Initial work

This commit is contained in:
Simon Fels 2016-05-26 22:38:57 +02:00 • committed by Simon Fels
commit 3222551702
374 changed files with 40290 additions and 0 deletions

View file

@ -0,0 +1,2 @@
add_subdirectory(tools)
add_subdirectory(libs)

View file

@ -0,0 +1,106 @@
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __etc1_h__
#define __etc1_h__
#define ETC1_ENCODED_BLOCK_SIZE 8
#define ETC1_DECODED_BLOCK_SIZE 48
#ifndef ETC1_RGB8_OES
#define ETC1_RGB8_OES 0x8D64
#endif
typedef unsigned char etc1_byte;
typedef int etc1_bool;
typedef unsigned int etc1_uint32;
#ifdef __cplusplus
extern "C" {
#endif
// Encode a block of pixels.
//
// pIn is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a
// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R
// value of pixel (x, y).
//
// validPixelMask is a 16-bit mask where bit (1 << (x + y * 4)) indicates whether
// the corresponding (x,y) pixel is valid. Invalid pixel color values are ignored when compressing.
//
// pOut is an ETC1 compressed version of the data.
void etc1_encode_block(const etc1_byte* pIn, etc1_uint32 validPixelMask, etc1_byte* pOut);
// Decode a block of pixels.
//
// pIn is an ETC1 compressed version of the data.
//
// pOut is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a
// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R
// value of pixel (x, y).
void etc1_decode_block(const etc1_byte* pIn, etc1_byte* pOut);
// Return the size of the encoded image data (does not include size of PKM header).
etc1_uint32 etc1_get_encoded_data_size(etc1_uint32 width, etc1_uint32 height);
// Encode an entire image.
// pIn - pointer to the image data. Formatted such that
// pixel (x,y) is at pIn + pixelSize * x + stride * y;
// pOut - pointer to encoded data. Must be large enough to store entire encoded image.
// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
// returns non-zero if there is an error.
int etc1_encode_image(const etc1_byte* pIn, etc1_uint32 width, etc1_uint32 height,
etc1_uint32 pixelSize, etc1_uint32 stride, etc1_byte* pOut);
// Decode an entire image.
// pIn - pointer to encoded data.
// pOut - pointer to the image data. Will be written such that
// pixel (x,y) is at pIn + pixelSize * x + stride * y. Must be
// large enough to store entire image.
// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
// returns non-zero if there is an error.
int etc1_decode_image(const etc1_byte* pIn, etc1_byte* pOut,
etc1_uint32 width, etc1_uint32 height,
etc1_uint32 pixelSize, etc1_uint32 stride);
// Size of a PKM header, in bytes.
#define ETC_PKM_HEADER_SIZE 16
// Format a PKM header
void etc1_pkm_format_header(etc1_byte* pHeader, etc1_uint32 width, etc1_uint32 height);
// Check if a PKM header is correctly formatted.
etc1_bool etc1_pkm_is_valid(const etc1_byte* pHeader);
// Read the image width from a PKM header
etc1_uint32 etc1_pkm_get_width(const etc1_byte* pHeader);
// Read the image height from a PKM header
etc1_uint32 etc1_pkm_get_height(const etc1_byte* pHeader);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,770 @@
#ifndef __gl_h_
#define __gl_h_
/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */
#include <GLES/glplatform.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
typedef void GLvoid;
typedef char GLchar;
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef khronos_int8_t GLbyte;
typedef short GLshort;
typedef int GLint;
typedef int GLsizei;
typedef khronos_uint8_t GLubyte;
typedef unsigned short GLushort;
typedef unsigned int GLuint;
typedef khronos_float_t GLfloat;
typedef khronos_float_t GLclampf;
typedef khronos_int32_t GLfixed;
typedef khronos_int32_t GLclampx;
typedef khronos_intptr_t GLintptr;
typedef khronos_ssize_t GLsizeiptr;
/*************************************************************/
/* OpenGL ES core versions */
#define GL_VERSION_ES_CM_1_0 1
#define GL_VERSION_ES_CL_1_0 1
#define GL_VERSION_ES_CM_1_1 1
#define GL_VERSION_ES_CL_1_1 1
/* ClearBufferMask */
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_COLOR_BUFFER_BIT 0x00004000
/* Boolean */
#define GL_FALSE 0
#define GL_TRUE 1
/* BeginMode */
#define GL_POINTS 0x0000
#define GL_LINES 0x0001
#define GL_LINE_LOOP 0x0002
#define GL_LINE_STRIP 0x0003
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_STRIP 0x0005
#define GL_TRIANGLE_FAN 0x0006
/* AlphaFunction */
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
#define GL_EQUAL 0x0202
#define GL_LEQUAL 0x0203
#define GL_GREATER 0x0204
#define GL_NOTEQUAL 0x0205
#define GL_GEQUAL 0x0206
#define GL_ALWAYS 0x0207
/* BlendingFactorDest */
#define GL_ZERO 0
#define GL_ONE 1
#define GL_SRC_COLOR 0x0300
#define GL_ONE_MINUS_SRC_COLOR 0x0301
#define GL_SRC_ALPHA 0x0302
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
#define GL_DST_ALPHA 0x0304
#define GL_ONE_MINUS_DST_ALPHA 0x0305
/* BlendingFactorSrc */
/* GL_ZERO */
/* GL_ONE */
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA_SATURATE 0x0308
/* GL_SRC_ALPHA */
/* GL_ONE_MINUS_SRC_ALPHA */
/* GL_DST_ALPHA */
/* GL_ONE_MINUS_DST_ALPHA */
/* ClipPlaneName */
#define GL_CLIP_PLANE0 0x3000
#define GL_CLIP_PLANE1 0x3001
#define GL_CLIP_PLANE2 0x3002
#define GL_CLIP_PLANE3 0x3003
#define GL_CLIP_PLANE4 0x3004
#define GL_CLIP_PLANE5 0x3005
/* ColorMaterialFace */
/* GL_FRONT_AND_BACK */
/* ColorMaterialParameter */
/* GL_AMBIENT_AND_DIFFUSE */
/* ColorPointerType */
/* GL_UNSIGNED_BYTE */
/* GL_FLOAT */
/* GL_FIXED */
/* CullFaceMode */
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_FRONT_AND_BACK 0x0408
/* DepthFunction */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* EnableCap */
#define GL_FOG 0x0B60
#define GL_LIGHTING 0x0B50
#define GL_TEXTURE_2D 0x0DE1
#define GL_CULL_FACE 0x0B44
#define GL_ALPHA_TEST 0x0BC0
#define GL_BLEND 0x0BE2
#define GL_COLOR_LOGIC_OP 0x0BF2
#define GL_DITHER 0x0BD0
#define GL_STENCIL_TEST 0x0B90
#define GL_DEPTH_TEST 0x0B71
/* GL_LIGHT0 */
/* GL_LIGHT1 */
/* GL_LIGHT2 */
/* GL_LIGHT3 */
/* GL_LIGHT4 */
/* GL_LIGHT5 */
/* GL_LIGHT6 */
/* GL_LIGHT7 */
#define GL_POINT_SMOOTH 0x0B10
#define GL_LINE_SMOOTH 0x0B20
#define GL_SCISSOR_TEST 0x0C11
#define GL_COLOR_MATERIAL 0x0B57
#define GL_NORMALIZE 0x0BA1
#define GL_RESCALE_NORMAL 0x803A
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_VERTEX_ARRAY 0x8074
#define GL_NORMAL_ARRAY 0x8075
#define GL_COLOR_ARRAY 0x8076
#define GL_TEXTURE_COORD_ARRAY 0x8078
#define GL_MULTISAMPLE 0x809D
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
#define GL_SAMPLE_COVERAGE 0x80A0
/* ErrorCode */
#define GL_NO_ERROR 0
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_OPERATION 0x0502
#define GL_STACK_OVERFLOW 0x0503
#define GL_STACK_UNDERFLOW 0x0504
#define GL_OUT_OF_MEMORY 0x0505
/* FogMode */
/* GL_LINEAR */
#define GL_EXP 0x0800
#define GL_EXP2 0x0801
/* FogParameter */
#define GL_FOG_DENSITY 0x0B62
#define GL_FOG_START 0x0B63
#define GL_FOG_END 0x0B64
#define GL_FOG_MODE 0x0B65
#define GL_FOG_COLOR 0x0B66
/* FrontFaceDirection */
#define GL_CW 0x0900
#define GL_CCW 0x0901
/* GetPName */
#define GL_CURRENT_COLOR 0x0B00
#define GL_CURRENT_NORMAL 0x0B02
#define GL_CURRENT_TEXTURE_COORDS 0x0B03
#define GL_POINT_SIZE 0x0B11
#define GL_POINT_SIZE_MIN 0x8126
#define GL_POINT_SIZE_MAX 0x8127
#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
#define GL_POINT_DISTANCE_ATTENUATION 0x8129
#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
#define GL_LINE_WIDTH 0x0B21
#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_SHADE_MODEL 0x0B54
#define GL_DEPTH_RANGE 0x0B70
#define GL_DEPTH_WRITEMASK 0x0B72
#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_DEPTH_FUNC 0x0B74
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_FUNC 0x0B92
#define GL_STENCIL_VALUE_MASK 0x0B93
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_REF 0x0B97
#define GL_STENCIL_WRITEMASK 0x0B98
#define GL_MATRIX_MODE 0x0BA0
#define GL_VIEWPORT 0x0BA2
#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
#define GL_PROJECTION_STACK_DEPTH 0x0BA4
#define GL_TEXTURE_STACK_DEPTH 0x0BA5
#define GL_MODELVIEW_MATRIX 0x0BA6
#define GL_PROJECTION_MATRIX 0x0BA7
#define GL_TEXTURE_MATRIX 0x0BA8
#define GL_ALPHA_TEST_FUNC 0x0BC1
#define GL_ALPHA_TEST_REF 0x0BC2
#define GL_BLEND_DST 0x0BE0
#define GL_BLEND_SRC 0x0BE1
#define GL_LOGIC_OP_MODE 0x0BF0
#define GL_SCISSOR_BOX 0x0C10
#define GL_SCISSOR_TEST 0x0C11
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_MAX_LIGHTS 0x0D31
#define GL_MAX_CLIP_PLANES 0x0D32
#define GL_MAX_TEXTURE_SIZE 0x0D33
#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
#define GL_MAX_VIEWPORT_DIMS 0x0D3A
#define GL_MAX_TEXTURE_UNITS 0x84E2
#define GL_SUBPIXEL_BITS 0x0D50
#define GL_RED_BITS 0x0D52
#define GL_GREEN_BITS 0x0D53
#define GL_BLUE_BITS 0x0D54
#define GL_ALPHA_BITS 0x0D55
#define GL_DEPTH_BITS 0x0D56
#define GL_STENCIL_BITS 0x0D57
#define GL_POLYGON_OFFSET_UNITS 0x2A00
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_VERTEX_ARRAY_SIZE 0x807A
#define GL_VERTEX_ARRAY_TYPE 0x807B
#define GL_VERTEX_ARRAY_STRIDE 0x807C
#define GL_NORMAL_ARRAY_TYPE 0x807E
#define GL_NORMAL_ARRAY_STRIDE 0x807F
#define GL_COLOR_ARRAY_SIZE 0x8081
#define GL_COLOR_ARRAY_TYPE 0x8082
#define GL_COLOR_ARRAY_STRIDE 0x8083
#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
#define GL_VERTEX_ARRAY_POINTER 0x808E
#define GL_NORMAL_ARRAY_POINTER 0x808F
#define GL_COLOR_ARRAY_POINTER 0x8090
#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
/* GL_TEXTURE_MIN_FILTER */
/* GL_TEXTURE_WRAP_S */
/* GL_TEXTURE_WRAP_T */
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
/* HintMode */
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
/* HintTarget */
#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
#define GL_POINT_SMOOTH_HINT 0x0C51
#define GL_LINE_SMOOTH_HINT 0x0C52
#define GL_FOG_HINT 0x0C54
#define GL_GENERATE_MIPMAP_HINT 0x8192
/* LightModelParameter */
#define GL_LIGHT_MODEL_AMBIENT 0x0B53
#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
/* LightParameter */
#define GL_AMBIENT 0x1200
#define GL_DIFFUSE 0x1201
#define GL_SPECULAR 0x1202
#define GL_POSITION 0x1203
#define GL_SPOT_DIRECTION 0x1204
#define GL_SPOT_EXPONENT 0x1205
#define GL_SPOT_CUTOFF 0x1206
#define GL_CONSTANT_ATTENUATION 0x1207
#define GL_LINEAR_ATTENUATION 0x1208
#define GL_QUADRATIC_ATTENUATION 0x1209
/* DataType */
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
#define GL_UNSIGNED_SHORT 0x1403
#define GL_FLOAT 0x1406
#define GL_FIXED 0x140C
/* LogicOp */
#define GL_CLEAR 0x1500
#define GL_AND 0x1501
#define GL_AND_REVERSE 0x1502
#define GL_COPY 0x1503
#define GL_AND_INVERTED 0x1504
#define GL_NOOP 0x1505
#define GL_XOR 0x1506
#define GL_OR 0x1507
#define GL_NOR 0x1508
#define GL_EQUIV 0x1509
#define GL_INVERT 0x150A
#define GL_OR_REVERSE 0x150B
#define GL_COPY_INVERTED 0x150C
#define GL_OR_INVERTED 0x150D
#define GL_NAND 0x150E
#define GL_SET 0x150F
/* MaterialFace */
/* GL_FRONT_AND_BACK */
/* MaterialParameter */
#define GL_EMISSION 0x1600
#define GL_SHININESS 0x1601
#define GL_AMBIENT_AND_DIFFUSE 0x1602
/* GL_AMBIENT */
/* GL_DIFFUSE */
/* GL_SPECULAR */
/* MatrixMode */
#define GL_MODELVIEW 0x1700
#define GL_PROJECTION 0x1701
#define GL_TEXTURE 0x1702
/* NormalPointerType */
/* GL_BYTE */
/* GL_SHORT */
/* GL_FLOAT */
/* GL_FIXED */
/* PixelFormat */
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
/* PixelStoreParameter */
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_ALIGNMENT 0x0D05
/* PixelType */
/* GL_UNSIGNED_BYTE */
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
/* ShadingModel */
#define GL_FLAT 0x1D00
#define GL_SMOOTH 0x1D01
/* StencilFunction */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* StencilOp */
/* GL_ZERO */
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
#define GL_DECR 0x1E03
/* GL_INVERT */
/* StringName */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
/* TexCoordPointerType */
/* GL_SHORT */
/* GL_FLOAT */
/* GL_FIXED */
/* GL_BYTE */
/* TextureEnvMode */
#define GL_MODULATE 0x2100
#define GL_DECAL 0x2101
/* GL_BLEND */
#define GL_ADD 0x0104
/* GL_REPLACE */
/* TextureEnvParameter */
#define GL_TEXTURE_ENV_MODE 0x2200
#define GL_TEXTURE_ENV_COLOR 0x2201
/* TextureEnvTarget */
#define GL_TEXTURE_ENV 0x2300
/* TextureMagFilter */
#define GL_NEAREST 0x2600
#define GL_LINEAR 0x2601
/* TextureMinFilter */
/* GL_NEAREST */
/* GL_LINEAR */
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
/* TextureParameterName */
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
#define GL_GENERATE_MIPMAP 0x8191
/* TextureTarget */
/* GL_TEXTURE_2D */
/* TextureUnit */
#define GL_TEXTURE0 0x84C0
#define GL_TEXTURE1 0x84C1
#define GL_TEXTURE2 0x84C2
#define GL_TEXTURE3 0x84C3
#define GL_TEXTURE4 0x84C4
#define GL_TEXTURE5 0x84C5
#define GL_TEXTURE6 0x84C6
#define GL_TEXTURE7 0x84C7
#define GL_TEXTURE8 0x84C8
#define GL_TEXTURE9 0x84C9
#define GL_TEXTURE10 0x84CA
#define GL_TEXTURE11 0x84CB
#define GL_TEXTURE12 0x84CC
#define GL_TEXTURE13 0x84CD
#define GL_TEXTURE14 0x84CE
#define GL_TEXTURE15 0x84CF
#define GL_TEXTURE16 0x84D0
#define GL_TEXTURE17 0x84D1
#define GL_TEXTURE18 0x84D2
#define GL_TEXTURE19 0x84D3
#define GL_TEXTURE20 0x84D4
#define GL_TEXTURE21 0x84D5
#define GL_TEXTURE22 0x84D6
#define GL_TEXTURE23 0x84D7
#define GL_TEXTURE24 0x84D8
#define GL_TEXTURE25 0x84D9
#define GL_TEXTURE26 0x84DA
#define GL_TEXTURE27 0x84DB
#define GL_TEXTURE28 0x84DC
#define GL_TEXTURE29 0x84DD
#define GL_TEXTURE30 0x84DE
#define GL_TEXTURE31 0x84DF
#define GL_ACTIVE_TEXTURE 0x84E0
#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
/* TextureWrapMode */
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
/* VertexPointerType */
/* GL_SHORT */
/* GL_FLOAT */
/* GL_FIXED */
/* GL_BYTE */
/* LightName */
#define GL_LIGHT0 0x4000
#define GL_LIGHT1 0x4001
#define GL_LIGHT2 0x4002
#define GL_LIGHT3 0x4003
#define GL_LIGHT4 0x4004
#define GL_LIGHT5 0x4005
#define GL_LIGHT6 0x4006
#define GL_LIGHT7 0x4007
/* Buffer Objects */
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
/* Texture combine + dot3 */
#define GL_SUBTRACT 0x84E7
#define GL_COMBINE 0x8570
#define GL_COMBINE_RGB 0x8571
#define GL_COMBINE_ALPHA 0x8572
#define GL_RGB_SCALE 0x8573
#define GL_ADD_SIGNED 0x8574
#define GL_INTERPOLATE 0x8575
#define GL_CONSTANT 0x8576
#define GL_PRIMARY_COLOR 0x8577
#define GL_PREVIOUS 0x8578
#define GL_OPERAND0_RGB 0x8590
#define GL_OPERAND1_RGB 0x8591
#define GL_OPERAND2_RGB 0x8592
#define GL_OPERAND0_ALPHA 0x8598
#define GL_OPERAND1_ALPHA 0x8599
#define GL_OPERAND2_ALPHA 0x859A
#define GL_ALPHA_SCALE 0x0D1C
#define GL_SRC0_RGB 0x8580
#define GL_SRC1_RGB 0x8581
#define GL_SRC2_RGB 0x8582
#define GL_SRC0_ALPHA 0x8588
#define GL_SRC1_ALPHA 0x8589
#define GL_SRC2_ALPHA 0x858A
#define GL_DOT3_RGB 0x86AE
#define GL_DOT3_RGBA 0x86AF
/*------------------------------------------------------------------------*
* required OES extension tokens
*------------------------------------------------------------------------*/
/* OES_read_format */
#ifndef GL_OES_read_format
#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
#endif
/* GL_OES_compressed_paletted_texture */
#ifndef GL_OES_compressed_paletted_texture
#define GL_PALETTE4_RGB8_OES 0x8B90
#define GL_PALETTE4_RGBA8_OES 0x8B91
#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
#define GL_PALETTE4_RGBA4_OES 0x8B93
#define GL_PALETTE4_RGB5_A1_OES 0x8B94
#define GL_PALETTE8_RGB8_OES 0x8B95
#define GL_PALETTE8_RGBA8_OES 0x8B96
#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
#define GL_PALETTE8_RGBA4_OES 0x8B98
#define GL_PALETTE8_RGB5_A1_OES 0x8B99
#endif
/* OES_point_size_array */
#ifndef GL_OES_point_size_array
#define GL_POINT_SIZE_ARRAY_OES 0x8B9C
#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A
#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B
#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C
#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F
#endif
/* GL_OES_point_sprite */
#ifndef GL_OES_point_sprite
#define GL_POINT_SPRITE_OES 0x8861
#define GL_COORD_REPLACE_OES 0x8862
#endif
/*************************************************************/
/* Available only in Common profile */
GL_API void GL_APIENTRY glAlphaFunc (GLenum func, GLclampf ref);
GL_API void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
GL_API void GL_APIENTRY glClearDepthf (GLclampf depth);
GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation);
GL_API void GL_APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
GL_API void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
GL_API void GL_APIENTRY glFogf (GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glFogfv (GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat eqn[4]);
GL_API void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetTexEnvfv (GLenum env, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);
GL_API void GL_APIENTRY glLightModelf (GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glLightModelfv (GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glLightf (GLenum light, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glLineWidth (GLfloat width);
GL_API void GL_APIENTRY glLoadMatrixf (const GLfloat *m);
GL_API void GL_APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glMultMatrixf (const GLfloat *m);
GL_API void GL_APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
GL_API void GL_APIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz);
GL_API void GL_APIENTRY glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glPointParameterf (GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glPointSize (GLfloat size);
GL_API void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
GL_API void GL_APIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
GL_API void GL_APIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z);
GL_API void GL_APIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
GL_API void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);
GL_API void GL_APIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z);
/* Available in both Common and Common-Lite profiles */
GL_API void GL_APIENTRY glActiveTexture (GLenum texture);
GL_API void GL_APIENTRY glAlphaFuncx (GLenum func, GLclampx ref);
GL_API void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
GL_API void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
GL_API void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
GL_API void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
GL_API void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
GL_API void GL_APIENTRY glClear (GLbitfield mask);
GL_API void GL_APIENTRY glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
GL_API void GL_APIENTRY glClearDepthx (GLclampx depth);
GL_API void GL_APIENTRY glClearStencil (GLint s);
GL_API void GL_APIENTRY glClientActiveTexture (GLenum texture);
GL_API void GL_APIENTRY glClipPlanex (GLenum plane, const GLfixed *equation);
GL_API void GL_APIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
GL_API void GL_APIENTRY glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
GL_API void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
GL_API void GL_APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
GL_API void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
GL_API void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
GL_API void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GL_API void GL_APIENTRY glCullFace (GLenum mode);
GL_API void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
GL_API void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
GL_API void GL_APIENTRY glDepthFunc (GLenum func);
GL_API void GL_APIENTRY glDepthMask (GLboolean flag);
GL_API void GL_APIENTRY glDepthRangex (GLclampx zNear, GLclampx zFar);
GL_API void GL_APIENTRY glDisable (GLenum cap);
GL_API void GL_APIENTRY glDisableClientState (GLenum array);
GL_API void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
GL_API void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
GL_API void GL_APIENTRY glEnable (GLenum cap);
GL_API void GL_APIENTRY glEnableClientState (GLenum array);
GL_API void GL_APIENTRY glFinish (void);
GL_API void GL_APIENTRY glFlush (void);
GL_API void GL_APIENTRY glFogx (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glFogxv (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glFrontFace (GLenum mode);
GL_API void GL_APIENTRY glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
GL_API void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *params);
GL_API void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetClipPlanex (GLenum pname, GLfixed eqn[4]);
GL_API void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
GL_API void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures);
GL_API GLenum GL_APIENTRY glGetError (void);
GL_API void GL_APIENTRY glGetFixedv (GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetLightxv (GLenum light, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetPointerv (GLenum pname, GLvoid **params);
GL_API const GLubyte * GL_APIENTRY glGetString (GLenum name);
GL_API void GL_APIENTRY glGetTexEnviv (GLenum env, GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
GL_API void GL_APIENTRY glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params);
GL_API void GL_APIENTRY glHint (GLenum target, GLenum mode);
GL_API GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
GL_API GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
GL_API GLboolean GL_APIENTRY glIsTexture (GLuint texture);
GL_API void GL_APIENTRY glLightModelx (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glLightModelxv (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glLightx (GLenum light, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glLightxv (GLenum light, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glLineWidthx (GLfixed width);
GL_API void GL_APIENTRY glLoadIdentity (void);
GL_API void GL_APIENTRY glLoadMatrixx (const GLfixed *m);
GL_API void GL_APIENTRY glLogicOp (GLenum opcode);
GL_API void GL_APIENTRY glMaterialx (GLenum face, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glMaterialxv (GLenum face, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glMatrixMode (GLenum mode);
GL_API void GL_APIENTRY glMultMatrixx (const GLfixed *m);
GL_API void GL_APIENTRY glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
GL_API void GL_APIENTRY glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz);
GL_API void GL_APIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
GL_API void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
GL_API void GL_APIENTRY glPointParameterx (GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glPointParameterxv (GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glPointSizex (GLfixed size);
GL_API void GL_APIENTRY glPolygonOffsetx (GLfixed factor, GLfixed units);
GL_API void GL_APIENTRY glPopMatrix (void);
GL_API void GL_APIENTRY glPushMatrix (void);
GL_API void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
GL_API void GL_APIENTRY glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
GL_API void GL_APIENTRY glSampleCoveragex (GLclampx value, GLboolean invert);
GL_API void GL_APIENTRY glScalex (GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
GL_API void GL_APIENTRY glShadeModel (GLenum mode);
GL_API void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
GL_API void GL_APIENTRY glStencilMask (GLuint mask);
GL_API void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
GL_API void GL_APIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param);
GL_API void GL_APIENTRY glTexEnvx (GLenum target, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params);
GL_API void GL_APIENTRY glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
GL_API void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
GL_API void GL_APIENTRY glTexParameterx (GLenum target, GLenum pname, GLfixed param);
GL_API void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);
GL_API void GL_APIENTRY glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params);
GL_API void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
GL_API void GL_APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z);
GL_API void GL_APIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
GL_API void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
/*------------------------------------------------------------------------*
* Required OES extension functions
*------------------------------------------------------------------------*/
/* GL_OES_read_format */
#ifndef GL_OES_read_format
#define GL_OES_read_format 1
#endif
/* GL_OES_compressed_paletted_texture */
#ifndef GL_OES_compressed_paletted_texture
#define GL_OES_compressed_paletted_texture 1
#endif
/* GL_OES_point_size_array */
#ifndef GL_OES_point_size_array
#define GL_OES_point_size_array 1
GL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer);
#endif
/* GL_OES_point_sprite */
#ifndef GL_OES_point_sprite
#define GL_OES_point_sprite 1
#endif
#ifdef __cplusplus
}
#endif
#endif /* __gl_h_ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,30 @@
#ifndef __glplatform_h_
#define __glplatform_h_
/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/* Platform-specific types and definitions for OpenGL ES 1.X gl.h
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "OpenGL-ES" component "Registry".
*/
#include <KHR/khrplatform.h>
#ifndef GL_API
#define GL_API KHRONOS_APICALL
#endif
#ifndef GL_APIENTRY
#define GL_APIENTRY KHRONOS_APIENTRY
#endif
#endif /* __glplatform_h_ */

View file

@ -0,0 +1,53 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "OpenGLESDispatch/RenderEGL_functions.h"
#include "OpenGLESDispatch/RenderEGL_extensions_functions.h"
// This header is used to define the EGLDispatch structure that contains
// pointers to the EGL shared library used by libOpenglRender. Normally,
// this will be our own libEGL_translator, but one could imagine a
// vendor-specific being used instead.
// There is a single global instance of this structure, named |s_egl|,
// which must be initialized by calling init_egl_dispatch() before use.
// Note that our code requires the implementation of misc EGL extensions
// including eglSetSwapRectangleANDROID(), see RenderEGL_extensions_functions.h
// for a full list.
#define RENDER_EGL_DEFINE_TYPE(return_type, function_name, signature) \
typedef return_type (EGLAPIENTRY *function_name ## _t) signature;
#define RENDER_EGL_DECLARE_MEMBER(return_type, function_name, signature) \
function_name ## _t function_name;
// Define function typedefs.
LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_DEFINE_TYPE)
LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_DEFINE_TYPE)
// Define EGLDispatch structure.
struct EGLDispatch {
LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_DECLARE_MEMBER)
LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_DECLARE_MEMBER)
};
// Initialize EGLDispatch function. Return true on success, false on failure.
bool init_egl_dispatch();
// Global EGLDispatch instance. Call init_egl_dispatch() before using it.
extern EGLDispatch s_egl;

View file

@ -0,0 +1,41 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "OpenGLESDispatch/gldefs.h"
#include "OpenGLESDispatch/gles_functions.h"
#include "KHR/khrplatform.h"
// Define function pointer types.
#define GLES1_DISPATCH_DEFINE_TYPE(return_type,func_name,signature,callargs) \
typedef return_type (KHRONOS_APIENTRY * func_name ## _t) signature;
LIST_GLES1_FUNCTIONS(GLES1_DISPATCH_DEFINE_TYPE,GLES1_DISPATCH_DEFINE_TYPE)
struct GLESv1Dispatch {
#define GLES1_DISPATCH_DECLARE_POINTER(return_type,func_name,signature,callargs) \
func_name ## _t func_name;
LIST_GLES1_FUNCTIONS(GLES1_DISPATCH_DECLARE_POINTER,
GLES1_DISPATCH_DECLARE_POINTER)
};
#undef GLES1_DISPATCH_DECLARE_POINTER
#undef GLES1_DISPATCH_DEFINE_TYPE
bool gles1_dispatch_init(GLESv1Dispatch* dispatch_table);
// Used to initialize the decoder.
void* gles1_dispatch_get_proc_func(const char* name, void* userData);

View file

@ -0,0 +1,41 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "OpenGLESDispatch/gldefs.h"
#include "OpenGLESDispatch/gles_functions.h"
#include "KHR/khrplatform.h"
// Define function pointer types.
#define GLES2_DISPATCH_DEFINE_TYPE(return_type,func_name,signature,callargs) \
typedef return_type (KHRONOS_APIENTRY * func_name ## _t) signature;
LIST_GLES2_FUNCTIONS(GLES2_DISPATCH_DEFINE_TYPE,GLES2_DISPATCH_DEFINE_TYPE)
struct GLESv2Dispatch {
#define GLES2_DISPATCH_DECLARE_POINTER(return_type,func_name,signature,callargs) \
func_name ## _t func_name;
LIST_GLES2_FUNCTIONS(GLES2_DISPATCH_DECLARE_POINTER,
GLES2_DISPATCH_DECLARE_POINTER)
};
#undef GLES2_DISPATCH_DECLARE_POINTER
#undef GLES2_DISPATCH_DEFINE_TYPE
bool gles2_dispatch_init(GLESv2Dispatch* dispatch_table);
// Used to initialize the decoder.
void* gles2_dispatch_get_proc_func(const char* name, void* userData);

View file

@ -0,0 +1,15 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=functions distrib/android-emugl/host/libs/libOpenGLESDispatch/render_egl_extensions.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/RenderEGL_extensions_functions.h
// DO NOT EDIT THIS FILE
#ifndef RENDER_EGL_EXTENSIONS_FUNCTIONS_H
#define RENDER_EGL_EXTENSIONS_FUNCTIONS_H
#include <EGL/egl.h>
#define EGL_EGLEXT_PROTOTYPES
#include <EGL/eglext.h>
#define LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(X) \
X(EGLImageKHR, eglCreateImageKHR, (EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list)) \
X(EGLBoolean, eglDestroyImageKHR, (EGLDisplay display, EGLImageKHR image)) \
#endif // RENDER_EGL_EXTENSIONS_FUNCTIONS_H

View file

@ -0,0 +1,31 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=functions distrib/android-emugl/host/libs/libOpenGLESDispatch/render_egl.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/RenderEGL_functions.h
// DO NOT EDIT THIS FILE
#ifndef RENDER_EGL_FUNCTIONS_H
#define RENDER_EGL_FUNCTIONS_H
#include <EGL/egl.h>
#define LIST_RENDER_EGL_FUNCTIONS(X) \
X(EGLint, eglGetError, ()) \
X(EGLDisplay, eglGetDisplay, (EGLNativeDisplayType dpy)) \
X(EGLBoolean, eglInitialize, (EGLDisplay dpy, EGLint* major, EGLint* minor)) \
X(char*, eglQueryString, (EGLDisplay dpy, EGLint id)) \
X(EGLBoolean, eglGetConfigs, (EGLDisplay display, EGLConfig* configs, EGLint config_size, EGLint* num_config)) \
X(EGLBoolean, eglChooseConfig, (EGLDisplay display, const EGLint* attribs, EGLConfig* configs, EGLint config_size, EGLint* num_config)) \
X(EGLBoolean, eglGetConfigAttrib, (EGLDisplay display, EGLConfig config, EGLint attribute, EGLint* value)) \
X(EGLSurface, eglCreateWindowSurface, (EGLDisplay display, EGLConfig config, EGLNativeWindowType native_window, const EGLint* attrib_list)) \
X(EGLSurface, eglCreatePbufferSurface, (EGLDisplay display, EGLConfig config, const EGLint* attrib_list)) \
X(EGLBoolean, eglDestroySurface, (EGLDisplay display, EGLSurface surface)) \
X(EGLBoolean, eglBindAPI, (EGLenum api)) \
X(EGLenum, eglQueryAPI, ()) \
X(EGLBoolean, eglReleaseThread, ()) \
X(EGLContext, eglCreateContext, (EGLDisplay display, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)) \
X(EGLBoolean, eglDestroyContext, (EGLDisplay display, EGLContext context)) \
X(EGLBoolean, eglMakeCurrent, (EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context)) \
X(EGLContext, eglGetCurrentContext, ()) \
X(EGLSurface, eglGetCurrentSurface, (EGLint readdraw)) \
X(EGLBoolean, eglSwapBuffers, (EGLDisplay display, EGLSurface surface)) \
X(void*, eglGetProcAddress, (const char* function_name)) \
#endif // RENDER_EGL_FUNCTIONS_H

View file

@ -0,0 +1,45 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
typedef double GLclampd; /* double precision float in [0,1] */
typedef double GLdouble; /* double precision float */
typedef void* GLeglImageOES;
#define GL_S 0x2000
#define GL_T 0x2001
#define GL_R 0x2002
#define GL_Q 0x2003
#define GL_TEXTURE_GEN_S 0x0C60
#define GL_TEXTURE_GEN_T 0x0C61
#define GL_TEXTURE_GEN_R 0x0C62
#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
#define GL_TRANSFORM_BIT 0x00001000
#define GL_INT 0x1404
#define GL_HALF_FLOAT_NV 0x140B
#define GL_HALF_FLOAT 0x140B
#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
#define GL_POINT_SPRITE 0x8861
#define GL_FRAMEBUFFER_EXT 0x8D40
#define GL_TEXTURE_WIDTH 0x1000
#define GL_TEXTURE_HEIGHT 0x1001
#define GL_TEXTURE_RED_SIZE 0x805C
#define GL_TEXTURE_GREEN_SIZE 0x805D
#define GL_TEXTURE_BLUE_SIZE 0x805E
#define GL_TEXTURE_ALPHA_SIZE 0x805F
#define GL_TEXTURE_DEPTH_SIZE 0x884A
#define GL_TEXTURE_INTERNAL_FORMAT 0x1003

View file

@ -0,0 +1,27 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles1_extensions.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles1_extensions_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES1_EXTENSIONS_FUNCTIONS_H
#define GLES1_EXTENSIONS_FUNCTIONS_H
#define LIST_GLES1_EXTENSIONS_FUNCTIONS(X) \
X(void, glCurrentPaletteMatrixARB, (GLint index), (index)) \
X(void, glMatrixIndexuivARB, (GLint size, GLuint * indices), (size, indices)) \
X(void, glMatrixIndexPointerARB, (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer), (size, type, stride, pointer)) \
X(void, glWeightPointerARB, (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer), (size, type, stride, pointer)) \
X(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param), (coord, pname, param)) \
X(void, glTexGeni, (GLenum coord, GLenum pname, GLint param), (coord, pname, param)) \
X(void, glTexGenfv, (GLenum coord, GLenum pname, const GLfloat * params), (coord, pname, params)) \
X(void, glTexGeniv, (GLenum coord, GLenum pname, const GLint * params), (coord, pname, params)) \
X(void, glGetTexGenfv, (GLenum coord, GLenum pname, GLfloat * params), (coord, pname, params)) \
X(void, glGetTexGeniv, (GLenum coord, GLenum pname, GLint * params), (coord, pname, params)) \
X(void, glDrawTexsOES, (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height), (x, y, z, width, height)) \
X(void, glDrawTexiOES, (GLshort x, GLint y, GLint z, GLint width, GLshort height), (x, y, z, width, height)) \
X(void, glDrawTexfOES, (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height), (x, y, z, width, height)) \
X(void, glDrawTexxOES, (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height), (x, y, z, width, height)) \
X(void, glDrawTexsvOES, (const GLshort *coords), (coords)) \
X(void, glDrawTexivOES, (const GLint *coords), (coords)) \
X(void, glDrawTexxvOES, (const GLfixed *coords), (coords)) \
X(void, glDrawTexfvOES, (const GLfloat *coords), (coords)) \
#endif // GLES1_EXTENSIONS_FUNCTIONS_H

View file

@ -0,0 +1,71 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles1_only.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles1_only_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES1_ONLY_FUNCTIONS_H
#define GLES1_ONLY_FUNCTIONS_H
#define LIST_GLES1_ONLY_FUNCTIONS(X) \
X(void, glAlphaFunc, (GLenum func, GLclampf ref), (func, ref)) \
X(void, glBegin, (GLenum mode), (mode)) \
X(void, glClientActiveTexture, (GLenum texture), (texture)) \
X(void, glClipPlane, (GLenum plane, const GLdouble * equation), (plane, equation)) \
X(void, glColor4d, (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha), (red, green, blue, alpha)) \
X(void, glColor4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red, green, blue, alpha)) \
X(void, glColor4fv, (const GLfloat * v), (v)) \
X(void, glColor4ub, (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha), (red, green, blue, alpha)) \
X(void, glColor4ubv, (const GLubyte * v), (v)) \
X(void, glColorPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer), (size, type, stride, pointer)) \
X(void, glDisableClientState, (GLenum array), (array)) \
X(void, glEnableClientState, (GLenum array), (array)) \
X(void, glEnd, (), ()) \
X(void, glFogf, (GLenum pname, GLfloat param), (pname, param)) \
X(void, glFogfv, (GLenum pname, const GLfloat * params), (pname, params)) \
X(void, glFrustum, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar), (left, right, bottom, top, zNear, zFar)) \
X(void, glGetClipPlane, (GLenum plane, GLdouble * equation), (plane, equation)) \
X(void, glGetDoublev, (GLenum pname, GLdouble * params), (pname, params)) \
X(void, glGetLightfv, (GLenum light, GLenum pname, GLfloat * params), (light, pname, params)) \
X(void, glGetMaterialfv, (GLenum face, GLenum pname, GLfloat * params), (face, pname, params)) \
X(void, glGetPointerv, (GLenum pname, GLvoid* * params), (pname, params)) \
X(void, glGetTexEnvfv, (GLenum target, GLenum pname, GLfloat * params), (target, pname, params)) \
X(void, glGetTexEnviv, (GLenum target, GLenum pname, GLint * params), (target, pname, params)) \
X(void, glLightf, (GLenum light, GLenum pname, GLfloat param), (light, pname, param)) \
X(void, glLightfv, (GLenum light, GLenum pname, const GLfloat * params), (light, pname, params)) \
X(void, glLightModelf, (GLenum pname, GLfloat param), (pname, param)) \
X(void, glLightModelfv, (GLenum pname, const GLfloat * params), (pname, params)) \
X(void, glLoadIdentity, (), ()) \
X(void, glLoadMatrixf, (const GLfloat * m), (m)) \
X(void, glLogicOp, (GLenum opcode), (opcode)) \
X(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param), (face, pname, param)) \
X(void, glMaterialfv, (GLenum face, GLenum pname, const GLfloat * params), (face, pname, params)) \
X(void, glMultiTexCoord2fv, (GLenum target, const GLfloat * v), (target, v)) \
X(void, glMultiTexCoord2sv, (GLenum target, const GLshort * v), (target, v)) \
X(void, glMultiTexCoord3fv, (GLenum target, const GLfloat * v), (target, v)) \
X(void, glMultiTexCoord3sv, (GLenum target, const GLshort * v), (target, v)) \
X(void, glMultiTexCoord4f, (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q), (target, s, t, r, q)) \
X(void, glMultiTexCoord4fv, (GLenum target, const GLfloat * v), (target, v)) \
X(void, glMultiTexCoord4sv, (GLenum target, const GLshort * v), (target, v)) \
X(void, glMultMatrixf, (const GLfloat * m), (m)) \
X(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz), (nx, ny, nz)) \
X(void, glNormal3fv, (const GLfloat * v), (v)) \
X(void, glNormal3sv, (const GLshort * v), (v)) \
X(void, glOrtho, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar), (left, right, bottom, top, zNear, zFar)) \
X(void, glPointParameterf, (GLenum param, GLfloat value), (param, value)) \
X(void, glPointParameterfv, (GLenum param, const GLfloat * values), (param, values)) \
X(void, glPointSize, (GLfloat size), (size)) \
X(void, glRotatef, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z), (angle, x, y, z)) \
X(void, glScalef, (GLfloat x, GLfloat y, GLfloat z), (x, y, z)) \
X(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param), (target, pname, param)) \
X(void, glTexEnvfv, (GLenum target, GLenum pname, const GLfloat * params), (target, pname, params)) \
X(void, glMatrixMode, (GLenum mode), (mode)) \
X(void, glNormalPointer, (GLenum type, GLsizei stride, const GLvoid * pointer), (type, stride, pointer)) \
X(void, glPopMatrix, (), ()) \
X(void, glPushMatrix, (), ()) \
X(void, glShadeModel, (GLenum mode), (mode)) \
X(void, glTexCoordPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer), (size, type, stride, pointer)) \
X(void, glTexEnvi, (GLenum target, GLenum pname, GLint param), (target, pname, param)) \
X(void, glTexEnviv, (GLenum target, GLenum pname, const GLint * params), (target, pname, params)) \
X(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z), (x, y, z)) \
X(void, glVertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer), (size, type, stride, pointer)) \
#endif // GLES1_ONLY_FUNCTIONS_H

View file

@ -0,0 +1,13 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles2_extensions.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles2_extensions_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES2_EXTENSIONS_FUNCTIONS_H
#define GLES2_EXTENSIONS_FUNCTIONS_H
#define LIST_GLES2_EXTENSIONS_FUNCTIONS(X) \
X(void, glGetShaderPrecisionFormat, (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision), (shadertype, precisiontype, range, precision)) \
X(void, glReleaseShaderCompiler, (), ()) \
X(void, glShaderBinary, (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length), (n, shaders, binaryformat, binary, length)) \
#endif // GLES2_EXTENSIONS_FUNCTIONS_H

View file

@ -0,0 +1,85 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles2_only.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles2_only_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES2_ONLY_FUNCTIONS_H
#define GLES2_ONLY_FUNCTIONS_H
#define LIST_GLES2_ONLY_FUNCTIONS(X) \
X(void, glBlendColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (red, green, blue, alpha)) \
X(void, glStencilFuncSeparate, (GLenum face, GLenum func, GLint ref, GLuint mask), (face, func, ref, mask)) \
X(void, glStencilMaskSeparate, (GLenum face, GLuint mask), (face, mask)) \
X(void, glStencilOpSeparate, (GLenum face, GLenum fail, GLenum zfail, GLenum zpass), (face, fail, zfail, zpass)) \
X(GLboolean, glIsProgram, (GLuint program), (program)) \
X(GLboolean, glIsShader, (GLuint shader), (shader)) \
X(void, glVertexAttrib1f, (GLuint indx, GLfloat x), (indx, x)) \
X(void, glVertexAttrib1fv, (GLuint indx, const GLfloat* values), (indx, values)) \
X(void, glVertexAttrib2f, (GLuint indx, GLfloat x, GLfloat y), (indx, x, y)) \
X(void, glVertexAttrib2fv, (GLuint indx, const GLfloat* values), (indx, values)) \
X(void, glVertexAttrib3f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z), (indx, x, y, z)) \
X(void, glVertexAttrib3fv, (GLuint indx, const GLfloat* values), (indx, values)) \
X(void, glVertexAttrib4f, (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w), (indx, x, y, z, w)) \
X(void, glVertexAttrib4fv, (GLuint indx, const GLfloat* values), (indx, values)) \
X(void, glVertexAttribPointer, (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr), (indx, size, type, normalized, stride, ptr)) \
X(void, glDisableVertexAttribArray, (GLuint index), (index)) \
X(void, glEnableVertexAttribArray, (GLuint index), (index)) \
X(void, glGetVertexAttribfv, (GLuint index, GLenum pname, GLfloat* params), (index, pname, params)) \
X(void, glGetVertexAttribiv, (GLuint index, GLenum pname, GLint* params), (index, pname, params)) \
X(void, glGetVertexAttribPointerv, (GLuint index, GLenum pname, GLvoid** pointer), (index, pname, pointer)) \
X(void, glUniform1f, (GLint location, GLfloat x), (location, x)) \
X(void, glUniform1fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v)) \
X(void, glUniform1i, (GLint location, GLint x), (location, x)) \
X(void, glUniform1iv, (GLint location, GLsizei count, const GLint* v), (location, count, v)) \
X(void, glUniform2f, (GLint location, GLfloat x, GLfloat y), (location, x, y)) \
X(void, glUniform2fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v)) \
X(void, glUniform2i, (GLint location, GLint x, GLint y), (location, x, y)) \
X(void, glUniform2iv, (GLint location, GLsizei count, const GLint* v), (location, count, v)) \
X(void, glUniform3f, (GLint location, GLfloat x, GLfloat y, GLfloat z), (location, x, y, z)) \
X(void, glUniform3fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v)) \
X(void, glUniform3i, (GLint location, GLint x, GLint y, GLint z), (location, x, y, z)) \
X(void, glUniform3iv, (GLint location, GLsizei count, const GLint* v), (location, count, v)) \
X(void, glUniform4f, (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w), (location, x, y, z, w)) \
X(void, glUniform4fv, (GLint location, GLsizei count, const GLfloat* v), (location, count, v)) \
X(void, glUniform4i, (GLint location, GLint x, GLint y, GLint z, GLint w), (location, x, y, z, w)) \
X(void, glUniform4iv, (GLint location, GLsizei count, const GLint* v), (location, count, v)) \
X(void, glUniformMatrix2fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value)) \
X(void, glUniformMatrix3fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value)) \
X(void, glUniformMatrix4fv, (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (location, count, transpose, value)) \
X(void, glAttachShader, (GLuint program, GLuint shader), (program, shader)) \
X(void, glBindAttribLocation, (GLuint program, GLuint index, const GLchar* name), (program, index, name)) \
X(void, glCompileShader, (GLuint shader), (shader)) \
X(GLuint, glCreateProgram, (), ()) \
X(GLuint, glCreateShader, (GLenum type), (type)) \
X(void, glDeleteProgram, (GLuint program), (program)) \
X(void, glDeleteShader, (GLuint shader), (shader)) \
X(void, glDetachShader, (GLuint program, GLuint shader), (program, shader)) \
X(void, glLinkProgram, (GLuint program), (program)) \
X(void, glUseProgram, (GLuint program), (program)) \
X(void, glValidateProgram, (GLuint program), (program)) \
X(void, glGetActiveAttrib, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name), (program, index, bufsize, length, size, type, name)) \
X(void, glGetActiveUniform, (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name), (program, index, bufsize, length, size, type, name)) \
X(void, glGetAttachedShaders, (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders), (program, maxcount, count, shaders)) \
X(int, glGetAttribLocation, (GLuint program, const GLchar* name), (program, name)) \
X(void, glGetProgramiv, (GLuint program, GLenum pname, GLint* params), (program, pname, params)) \
X(void, glGetProgramInfoLog, (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog), (program, bufsize, length, infolog)) \
X(void, glGetShaderiv, (GLuint shader, GLenum pname, GLint* params), (shader, pname, params)) \
X(void, glGetShaderInfoLog, (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog), (shader, bufsize, length, infolog)) \
X(void, glGetShaderSource, (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source), (shader, bufsize, length, source)) \
X(void, glGetUniformfv, (GLuint program, GLint location, GLfloat* params), (program, location, params)) \
X(void, glGetUniformiv, (GLuint program, GLint location, GLint* params), (program, location, params)) \
X(int, glGetUniformLocation, (GLuint program, const GLchar* name), (program, name)) \
X(void, glShaderSource, (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length), (shader, count, string, length)) \
X(void, glBindFramebuffer, (GLenum target, GLuint framebuffer), (target, framebuffer)) \
X(void, glGenFramebuffers, (GLsizei n, GLuint* framebuffers), (n, framebuffers)) \
X(void, glFramebufferTexture2D, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level)) \
X(GLenum, glCheckFramebufferStatus, (GLenum target), (target)) \
X(void, glDeleteFramebuffers, (GLsizei n, const GLuint* framebuffers), (n, framebuffers)) \
X(GLboolean, glIsRenderbuffer, (GLuint renderbuffer), (renderbuffer)) \
X(void, glBindRenderbuffer, (GLenum target, GLuint renderbuffer), (target, renderbuffer)) \
X(void, glDeleteRenderbuffers, (GLsizei n, const GLuint * renderbuffers), (n, renderbuffers)) \
X(void, glGenRenderbuffers, (GLsizei n, GLuint * renderbuffers), (n, renderbuffers)) \
X(void, glRenderbufferStorage, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height), (target, internalformat, width, height)) \
X(void, glGetRenderbufferParameteriv, (GLenum target, GLenum pname, GLint * params), (target, pname, params)) \
X(void, glFramebufferRenderbuffer, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer), (target, attachment, renderbuffertarget, renderbuffer)) \
#endif // GLES2_ONLY_FUNCTIONS_H

View file

@ -0,0 +1,18 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles3_only.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles3_only_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES3_ONLY_FUNCTIONS_H
#define GLES3_ONLY_FUNCTIONS_H
#include <GLES/gl.h>
// Used to avoid adding GLES3/gl3.h to our headers.
#ifndef GL_NUM_EXTENSIONS
#define GL_NUM_EXTENSIONS 0x821D
#endif
typedef const GLubyte* GLconstubyteptr;
#define LIST_GLES3_ONLY_FUNCTIONS(X) \
X(GLconstubyteptr, glGetStringi, (GLenum name, GLint index), (name, index)) \
#endif // GLES3_ONLY_FUNCTIONS_H

View file

@ -0,0 +1,79 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles_common.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles_common_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES_COMMON_FUNCTIONS_H
#define GLES_COMMON_FUNCTIONS_H
#include <GLES/gl.h>
// Return types must be single words, see GLDispatch.cpp
typedef const GLubyte* GLconstubyteptr;
#define LIST_GLES_COMMON_FUNCTIONS(X) \
X(void, glActiveTexture, (GLenum texture), (texture)) \
X(void, glBindBuffer, (GLenum target, GLuint buffer), (target, buffer)) \
X(void, glBindTexture, (GLenum target, GLuint texture), (target, texture)) \
X(void, glBlendFunc, (GLenum sfactor, GLenum dfactor), (sfactor, dfactor)) \
X(void, glBlendEquation, (GLenum mode), (mode)) \
X(void, glBlendEquationSeparate, (GLenum modeRGB, GLenum modeAlpha), (modeRGB, modeAlpha)) \
X(void, glBlendFuncSeparate, (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha), (srcRGB, dstRGB, srcAlpha, dstAlpha)) \
X(void, glBufferData, (GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage), (target, size, data, usage)) \
X(void, glBufferSubData, (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data), (target, offset, size, data)) \
X(void, glClear, (GLbitfield mask), (mask)) \
X(void, glClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (red, green, blue, alpha)) \
X(void, glClearDepth, (GLclampd depth), (depth)) \
X(void, glClearStencil, (GLint s), (s)) \
X(void, glColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha), (red, green, blue, alpha)) \
X(void, glCompressedTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data), (target, level, internalformat, width, height, border, imageSize, data)) \
X(void, glCompressedTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data), (target, level, xoffset, yoffset, width, height, format, imageSize, data)) \
X(void, glCopyTexImage2D, (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border), (target, level, internalFormat, x, y, width, height, border)) \
X(void, glCopyTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height), (target, level, xoffset, yoffset, x, y, width, height)) \
X(void, glCullFace, (GLenum mode), (mode)) \
X(void, glDeleteBuffers, (GLsizei n, const GLuint * buffers), (n, buffers)) \
X(void, glDeleteTextures, (GLsizei n, const GLuint * textures), (n, textures)) \
X(void, glDepthFunc, (GLenum func), (func)) \
X(void, glDepthMask, (GLboolean flag), (flag)) \
X(void, glDepthRange, (GLclampd zNear, GLclampd zFar), (zNear, zFar)) \
X(void, glDisable, (GLenum cap), (cap)) \
X(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count), (mode, first, count)) \
X(void, glDrawElements, (GLenum mode, GLsizei count, GLenum type, const GLvoid * indices), (mode, count, type, indices)) \
X(void, glEnable, (GLenum cap), (cap)) \
X(void, glFinish, (), ()) \
X(void, glFlush, (), ()) \
X(void, glFrontFace, (GLenum mode), (mode)) \
X(void, glGenBuffers, (GLsizei n, GLuint * buffers), (n, buffers)) \
X(void, glGenTextures, (GLsizei n, GLuint * textures), (n, textures)) \
X(void, glGetBooleanv, (GLenum pname, GLboolean * params), (pname, params)) \
X(void, glGetBufferParameteriv, (GLenum buffer, GLenum parameter, GLint * value), (buffer, parameter, value)) \
X(GLenum, glGetError, (), ()) \
X(void, glGetFloatv, (GLenum pname, GLfloat * params), (pname, params)) \
X(void, glGetIntegerv, (GLenum pname, GLint * params), (pname, params)) \
X(GLconstubyteptr, glGetString, (GLenum name), (name)) \
X(void, glTexParameterf, (GLenum target, GLenum pname, GLfloat param), (target, pname, param)) \
X(void, glTexParameterfv, (GLenum target, GLenum pname, const GLfloat * params), (target, pname, params)) \
X(void, glGetTexParameterfv, (GLenum target, GLenum pname, GLfloat * params), (target, pname, params)) \
X(void, glGetTexParameteriv, (GLenum target, GLenum pname, GLint * params), (target, pname, params)) \
X(void, glGetTexLevelParameteriv, (GLenum target, GLint level, GLenum pname, GLint * params), (target, level, pname, params)) \
X(void, glHint, (GLenum target, GLenum mode), (target, mode)) \
X(GLboolean, glIsBuffer, (GLuint buffer), (buffer)) \
X(GLboolean, glIsEnabled, (GLenum cap), (cap)) \
X(GLboolean, glIsTexture, (GLuint texture), (texture)) \
X(void, glLineWidth, (GLfloat width), (width)) \
X(void, glPolygonOffset, (GLfloat factor, GLfloat units), (factor, units)) \
X(void, glPixelStorei, (GLenum pname, GLint param), (pname, param)) \
X(void, glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels), (x, y, width, height, format, type, pixels)) \
X(void, glSampleCoverage, (GLclampf value, GLboolean invert), (value, invert)) \
X(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height), (x, y, width, height)) \
X(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask), (func, ref, mask)) \
X(void, glStencilMask, (GLuint mask), (mask)) \
X(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass), (fail, zfail, zpass)) \
X(void, glTexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels), (target, level, internalformat, width, height, border, format, type, pixels)) \
X(void, glTexParameteri, (GLenum target, GLenum pname, GLint param), (target, pname, param)) \
X(void, glTexParameteriv, (GLenum target, GLenum pname, const GLint * params), (target, pname, params)) \
X(void, glTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels), (target, level, xoffset, yoffset, width, height, format, type, pixels)) \
X(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height), (x, y, width, height)) \
X(void, glPushAttrib, (GLbitfield mask), (mask)) \
X(void, glPushClientAttrib, (GLbitfield mask), (mask)) \
X(void, glPopAttrib, (), ()) \
X(void, glPopClientAttrib, (), ()) \
#endif // GLES_COMMON_FUNCTIONS_H

View file

@ -0,0 +1,29 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenGLESDispatch/gles_extensions.entries --output=distrib/android-emugl/host/include/OpenGLESDispatch/gles_extensions_functions.h
// DO NOT EDIT THIS FILE
#ifndef GLES_EXTENSIONS_FUNCTIONS_H
#define GLES_EXTENSIONS_FUNCTIONS_H
#define LIST_GLES_EXTENSIONS_FUNCTIONS(X) \
X(GLboolean, glIsRenderbufferEXT, (GLuint renderbuffer), (renderbuffer)) \
X(void, glBindRenderbufferEXT, (GLenum target, GLuint renderbuffer), (target, renderbuffer)) \
X(void, glDeleteRenderbuffersEXT, (GLsizei n, const GLuint * renderbuffers), (n, renderbuffers)) \
X(void, glGenRenderbuffersEXT, (GLsizei n, GLuint * renderbuffers), (n, renderbuffers)) \
X(void, glRenderbufferStorageEXT, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height), (target, internalformat, width, height)) \
X(void, glGetRenderbufferParameterivEXT, (GLenum target, GLenum pname, GLint * params), (target, pname, params)) \
X(GLboolean, glIsFramebufferEXT, (GLuint framebuffer), (framebuffer)) \
X(void, glBindFramebufferEXT, (GLenum target, GLuint framebuffer), (target, framebuffer)) \
X(void, glDeleteFramebuffersEXT, (GLsizei n, const GLuint * framebuffers), (n, framebuffers)) \
X(void, glGenFramebuffersEXT, (GLsizei n, GLuint * framebuffers), (n, framebuffers)) \
X(GLenum, glCheckFramebufferStatusEXT, (GLenum target), (target)) \
X(void, glFramebufferTexture1DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level)) \
X(void, glFramebufferTexture2DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level)) \
X(void, glFramebufferTexture3DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset), (target, attachment, textarget, texture, level, zoffset)) \
X(void, glFramebufferRenderbufferEXT, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer), (target, attachment, renderbuffertarget, renderbuffer)) \
X(void, glGetFramebufferAttachmentParameterivEXT, (GLenum target, GLenum attachment, GLenum pname, GLint * params), (target, attachment, pname, params)) \
X(void, glGenerateMipmapEXT, (GLenum target), (target)) \
X(void, glEGLImageTargetTexture2DOES, (GLenum target, GLeglImageOES image), (target, image)) \
X(void, glEGLImageTargetRenderbufferStorageOES, (GLenum target, GLeglImageOES image), (target, image)) \
#endif // GLES_EXTENSIONS_FUNCTIONS_H

View file

@ -0,0 +1,50 @@
// Copyright 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "OpenGLESDispatch/gles_common_functions.h"
#include "OpenGLESDispatch/gles_extensions_functions.h"
#include "OpenGLESDispatch/gles1_only_functions.h"
#include "OpenGLESDispatch/gles1_extensions_functions.h"
#include "OpenGLESDispatch/gles2_only_functions.h"
#include "OpenGLESDispatch/gles2_extensions_functions.h"
#include "OpenGLESDispatch/gles3_only_functions.h"
// As a special case, LIST_GLES3_ONLY_FUNCTIONS below uses the Y parameter
// instead of the X one, meaning that the corresponding functions are
// optional extensions. This is only because currently, the only GLESv3
// API we support is glGetStringi(), which is not always provided by
// host desktop GL drivers (though most do).
#define LIST_GLES_FUNCTIONS(X,Y) \
LIST_GLES_COMMON_FUNCTIONS(X) \
LIST_GLES_EXTENSIONS_FUNCTIONS(Y) \
LIST_GLES1_ONLY_FUNCTIONS(X) \
LIST_GLES1_EXTENSIONS_FUNCTIONS(Y) \
LIST_GLES2_ONLY_FUNCTIONS(X) \
LIST_GLES2_EXTENSIONS_FUNCTIONS(Y) \
LIST_GLES3_ONLY_FUNCTIONS(Y) \
#define LIST_GLES1_FUNCTIONS(X, Y) \
LIST_GLES_COMMON_FUNCTIONS(X) \
LIST_GLES_EXTENSIONS_FUNCTIONS(Y) \
LIST_GLES1_ONLY_FUNCTIONS(X) \
LIST_GLES1_EXTENSIONS_FUNCTIONS(Y) \
#define LIST_GLES2_FUNCTIONS(X, Y) \
LIST_GLES_COMMON_FUNCTIONS(X) \
LIST_GLES_EXTENSIONS_FUNCTIONS(Y) \
LIST_GLES2_ONLY_FUNCTIONS(X) \
LIST_GLES2_EXTENSIONS_FUNCTIONS(Y) \

View file

@ -0,0 +1,56 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "OpenglRender/render_api_functions.h"
#include <KHR/khrplatform.h>
/* This header and its declarations must be usable from C code.
*
* If RENDER_API_NO_PROTOTYPES is #defined before including this header, only
* the interface function pointer types will be declared, not the prototypes.
* This allows the client to use those names for its function pointer variables.
*
* All interfaces which can fail return an int, with zero indicating failure
* and anything else indicating success.
*/
#ifdef __cplusplus
extern "C" {
#endif
// Use KHRONOS_APICALL to control visibility, but do not use KHRONOS_APIENTRY
// because we don't need the functions to be __stdcall on Win32.
#define RENDER_APICALL KHRONOS_APICALL
#define RENDER_APIENTRY
#define RENDER_API_DECLARE(return_type, func_name, signature, callargs) \
typedef return_type (RENDER_APIENTRY *func_name ## Fn) signature; \
RENDER_APICALL return_type RENDER_APIENTRY func_name signature;
typedef void (*emugl_logger_func_t)(const char* fmt, ...);
typedef struct {
emugl_logger_func_t coarse;
emugl_logger_func_t fine;
} emugl_logger_struct;
LIST_RENDER_API_FUNCTIONS(RENDER_API_DECLARE)
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,37 @@
// Auto-generated with: android/scripts/gen-entries.py --mode=funcargs distrib/android-emugl/host/libs/libOpenglRender/render_api.entries --output=distrib/android-emugl/host/include/OpenglRender/render_api_functions.h
// DO NOT EDIT THIS FILE
#ifndef RENDER_API_FUNCTIONS_H
#define RENDER_API_FUNCTIONS_H
#include "OpenglRender/render_api_platform_types.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
/* list of constants to be passed to setStreamMode */
#define RENDER_API_STREAM_MODE_DEFAULT 0
#define RENDER_API_STREAM_MODE_TCP 1
#define RENDER_API_STREAM_MODE_UNIX 2
#define RENDER_API_STREAM_MODE_PIPE 3
typedef void (*OnPostFn)(void* context, int width, int height, int ydir,
int format, int type, unsigned char* pixels);
typedef void (*emugl_crash_func_t)(const char* format, ...);
#define LIST_RENDER_API_FUNCTIONS(X) \
X(int, initLibrary, (), ()) \
X(int, setStreamMode, (int mode), (mode)) \
X(int, initOpenGLRenderer, (int width, int height, bool useSubWindow, char* addr, size_t addrLen, emugl_logger_struct logfuncs, emugl_crash_func_t crashfunc), (width, height, useSubWindow, addr, addrLen, logfuncs, crashfunc)) \
X(void, getHardwareStrings, (const char** vendor, const char** renderer, const char** version), (vendor, renderer, version)) \
X(void, setPostCallback, (OnPostFn onPost, void* onPostContext), (onPost, onPostContext)) \
X(bool, showOpenGLSubwindow, (FBNativeWindowType window, int wx, int wy, int ww, int wh, int fbw, int fbh, float dpr, float zRot), (window, wx, wy, ww, wh, fbw, fbh, dpr, zRot)) \
X(bool, destroyOpenGLSubwindow, (), ()) \
X(void, setOpenGLDisplayRotation, (float zRot), (zRot)) \
X(void, setOpenGLDisplayTranslation, (float px, float py), (px, py)) \
X(void, repaintOpenGLDisplay, (), ()) \
X(int, stopOpenGLRenderer, (), ()) \
#endif // RENDER_API_FUNCTIONS_H

View file

@ -0,0 +1,39 @@
/*
* Copyright 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
// Define FBNativeWindowType which corresponds to the type of native
// host UI window handles.
#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
#include <windows.h>
typedef HWND FBNativeWindowType;
#elif defined(__linux__)
// Really a Window handle, but we don't want to include the X11 headers here.
#include <stdint.h>
typedef uint32_t FBNativeWindowType;
#elif defined(__APPLE__)
typedef void* FBNativeWindowType;
#else
#warning "Unsupported platform"
#endif

View file

@ -0,0 +1,103 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __IO_STREAM_H__
#define __IO_STREAM_H__
#include <stdlib.h>
#include <stdio.h>
#include "ErrorLog.h"
class IOStream {
public:
IOStream(size_t bufSize) {
m_buf = NULL;
m_bufsize = bufSize;
m_free = 0;
}
virtual void *allocBuffer(size_t minSize) = 0;
virtual int commitBuffer(size_t size) = 0;
virtual const unsigned char *readFully( void *buf, size_t len) = 0;
virtual const unsigned char *read( void *buf, size_t *inout_len) = 0;
virtual int writeFully(const void* buf, size_t len) = 0;
virtual void forceStop() = 0;
virtual ~IOStream() {
// NOTE: m_buf is 'owned' by the child class thus we expect it to be released by it
}
unsigned char *alloc(size_t len) {
if (m_buf && len > m_free) {
if (flush() < 0) {
ERR("Failed to flush in alloc\n");
return NULL; // we failed to flush so something is wrong
}
}
if (!m_buf || len > m_bufsize) {
int allocLen = m_bufsize < len ? len : m_bufsize;
m_buf = (unsigned char *)allocBuffer(allocLen);
if (!m_buf) {
ERR("Alloc (%u bytes) failed\n", allocLen);
return NULL;
}
m_bufsize = m_free = allocLen;
}
unsigned char *ptr;
ptr = m_buf + (m_bufsize - m_free);
m_free -= len;
return ptr;
}
int flush() {
if (!m_buf || m_free == m_bufsize) return 0;
int stat = commitBuffer(m_bufsize - m_free);
m_buf = NULL;
m_free = 0;
return stat;
}
const unsigned char *readback(void *buf, size_t len) {
flush();
return readFully(buf, len);
}
private:
unsigned char *m_buf;
size_t m_bufsize;
size_t m_free;
};
//
// When a client opens a connection to the renderer, it should
// send unsigned int value indicating the "clientFlags".
// The following are the bitmask of the clientFlags.
// currently only one bit is used which flags the server
// it should exit.
//
#define IOSTREAM_CLIENT_EXIT_SERVER 1
#endif

View file

@ -0,0 +1,6 @@
add_subdirectory(mir_support)
add_subdirectory(GLESv1_dec)
add_subdirectory(GLESv2_dec)
add_subdirectory(libOpenGLESDispatch)
add_subdirectory(libOpenglRender)
add_subdirectory(renderControl_dec)

View file

@ -0,0 +1,16 @@
LOCAL_PATH := $(call my-dir)
### host library #########################################
$(call emugl-begin-host-static-library,libGLESv1_dec)
$(call emugl-import, libOpenglCodecCommon)
$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
$(call emugl-gen-decoder,$(LOCAL_PATH),gles1)
LOCAL_SRC_FILES := GLESv1Decoder.cpp
$(call emugl-export,CFLAGS,$(EMUGL_USER_CFLAGS))
$(call emugl-export,LDLIBS,$(CXX_STD_LIB))
$(call emugl-end-module)

View file

@ -0,0 +1,18 @@
set(GENERATED_SOURCES
gles1_dec.cpp
gles1_opcodes.h
gles1_server_context.cpp)
add_custom_command(
OUTPUT ${GENERATED_SOURCES}
POST_BUILD
COMMAND ${CMAKE_BINARY_DIR}/external/android-emugl/host/tools/emugen/emugen
-D ${CMAKE_CURRENT_BINARY_DIR} gles1
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS emugen)
set(SOURCES
GLESv1Decoder.cpp)
add_library(GLESv1_dec ${SOURCES} ${GENERATED_SOURCES})
target_link_libraries(GLESv1_dec OpenglCodecCommon)

View file

@ -0,0 +1,229 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "GLESv1Decoder.h"
#include <EGL/egl.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static inline void* SafePointerFromUInt(GLuint value) {
return (void*)(uintptr_t)value;
}
GLESv1Decoder::GLESv1Decoder()
{
m_contextData = NULL;
m_glesDso = NULL;
}
GLESv1Decoder::~GLESv1Decoder()
{
if (m_glesDso != NULL) {
delete m_glesDso;
}
}
int GLESv1Decoder::initGL(get_proc_func_t getProcFunc, void *getProcFuncData)
{
this->initDispatchByName(getProcFunc, getProcFuncData);
glGetCompressedTextureFormats = s_glGetCompressedTextureFormats;
glVertexPointerOffset = s_glVertexPointerOffset;
glColorPointerOffset = s_glColorPointerOffset;
glNormalPointerOffset = s_glNormalPointerOffset;
glTexCoordPointerOffset = s_glTexCoordPointerOffset;
glPointSizePointerOffset = s_glPointSizePointerOffset;
glWeightPointerOffset = s_glWeightPointerOffset;
glMatrixIndexPointerOffset = s_glMatrixIndexPointerOffset;
glVertexPointerData = s_glVertexPointerData;
glColorPointerData = s_glColorPointerData;
glNormalPointerData = s_glNormalPointerData;
glTexCoordPointerData = s_glTexCoordPointerData;
glPointSizePointerData = s_glPointSizePointerData;
glWeightPointerData = s_glWeightPointerData;
glMatrixIndexPointerData = s_glMatrixIndexPointerData;
glDrawElementsOffset = s_glDrawElementsOffset;
glDrawElementsData = s_glDrawElementsData;
glFinishRoundTrip = s_glFinishRoundTrip;
return 0;
}
int GLESv1Decoder::s_glFinishRoundTrip(void *self)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
ctx->glFinish();
return 0;
}
void GLESv1Decoder::s_glVertexPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
ctx->glVertexPointer(size, type, stride, SafePointerFromUInt(offset));
}
void GLESv1Decoder::s_glColorPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
ctx->glColorPointer(size, type, stride, SafePointerFromUInt(offset));
}
void GLESv1Decoder::s_glTexCoordPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
ctx->glTexCoordPointer(size, type, stride, SafePointerFromUInt(offset));
}
void GLESv1Decoder::s_glNormalPointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
ctx->glNormalPointer(type, stride, SafePointerFromUInt(offset));
}
void GLESv1Decoder::s_glPointSizePointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
ctx->glPointSizePointerOES(type, stride, SafePointerFromUInt(offset));
}
void GLESv1Decoder::s_glWeightPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
ctx->glWeightPointerOES(size, type, stride, SafePointerFromUInt(offset));
}
void GLESv1Decoder::s_glMatrixIndexPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
ctx->glMatrixIndexPointerOES(size, type, stride, SafePointerFromUInt(offset));
}
#define STORE_POINTER_DATA_OR_ABORT(location) \
if (ctx->m_contextData != NULL) { \
ctx->m_contextData->storePointerData((location), data, datalen); \
} else { \
return; \
}
void GLESv1Decoder::s_glVertexPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::VERTEX_LOCATION);
ctx->glVertexPointer(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::VERTEX_LOCATION));
}
void GLESv1Decoder::s_glColorPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::COLOR_LOCATION);
ctx->glColorPointer(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::COLOR_LOCATION));
}
void GLESv1Decoder::s_glTexCoordPointerData(void *self, GLint unit, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
STORE_POINTER_DATA_OR_ABORT((GLDecoderContextData::PointerDataLocation)
(GLDecoderContextData::TEXCOORD0_LOCATION + unit));
ctx->glTexCoordPointer(size, type, 0,
ctx->m_contextData->pointerData((GLDecoderContextData::PointerDataLocation)
(GLDecoderContextData::TEXCOORD0_LOCATION + unit)));
}
void GLESv1Decoder::s_glNormalPointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::NORMAL_LOCATION);
ctx->glNormalPointer(type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::NORMAL_LOCATION));
}
void GLESv1Decoder::s_glPointSizePointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::POINTSIZE_LOCATION);
ctx->glPointSizePointerOES(type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::POINTSIZE_LOCATION));
}
void GLESv1Decoder::s_glWeightPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::WEIGHT_LOCATION);
ctx->glWeightPointerOES(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::WEIGHT_LOCATION));
}
void GLESv1Decoder::s_glMatrixIndexPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::MATRIXINDEX_LOCATION);
ctx->glMatrixIndexPointerOES(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::MATRIXINDEX_LOCATION));
}
void GLESv1Decoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
ctx->glDrawElements(mode, count, type, SafePointerFromUInt(offset));
}
void GLESv1Decoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)self;
ctx->glDrawElements(mode, count, type, data);
}
void GLESv1Decoder::s_glGetCompressedTextureFormats(void *self, GLint count, GLint *data)
{
GLESv1Decoder *ctx = (GLESv1Decoder *) self;
ctx->glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, data);
}
void *GLESv1Decoder::s_getProc(const char *name, void *userData)
{
GLESv1Decoder *ctx = (GLESv1Decoder *)userData;
if (ctx == NULL || ctx->m_glesDso == NULL) {
return NULL;
}
void *func = NULL;
#ifdef USE_EGL_GETPROCADDRESS
func = (void *) eglGetProcAddress(name);
#endif
if (func == NULL) {
func = (void *)(ctx->m_glesDso->findSymbol(name));
}
return func;
}

View file

@ -0,0 +1,68 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _GL_DECODER_H_
#define _GL_DECODER_H_
#include "gles1_dec.h"
#include "GLDecoderContextData.h"
#include "emugl/common/shared_library.h"
class GLESv1Decoder : public gles1_decoder_context_t
{
public:
typedef void *(*get_proc_func_t)(const char *name, void *userData);
GLESv1Decoder();
~GLESv1Decoder();
int initGL(get_proc_func_t getProcFunc, void *getProcFuncData);
void setContextData(GLDecoderContextData *contextData) { m_contextData = contextData; }
private:
static void gles1_APIENTRY s_glGetCompressedTextureFormats(void * self, GLint cont, GLint *data);
static void gles1_APIENTRY s_glVertexPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen);
static void gles1_APIENTRY s_glVertexPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset);
static void gles1_APIENTRY s_glColorPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen);
static void gles1_APIENTRY s_glColorPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset);
static void gles1_APIENTRY s_glTexCoordPointerData(void *self, GLint unit, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen);
static void gles1_APIENTRY s_glTexCoordPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset);
static void gles1_APIENTRY s_glNormalPointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen);
static void gles1_APIENTRY s_glNormalPointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset);
static void gles1_APIENTRY s_glPointSizePointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen);
static void gles1_APIENTRY s_glPointSizePointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset);
static void gles1_APIENTRY s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset);
static void gles1_APIENTRY s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen);
static void gles1_APIENTRY s_glWeightPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen);
static void gles1_APIENTRY s_glWeightPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset);
static void gles1_APIENTRY s_glMatrixIndexPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen);
static void gles1_APIENTRY s_glMatrixIndexPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset);
static int gles1_APIENTRY s_glFinishRoundTrip(void *self);
static void * s_getProc(const char *name, void *userData);
GLDecoderContextData *m_contextData;
emugl::SharedLibrary* m_glesDso;
};
#endif

View file

@ -0,0 +1,15 @@
GL_ENTRY(void, glVertexPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glColorPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glNormalPointerOffset, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glPointSizePointerOffset, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glTexCoordPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glVertexPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glColorPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glNormalPointerData, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glTexCoordPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glPointSizePointerData, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset);
GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen);

View file

@ -0,0 +1,694 @@
GLOBAL
base_opcode 1024
encoder_headers "glUtils.h" "GLEncoderUtils.h"
#void glClipPlanef(GLenum plane, GLfloat *equation)
glClipPlanef
dir equation in
len equation (4 * sizeof(float))
#void glFogfv(GLenum pname, GLfloat *params)
glFogfv
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glGetFloatv(GLenum pname, GLfloat *params)
glGetFloatv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glGetLightfv(GLenum light, GLenum pname, GLfloat *params)
glGetLightfv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
glGetMaterialfv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params)
glGetTexEnvfv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
glGetTexParameterfv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glLightModelfv(GLenum pname, GLfloat *params)
glLightModelfv
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glLightfv(GLenum light, GLenum pname, GLfloat *params)
glLightfv
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glLoadMatrixf(GLfloat *m)
glLoadMatrixf
len m (16 * sizeof(GLfloat))
#void glMaterialfv(GLenum face, GLenum pname, GLfloat *params)
glMaterialfv
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glMultMatrixf(GLfloat *m)
glMultMatrixf
len m (16 * sizeof(GLfloat))
#void glPointParameterfv(GLenum pname, GLfloat *params)
glPointParameterfv
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glTexEnvfv(GLenum target, GLenum pname, GLfloat *params)
glTexEnvfv
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
glTexParameterfv
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glBufferData(GLenum target, GLsizeiptr size, GLvoid *data, GLenum usage)
glBufferData
len data size
var_flag data nullAllowed
#void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)
glBufferSubData
dir data in
len data size
var_flag data nullAllowed
#void glClipPlanex(GLenum plane, GLfixed *eqn)
glClipPlanex
dir eqn in
len eqn (4 * sizeof(GLfixed))
#void glColorPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
#we treat the pointer as offset to a VBO
glColorPointer
len pointer (sizeof(unsigned int))
flag unsupported
#void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid *data)
glCompressedTexImage2D
len data imageSize
var_flag data nullAllowed
#void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLvoid *data)
glCompressedTexSubImage2D
len data imageSize
var_flag data nullAllowed
#void glDeleteBuffers(GLsizei n, GLuint *buffers)
glDeleteBuffers
len buffers (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glDeleteTextures(GLsizei n, GLuint *textures)
glDeleteTextures
len textures (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#this function is marked as unsupported - it shouldn't be called directly
#instead it translated into - glDrawDirectElements and glDrawIndirectElements
#void glDrawElements(GLenum mode, GLsizei count, GLenum type, GLvoid *indices)
glDrawElements
flag unsupported
#void glFogxv(GLenum pname, GLfixed *params)
glFogxv
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetBooleanv(GLenum pname, GLboolean *params)
glGetBooleanv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLboolean))
#void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
glGetBufferParameteriv
len params (sizeof(GLint))
dir params out
#void glGenBuffers(GLsizei n, GLuint *buffers)
glGenBuffers
len buffers (n * sizeof(GLuint))
dir buffers out
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGenTextures(GLsizei n, GLuint *textures)
glGenTextures
len textures (n * sizeof(GLuint))
dir textures out
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGetFixedv(GLenum pname, GLfixed *params)
glGetFixedv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetIntegerv(GLenum pname, GLint *params)
glGetIntegerv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glGetLightxv(GLenum light, GLenum pname, GLfixed *params)
glGetLightxv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetMaterialxv(GLenum face, GLenum pname, GLfixed *params)
glGetMaterialxv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetPointerv(GLenum pname, void **params)
glGetPointerv
flag unsupported
#GLubyte* glGetString(GLenum name)
glGetString
flag unsupported
#void glGetTexEnviv(GLenum env, GLenum pname, GLint *params)
glGetTexEnviv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params)
glGetTexEnvxv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params)
glGetTexParameteriv
dir params out
len params (sizeof(GLint))
#void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params)
glGetTexParameterxv
dir params out
len params (sizeof(GLfixed))
#void glLightModelxv(GLenum pname, GLfixed *params)
glLightModelxv
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glLightxv(GLenum light, GLenum pname, GLfixed *params)
glLightxv
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glLoadMatrixx(GLfixed *m)
glLoadMatrixx
len m (16 * sizeof(GLfixed))
#void glMaterialxv(GLenum face, GLenum pname, GLfixed *params)
glMaterialxv
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glMultMatrixx(GLfixed *m)
glMultMatrixx
len m (16 * sizeof(GLfixed))
#void glNormalPointer(GLenum type, GLsizei stride, GLvoid *pointer)
#we treat the pointer as an offset to a VBO
glNormalPointer
len pointer (sizeof(unsigned int))
flag unsupported
#void glPointParameterxv(GLenum pname, GLfixed *params)
glPointParameterxv
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
glReadPixels
dir pixels out
len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 1)
#void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
glTexCoordPointer
len pointer (sizeof(unsigned int))
flag unsupported
#void glTexEnviv(GLenum target, GLenum pname, GLint *params)
glTexEnviv
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glTexEnvxv(GLenum target, GLenum pname, GLfixed *params)
glTexEnvxv
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels)
glTexImage2D
dir pixels in
len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glTexParameteriv(GLenum target, GLenum pname, GLint *params)
glTexParameteriv
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glTexParameterxv(GLenum target, GLenum pname, GLfixed *params)
glTexParameterxv
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
glTexSubImage2D
len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glVertexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
# we treat the pointer as an offset to a VBO
glVertexPointer
flag unsupported
#void glPointSizePointerOES(GLenum type, GLsizei stride, GLvoid *pointer)
glPointSizePointerOES
len pointer (sizeof(unsigned int))
flag unsupported
#void glGetClipPlanef(GLenum pname, GLfloat * eqn)
glGetClipPlanef
dir eqn out
len eqn (4 * sizeof(GLfloat))
#void glVertexPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
glVertexPointerData
len data datalen
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
flag custom_decoder
flag not_api
#void glColorPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
glColorPointerData
len data datalen
flag custom_decoder
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
flag not_api
#void glNormalPointerData(GLenum type, GLsizei stride, void *data, GLuint datalen)
glNormalPointerData
len data datalen
flag custom_decoder
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 3, type, stride, datalen)
flag not_api
#void glPointSizePointerData(GLenum type, GLsizei stride, void *data, GLuint datalen)
glPointSizePointerData
len data datalen
flag custom_decoder
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 1, type, stride, datalen)
flag not_api
#void glTexCoordPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen)
glTexCoordPointerData
len data datalen
flag custom_decoder
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
flag not_api
#void glWeightPointerData(GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
glWeightPointerData
len data datalen
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char*)data, size, type, stride, datalen)
flag custom_decoder
flag not_api
#void glMatrixIndexPointerData(GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
glMatrixIndexPointerData
len data datalen
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char*)data, size, type, stride, datalen)
flag custom_decoder
flag not_api
glVertexPointerOffset
flag custom_decoder
flag not_api
glNormalPointerOffset
flag custom_decoder
flag not_api
glTexCoordPointerOffset
flag custom_decoder
flag not_api
glPointSizePointerOffset
flag custom_decoder
flag not_api
glColorPointerOffset
flag custom_decoder
flag not_api
glWeightPointerOffset
flag custom_decoder
flag not_api
glMatrixIndexPointerOffset
flag custom_decoder
flag not_api
glDrawElementsData
len data datalen
flag custom_decoder
flag not_api
glDrawElementsOffset
flag custom_decoder
flag not_api
glGetCompressedTextureFormats
dir formats out
len formats (count * sizeof(GLint))
flag custom_decoder
flag not_api
glFinishRoundTrip
flag custom_decoder
flag not_api
#gles1 extensions
#void glDrawTexsvOES(GLshort *coords)
glDrawTexsvOES
len coords (5 * sizeof(GLshort))
#void glDrawTexivOES(GLint *coords)
glDrawTexivOES
len coords (5 * sizeof(GLint))
#void glDrawTexxvOES(GLfixed *coords)
glDrawTexxvOES
len coords (5 * sizeof(GLfixed))
#void glDrawTexfvOES(GLfloat *coords)
glDrawTexfvOES
len coords (5 * sizeof(GLfloat))
#glClipPlanexOES(GLenum plane, const GLfixed * equation)
glClipPlanexOES
dir equation in
len equation (4 * sizeof(GLfixed))
#glClipPlanexIMG(GLenum plane, const GLfixed * equation)
glClipPlanexIMG
dir equation in
len equation (4 * sizeof(GLfixed))
#void glFogxvOES(GLenum pname, GLfixed *params)
glFogxvOES
dir params in
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetClipPlanexOES(GLenum pname, GLfixed * eqn)
glGetClipPlanexOES
dir eqn out
len eqn (4 * sizeof(GLfixed))
#void glGetClipPlanex(GLenum pname, GLfixed * eqn)
glGetClipPlanex
dir eqn out
len eqn (4 * sizeof(GLfixed))
#void glGetFixedvOES(GLenum pname, GLfixed *params)
glGetFixedvOES
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetLightxvOES(GLenum light, GLenum pname, GLfixed *params)
glGetLightxvOES
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed *params)
glGetMaterialxvOES
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed *params)
glGetTexEnvxvOES
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params)
glGetTexParameterxvOES
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glLightModelxvOES(GLenum pname, GLfixed *params)
glLightModelxvOES
dir params in
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glLightxvOES(GLenum light, GLenum pname, GLfixed *params)
glLightxvOES
dir params in
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glLoadMatrixxOES(GLfixed *m)
glLoadMatrixxOES
dir m in
len m (16 * sizeof(GLfixed))
#void glMaterialxvOES(GLenum face, GLenum pname, GLfixed *params)
glMaterialxvOES
dir params in
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glMultMatrixxOES(GLfixed *m)
glMultMatrixxOES
dir m in
len m (16 * sizeof(GLfixed))
#void glPointParameterxvOES(GLenum pname, GLfixed *params)
glPointParameterxvOES
dir params in
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glTexEnvxvOES(GLenum target, GLenum pname, GLfixed *params)
glTexEnvxvOES
dir params in
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params)
glTexParameterxvOES
dir params in
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glDeleteRenderbuffersOES(GLsizei n, GLuint *renderbuffers)
glDeleteRenderbuffersOES
dir renderbuffers in
len renderbuffers (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGenRenderbuffersOES(GLsizei n, GLuint *renderbuffers)
glGenRenderbuffersOES
dir renderbuffers out
len renderbuffers (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint *params)
glGetRenderbufferParameterivOES
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glDeleteFramebuffersOES(GLsizei n, GLuint *framebuffers)
glDeleteFramebuffersOES
dir framebuffers in
len framebuffers (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGenFramebuffersOES(GLsizei n, GLuint *framebuffers)
glGenFramebuffersOES
dir framebuffers out
len framebuffers (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint *params)
glGetFramebufferAttachmentParameterivOES
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void* glMapBufferOES(GLenum target, GLenum access)
glMapBufferOES
flag unsupported
#void glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid ** params)
glGetBufferPointervOES
flag unsupported
#void glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
glMatrixIndexPointerOES
len pointer (sizeof(unsigned int))
flag unsupported
#void glWeightPointerOES(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
glWeightPointerOES
len pointer (sizeof(unsigned int))
flag unsupported
#glQueryMatrixxOES(GLfixed * mantissa, GLint * exponent)
glQueryMatrixxOES
dir mantissa out
len mantissa (16 * sizeof(GLfixed))
dir exponent out
len exponent (16 * sizeof(GLfixed))
#void glClipPlanefOES(GLenum plane, GLfloat *equation)
glClipPlanefOES
dir equation in
len equation (4 * sizeof(GLfloat))
#void glClipPlanefIMG(GLenum plane, GLfloat *equation)
glClipPlanefIMG
dir equation in
len equation (4 * sizeof(GLfloat))
#void glGetClipPlanefOES(GLenum pname, GLfloat * eqn)
glGetClipPlanefOES
dir eqn out
len eqn (4 * sizeof(GLfloat))
#void glTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params)
glTexGenfvOES
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glTexGenivOES(GLenum coord, GLenum pname, GLint *params)
glTexGenivOES
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params)
glTexGenxvOES
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params)
glGetTexGenfvOES
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glGetTexGenivOES(GLenum coord, GLenum pname, GLint *params)
glGetTexGenivOES
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params)
glGetTexGenxvOES
len params (glUtilsParamSize(pname) * sizeof(GLfixed))
#void glDeleteVertexArraysOES(GLsizei n, const GLuint *arrays)
glDeleteVertexArraysOES
dir arrays in
len arrays (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGenVertexArraysOES(GLsizei n, GLuint *arrays)
glGenVertexArraysOES
dir arrays out
len arrays (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments)
glDiscardFramebufferEXT
dir attachments in
len attachments (numAttachments * sizeof(const GLenum))
#void glMultiDrawArraysEXT(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount)
glMultiDrawArraysEXT
flag unsupported
#void glMultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount)
glMultiDrawElementsEXT
flag unsupported
#void glMultiDrawArraysSUN(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
glMultiDrawArraysSUN
flag unsupported
#void glMultiDrawElementsSUN(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount)
glMultiDrawElementsSUN
flag unsupported
#void glDeleteFencesNV(GLsizei n, const GLuint *fences)
glDeleteFencesNV
dir fences in
len fences (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGenFencesNV(GLsizei n, GLuint *fences)
glGenFencesNV
dir fences in
len fences (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
glGetFenceivNV
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls)
glGetDriverControlsQCOM
dir num out
len num (1 * sizeof(GLint))
dir driverControls out
len driverControls (size * sizeof(GLuint))
#void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString)
glGetDriverControlStringQCOM
dir length out
len length (1 * sizeof(GLsizei))
dir driverControlString out
len driverControlString (1 * sizeof(GLchar))
#void glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures)
glExtGetTexturesQCOM
dir textures out
len textures (maxTextures * sizeof(GLuint))
dir numTextures out
len numTextures (1 * sizeof(GLint))
#void glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers)
glExtGetBuffersQCOM
dir buffers out
len buffers (maxBuffers * sizeof(GLuint))
dir numBuffers out
len numBuffers (1 * sizeof(GLint))
#void glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers)
glExtGetRenderbuffersQCOM
dir renderbuffers out
len renderbuffers (maxRenderbuffers * sizeof(GLuint))
dir numRenderbuffers out
len numRenderbuffers (1 * sizeof(GLint))
#void glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers)
glExtGetFramebuffersQCOM
dir framebuffers out
len framebuffers (maxFramebuffers * sizeof(GLuint))
dir numFramebuffers out
len numFramebuffers (1 * sizeof(GLint))
#void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params)
glExtGetTexLevelParameterivQCOM
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels)
glExtGetTexSubImageQCOM
dir texels out
len texels (depth * glesv1_enc::pixelDataSize(self, width, height, format, type, 0))
#void glExtGetBufferPointervQCOM(GLenum target, GLvoid **params)
glExtGetBufferPointervQCOM
flag unsupported
#void glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders)
glExtGetShadersQCOM
dir shaders out
len shaders (maxShaders * sizeof(GLuint))
dir numShaders out
len numShaders (1 * sizeof(GLint))
#void glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms)
glExtGetProgramsQCOM
dir programs out
len programs (maxPrograms * sizeof(GLuint))
dir numPrograms out
len numPrograms (1 * sizeof(GLint))
#void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length)
glExtGetProgramBinarySourceQCOM
flag unsupported

View file

@ -0,0 +1,298 @@
GL_ENTRY(void, glAlphaFunc, GLenum func, GLclampf ref)
GL_ENTRY(void, glClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
GL_ENTRY(void, glClearDepthf, GLclampf depth)
GL_ENTRY(void, glClipPlanef, GLenum plane, const GLfloat *equation)
GL_ENTRY(void, glColor4f, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
GL_ENTRY(void, glDepthRangef, GLclampf zNear, GLclampf zFar)
GL_ENTRY(void, glFogf, GLenum pname, GLfloat param)
GL_ENTRY(void, glFogfv, GLenum pname, const GLfloat *params)
GL_ENTRY(void, glFrustumf, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
GL_ENTRY(void, glGetClipPlanef, GLenum pname, GLfloat* eqn)
GL_ENTRY(void, glGetFloatv, GLenum pname, GLfloat *params)
GL_ENTRY(void, glGetLightfv, GLenum light, GLenum pname, GLfloat *params)
GL_ENTRY(void, glGetMaterialfv, GLenum face, GLenum pname, GLfloat *params)
GL_ENTRY(void, glGetTexEnvfv, GLenum env, GLenum pname, GLfloat *params)
GL_ENTRY(void, glGetTexParameterfv, GLenum target, GLenum pname, GLfloat *params)
GL_ENTRY(void, glLightModelf, GLenum pname, GLfloat param)
GL_ENTRY(void, glLightModelfv, GLenum pname, const GLfloat *params)
GL_ENTRY(void, glLightf, GLenum light, GLenum pname, GLfloat param)
GL_ENTRY(void, glLightfv, GLenum light, GLenum pname, const GLfloat *params)
GL_ENTRY(void, glLineWidth, GLfloat width)
GL_ENTRY(void, glLoadMatrixf, const GLfloat *m)
GL_ENTRY(void, glMaterialf, GLenum face, GLenum pname, GLfloat param)
GL_ENTRY(void, glMaterialfv, GLenum face, GLenum pname, const GLfloat *params)
GL_ENTRY(void, glMultMatrixf, const GLfloat *m)
GL_ENTRY(void, glMultiTexCoord4f, GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
GL_ENTRY(void, glNormal3f, GLfloat nx, GLfloat ny, GLfloat nz)
GL_ENTRY(void, glOrthof, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
GL_ENTRY(void, glPointParameterf, GLenum pname, GLfloat param)
GL_ENTRY(void, glPointParameterfv, GLenum pname, const GLfloat *params)
GL_ENTRY(void, glPointSize, GLfloat size)
GL_ENTRY(void, glPolygonOffset, GLfloat factor, GLfloat units)
GL_ENTRY(void, glRotatef, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
GL_ENTRY(void, glScalef, GLfloat x, GLfloat y, GLfloat z)
GL_ENTRY(void, glTexEnvf, GLenum target, GLenum pname, GLfloat param)
GL_ENTRY(void, glTexEnvfv, GLenum target, GLenum pname, const GLfloat *params)
GL_ENTRY(void, glTexParameterf, GLenum target, GLenum pname, GLfloat param)
GL_ENTRY(void, glTexParameterfv, GLenum target, GLenum pname, const GLfloat *params)
GL_ENTRY(void, glTranslatef, GLfloat x, GLfloat y, GLfloat z)
GL_ENTRY(void, glActiveTexture, GLenum texture)
GL_ENTRY(void, glAlphaFuncx, GLenum func, GLclampx ref)
GL_ENTRY(void, glBindBuffer, GLenum target, GLuint buffer)
GL_ENTRY(void, glBindTexture, GLenum target, GLuint texture)
GL_ENTRY(void, glBlendFunc, GLenum sfactor, GLenum dfactor)
GL_ENTRY(void, glBufferData, GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
GL_ENTRY(void, glBufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)
GL_ENTRY(void, glClear, GLbitfield mask)
GL_ENTRY(void, glClearColorx, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
GL_ENTRY(void, glClearDepthx, GLclampx depth)
GL_ENTRY(void, glClearStencil, GLint s)
GL_ENTRY(void, glClientActiveTexture, GLenum texture)
GL_ENTRY(void, glColor4ub, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
GL_ENTRY(void, glColor4x, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
GL_ENTRY(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
GL_ENTRY(void, glColorPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
GL_ENTRY(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data)
GL_ENTRY(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data)
GL_ENTRY(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
GL_ENTRY(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
GL_ENTRY(void, glCullFace, GLenum mode)
GL_ENTRY(void, glDeleteBuffers, GLsizei n, const GLuint *buffers)
GL_ENTRY(void, glDeleteTextures, GLsizei n, const GLuint *textures)
GL_ENTRY(void, glDepthFunc, GLenum func)
GL_ENTRY(void, glDepthMask, GLboolean flag)
GL_ENTRY(void, glDepthRangex, GLclampx zNear, GLclampx zFar)
GL_ENTRY(void, glDisable, GLenum cap)
GL_ENTRY(void, glDisableClientState, GLenum array)
GL_ENTRY(void, glDrawArrays, GLenum mode, GLint first, GLsizei count)
GL_ENTRY(void, glDrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
GL_ENTRY(void, glEnable, GLenum cap)
GL_ENTRY(void, glEnableClientState, GLenum array)
GL_ENTRY(void, glFinish, void)
GL_ENTRY(void, glFlush, void)
GL_ENTRY(void, glFogx, GLenum pname, GLfixed param)
GL_ENTRY(void, glFogxv, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glFrontFace, GLenum mode)
GL_ENTRY(void, glFrustumx, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean *params)
GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint *params)
GL_ENTRY(void, glClipPlanex, GLenum pname, const GLfixed * eqn)
GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint *buffers)
GL_ENTRY(void, glGenTextures, GLsizei n, GLuint *textures)
GL_ENTRY(GLenum, glGetError, void)
GL_ENTRY(void, glGetFixedv, GLenum pname, GLfixed *params)
GL_ENTRY(void, glGetIntegerv, GLenum pname, GLint *params)
GL_ENTRY(void, glGetLightxv, GLenum light, GLenum pname, GLfixed *params)
GL_ENTRY(void, glGetMaterialxv, GLenum face, GLenum pname, GLfixed *params)
GL_ENTRY(void, glGetPointerv, GLenum pname, GLvoid **params)
GL_ENTRY(const GLubyte *, glGetString, GLenum name)
GL_ENTRY(void, glGetTexEnviv, GLenum env, GLenum pname, GLint *params)
GL_ENTRY(void, glGetTexEnvxv, GLenum env, GLenum pname, GLfixed *params)
GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint *params)
GL_ENTRY(void, glGetTexParameterxv, GLenum target, GLenum pname, GLfixed *params)
GL_ENTRY(void, glHint, GLenum target, GLenum mode)
GL_ENTRY(GLboolean, glIsBuffer, GLuint buffer)
GL_ENTRY(GLboolean, glIsEnabled, GLenum cap)
GL_ENTRY(GLboolean, glIsTexture, GLuint texture)
GL_ENTRY(void, glLightModelx, GLenum pname, GLfixed param)
GL_ENTRY(void, glLightModelxv, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glLightx, GLenum light, GLenum pname, GLfixed param)
GL_ENTRY(void, glLightxv, GLenum light, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glLineWidthx, GLfixed width)
GL_ENTRY(void, glLoadIdentity, void)
GL_ENTRY(void, glLoadMatrixx, const GLfixed *m)
GL_ENTRY(void, glLogicOp, GLenum opcode)
GL_ENTRY(void, glMaterialx, GLenum face, GLenum pname, GLfixed param)
GL_ENTRY(void, glMaterialxv, GLenum face, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glMatrixMode, GLenum mode)
GL_ENTRY(void, glMultMatrixx, const GLfixed *m)
GL_ENTRY(void, glMultiTexCoord4x, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
GL_ENTRY(void, glNormal3x, GLfixed nx, GLfixed ny, GLfixed nz)
GL_ENTRY(void, glNormalPointer, GLenum type, GLsizei stride, const GLvoid *pointer)
GL_ENTRY(void, glOrthox, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
GL_ENTRY(void, glPixelStorei, GLenum pname, GLint param)
GL_ENTRY(void, glPointParameterx, GLenum pname, GLfixed param)
GL_ENTRY(void, glPointParameterxv, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glPointSizex, GLfixed size)
GL_ENTRY(void, glPolygonOffsetx, GLfixed factor, GLfixed units)
GL_ENTRY(void, glPopMatrix, void)
GL_ENTRY(void, glPushMatrix, void)
GL_ENTRY(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
GL_ENTRY(void, glRotatex, GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
GL_ENTRY(void, glSampleCoverage, GLclampf value, GLboolean invert)
GL_ENTRY(void, glSampleCoveragex, GLclampx value, GLboolean invert)
GL_ENTRY(void, glScalex, GLfixed x, GLfixed y, GLfixed z)
GL_ENTRY(void, glScissor, GLint x, GLint y, GLsizei width, GLsizei height)
GL_ENTRY(void, glShadeModel, GLenum mode)
GL_ENTRY(void, glStencilFunc, GLenum func, GLint ref, GLuint mask)
GL_ENTRY(void, glStencilMask, GLuint mask)
GL_ENTRY(void, glStencilOp, GLenum fail, GLenum zfail, GLenum zpass)
GL_ENTRY(void, glTexCoordPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
GL_ENTRY(void, glTexEnvi, GLenum target, GLenum pname, GLint param)
GL_ENTRY(void, glTexEnvx, GLenum target, GLenum pname, GLfixed param)
GL_ENTRY(void, glTexEnviv, GLenum target, GLenum pname, const GLint *params)
GL_ENTRY(void, glTexEnvxv, GLenum target, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glTexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
GL_ENTRY(void, glTexParameteri, GLenum target, GLenum pname, GLint param)
GL_ENTRY(void, glTexParameterx, GLenum target, GLenum pname, GLfixed param)
GL_ENTRY(void, glTexParameteriv, GLenum target, GLenum pname, const GLint *params)
GL_ENTRY(void, glTexParameterxv, GLenum target, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
GL_ENTRY(void, glTranslatex, GLfixed x, GLfixed y, GLfixed z)
GL_ENTRY(void, glVertexPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
GL_ENTRY(void, glViewport, GLint x, GLint y, GLsizei width, GLsizei height)
GL_ENTRY(void, glPointSizePointerOES, GLenum type, GLsizei stride, const GLvoid *pointer)
GL_ENTRY(void, glVertexPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glColorPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glNormalPointerOffset, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glPointSizePointerOffset, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glTexCoordPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glWeightPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glMatrixIndexPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset)
GL_ENTRY(void, glVertexPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glColorPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glNormalPointerData, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glTexCoordPointerData, GLint unit, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glPointSizePointerData, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glWeightPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glMatrixIndexPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset)
GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen)
GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats);
GL_ENTRY(int, glFinishRoundTrip, void)
#opengl extensions
GL_ENTRY(void, glBlendEquationSeparateOES, GLenum modeRGB, GLenum modeAlpha)
GL_ENTRY(void, glBlendFuncSeparateOES, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
GL_ENTRY(void, glBlendEquationOES, GLenum mode)
GL_ENTRY(void, glDrawTexsOES, GLshort x, GLshort y, GLshort z, GLshort width, GLshort height)
GL_ENTRY(void, glDrawTexiOES, GLint x, GLint y, GLint z, GLint width, GLint height)
GL_ENTRY(void, glDrawTexxOES, GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height)
GL_ENTRY(void, glDrawTexsvOES, const GLshort *coords)
GL_ENTRY(void, glDrawTexivOES, const GLint *coords)
GL_ENTRY(void, glDrawTexxvOES, const GLfixed *coords)
GL_ENTRY(void, glDrawTexfOES, GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height)
GL_ENTRY(void, glDrawTexfvOES, const GLfloat *coords)
GL_ENTRY(void, glEGLImageTargetTexture2DOES, GLenum target, GLeglImageOES image)
GL_ENTRY(void, glEGLImageTargetRenderbufferStorageOES, GLenum target, GLeglImageOES image)
GL_ENTRY(void, glAlphaFuncxOES, GLenum func, GLclampx ref)
GL_ENTRY(void, glClearColorxOES, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
GL_ENTRY(void, glClearDepthxOES, GLclampx depth)
GL_ENTRY(void, glClipPlanexOES, GLenum plane, const GLfixed * equation)
GL_ENTRY(void, glClipPlanexIMG, GLenum plane, const GLfixed * equation)
GL_ENTRY(void, glColor4xOES, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
GL_ENTRY(void, glDepthRangexOES, GLclampx zNear, GLclampx zFar)
GL_ENTRY(void, glFogxOES, GLenum pname, GLfixed param)
GL_ENTRY(void, glFogxvOES, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glFrustumxOES, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
GL_ENTRY(void, glGetClipPlanexOES, GLenum pname, GLfixed* eqn)
GL_ENTRY(void, glGetClipPlanex, GLenum pname, GLfixed* eqn)
GL_ENTRY(void, glGetFixedvOES, GLenum pname, GLfixed *params)
GL_ENTRY(void, glGetLightxvOES, GLenum light, GLenum pname, GLfixed *params)
GL_ENTRY(void, glGetMaterialxvOES, GLenum face, GLenum pname, GLfixed *params)
GL_ENTRY(void, glGetTexEnvxvOES, GLenum env, GLenum pname, GLfixed *params)
GL_ENTRY(void, glGetTexParameterxvOES, GLenum target, GLenum pname, GLfixed *params)
GL_ENTRY(void, glLightModelxOES, GLenum pname, GLfixed param)
GL_ENTRY(void, glLightModelxvOES, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glLightxOES, GLenum light, GLenum pname, GLfixed param)
GL_ENTRY(void, glLightxvOES, GLenum light, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glLineWidthxOES, GLfixed width)
GL_ENTRY(void, glLoadMatrixxOES, const GLfixed *m)
GL_ENTRY(void, glMaterialxOES, GLenum face, GLenum pname, GLfixed param)
GL_ENTRY(void, glMaterialxvOES, GLenum face, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glMultMatrixxOES, const GLfixed *m)
GL_ENTRY(void, glMultiTexCoord4xOES, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
GL_ENTRY(void, glNormal3xOES, GLfixed nx, GLfixed ny, GLfixed nz)
GL_ENTRY(void, glOrthoxOES, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
GL_ENTRY(void, glPointParameterxOES, GLenum pname, GLfixed param)
GL_ENTRY(void, glPointParameterxvOES, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glPointSizexOES, GLfixed size)
GL_ENTRY(void, glPolygonOffsetxOES, GLfixed factor, GLfixed units)
GL_ENTRY(void, glRotatexOES, GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
GL_ENTRY(void, glSampleCoveragexOES, GLclampx value, GLboolean invert)
GL_ENTRY(void, glScalexOES, GLfixed x, GLfixed y, GLfixed z)
GL_ENTRY(void, glTexEnvxOES, GLenum target, GLenum pname, GLfixed param)
GL_ENTRY(void, glTexEnvxvOES, GLenum target, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glTexParameterxOES, GLenum target, GLenum pname, GLfixed param)
GL_ENTRY(void, glTexParameterxvOES, GLenum target, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glTranslatexOES, GLfixed x, GLfixed y, GLfixed z)
GL_ENTRY(GLboolean, glIsRenderbufferOES, GLuint renderbuffer)
GL_ENTRY(void, glBindRenderbufferOES, GLenum target, GLuint renderbuffer)
GL_ENTRY(void, glDeleteRenderbuffersOES, GLsizei n, const GLuint* renderbuffers)
GL_ENTRY(void, glGenRenderbuffersOES, GLsizei n, GLuint* renderbuffers)
GL_ENTRY(void, glRenderbufferStorageOES, GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
GL_ENTRY(void, glGetRenderbufferParameterivOES, GLenum target, GLenum pname, GLint* params)
GL_ENTRY(GLboolean, glIsFramebufferOES, GLuint framebuffer)
GL_ENTRY(void, glBindFramebufferOES, GLenum target, GLuint framebuffer)
GL_ENTRY(void, glDeleteFramebuffersOES, GLsizei n, const GLuint* framebuffers)
GL_ENTRY(void, glGenFramebuffersOES, GLsizei n, GLuint* framebuffers)
GL_ENTRY(GLenum, glCheckFramebufferStatusOES, GLenum target)
GL_ENTRY(void, glFramebufferRenderbufferOES, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
GL_ENTRY(void, glFramebufferTexture2DOES, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
GL_ENTRY(void, glGetFramebufferAttachmentParameterivOES, GLenum target, GLenum attachment, GLenum pname, GLint* params)
GL_ENTRY(void, glGenerateMipmapOES, GLenum target)
GL_ENTRY(void*, glMapBufferOES, GLenum target, GLenum access)
GL_ENTRY(GLboolean, glUnmapBufferOES, GLenum target)
GL_ENTRY(void, glGetBufferPointervOES, GLenum target, GLenum pname, GLvoid* *params)
GL_ENTRY(void, glCurrentPaletteMatrixOES, GLuint matrixpaletteindex)
GL_ENTRY(void, glLoadPaletteFromModelViewMatrixOES, void)
GL_ENTRY(void, glMatrixIndexPointerOES, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)
GL_ENTRY(void, glWeightPointerOES, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)
GL_ENTRY(GLbitfield, glQueryMatrixxOES, GLfixed * mantissa, GLint * exponent)
GL_ENTRY(void, glDepthRangefOES, GLclampf zNear, GLclampf zFar)
GL_ENTRY(void, glFrustumfOES, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
GL_ENTRY(void, glOrthofOES, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
GL_ENTRY(void, glClipPlanefOES, GLenum plane, const GLfloat *equation)
GL_ENTRY(void, glClipPlanefIMG, GLenum plane, const GLfloat *equation)
GL_ENTRY(void, glGetClipPlanefOES, GLenum pname, GLfloat * eqn)
GL_ENTRY(void, glClearDepthfOES, GLclampf depth)
GL_ENTRY(void, glTexGenfOES, GLenum coord, GLenum pname, GLfloat param)
GL_ENTRY(void, glTexGenfvOES, GLenum coord, GLenum pname, const GLfloat *params)
GL_ENTRY(void, glTexGeniOES, GLenum coord, GLenum pname, GLint param)
GL_ENTRY(void, glTexGenivOES, GLenum coord, GLenum pname, const GLint *params)
GL_ENTRY(void, glTexGenxOES, GLenum coord, GLenum pname, GLfixed param)
GL_ENTRY(void, glTexGenxvOES, GLenum coord, GLenum pname, const GLfixed *params)
GL_ENTRY(void, glGetTexGenfvOES, GLenum coord, GLenum pname, GLfloat *params)
GL_ENTRY(void, glGetTexGenivOES, GLenum coord, GLenum pname, GLint *params)
GL_ENTRY(void, glGetTexGenxvOES, GLenum coord, GLenum pname, GLfixed *params)
GL_ENTRY(void, glBindVertexArrayOES, GLuint array)
GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint *arrays)
GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint *arrays)
GL_ENTRY(GLboolean, glIsVertexArrayOES, GLuint array)
GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum *attachments)
GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount)
GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid*const *indices, GLsizei primcount)
GL_ENTRY(void, glMultiDrawArraysSUN, GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
GL_ENTRY(void, glMultiDrawElementsSUN, GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)
GL_ENTRY(void, glRenderbufferStorageMultisampleIMG, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
GL_ENTRY(void, glFramebufferTexture2DMultisampleIMG, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
GL_ENTRY(void, glDeleteFencesNV, GLsizei n, const GLuint *fences)
GL_ENTRY(void, glGenFencesNV, GLsizei n, GLuint *fences)
GL_ENTRY(GLboolean, glIsFenceNV, GLuint fence)
GL_ENTRY(GLboolean, glTestFenceNV, GLuint fence)
GL_ENTRY(void, glGetFenceivNV, GLuint fence, GLenum pname, GLint *params)
GL_ENTRY(void, glFinishFenceNV, GLuint fence)
GL_ENTRY(void, glSetFenceNV, GLuint fence, GLenum condition)
GL_ENTRY(void, glGetDriverControlsQCOM, GLint *num, GLsizei size, GLuint *driverControls)
GL_ENTRY(void, glGetDriverControlStringQCOM, GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString)
GL_ENTRY(void, glEnableDriverControlQCOM, GLuint driverControl)
GL_ENTRY(void, glDisableDriverControlQCOM, GLuint driverControl)
GL_ENTRY(void, glExtGetTexturesQCOM, GLuint *textures, GLint maxTextures, GLint *numTextures)
GL_ENTRY(void, glExtGetBuffersQCOM, GLuint *buffers, GLint maxBuffers, GLint *numBuffers)
GL_ENTRY(void, glExtGetRenderbuffersQCOM, GLuint * renderbuffers, GLint maxRenderbuffers, GLint * numRenderbuffers)
GL_ENTRY(void, glExtGetFramebuffersQCOM, GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers)
GL_ENTRY(void, glExtGetTexLevelParameterivQCOM, GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params)
GL_ENTRY(void, glExtTexObjectStateOverrideiQCOM, GLenum target, GLenum pname, GLint param)
GL_ENTRY(void, glExtGetTexSubImageQCOM, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels)
GL_ENTRY(void, glExtGetBufferPointervQCOM, GLenum target, GLvoid* *params)
GL_ENTRY(void, glExtGetShadersQCOM, GLuint *shaders, GLint maxShaders, GLint *numShaders)
GL_ENTRY(void, glExtGetProgramsQCOM, GLuint *programs, GLint maxPrograms, GLint *numPrograms)
GL_ENTRY(GLboolean, glExtIsProgramBinaryQCOM, GLuint program)
GL_ENTRY(void, glExtGetProgramBinarySourceQCOM, GLuint program, GLenum shadertype, GLchar *source, GLint *length)
GL_ENTRY(void, glStartTilingQCOM, GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
GL_ENTRY(void, glEndTilingQCOM, GLbitfield preserveMask)

View file

@ -0,0 +1,34 @@
GLbitfield 32 0x%08x
GLboolean 8 %d
GLclampf 32 %f
GLclampx 32 0x%08x
GLeglImageOES 32 %p
GLenum 32 0x%08x
GLfixed 32 0x%08x
GLfloat 32 %f
GLint 32 %d
GLintptr 32 %p
GLshort 16 %d
GLsizei 32 %d
GLsizeiptr 32 %p
GLubyte 8 0x%02x
GLuint 32 %u
GLvoid 0 %x
GLchar 8 %d
GLenum* 32 0x%08x
GLboolean* 32 0x%08x
GLclampf* 32 0x%08x
GLclampx* 32 0x%08x
GLeglImageOES* 32 0x%08x
GLfixed* 32 0x%08x
GLfloat* 32 0x%08x
GLint* 32 0x%08x
GLshort* 32 0x%08x
GLsizei* 32 0x%08x
GLubyte* 32 0x%08x
GLuint* 32 0x%08x
GLvoid* 32 0x%08x
GLchar* 32 0x%08x
GLvoid** 32 0x%08x
void* 32 0x%08x
GLvoid*const* 32 0x%08x

View file

@ -0,0 +1,21 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __GLES1_TYPES__H
#define __GLES1_TYPES__H
#include "gl_base_types.h"
#endif // __GLES1_TYPES__H

View file

@ -0,0 +1,15 @@
LOCAL_PATH := $(call my-dir)
### host library ##########################################
$(call emugl-begin-host-static-library,libGLESv2_dec)
$(call emugl-import, libOpenglCodecCommon)
$(call emugl-gen-decoder,$(LOCAL_PATH),gles2)
# For gl2_types.h !
$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
$(call emugl-export,CFLAGS,$(EMUGL_USER_CFLAGS))
LOCAL_SRC_FILES := GLESv2Decoder.cpp
$(call emugl-end-module)

View file

@ -0,0 +1,18 @@
set(GENERATED_SOURCES
gles2_dec.cpp
gles2_opcodes.h
gles2_server_context.cpp)
add_custom_command(
OUTPUT ${GENERATED_SOURCES}
POST_BUILD
COMMAND ${CMAKE_BINARY_DIR}/external/android-emugl/host/tools/emugen/emugen
-D ${CMAKE_CURRENT_BINARY_DIR} gles2
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS emugen)
set(SOURCES
GLESv2Decoder.cpp)
add_library(GLESv2_dec ${SOURCES} ${GENERATED_SOURCES})
target_link_libraries(GLESv2_dec OpenglCodecCommon)

View file

@ -0,0 +1,129 @@
/*
* Copyright 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "GLESv2Decoder.h"
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
static inline void* SafePointerFromUInt(GLuint value) {
return (void*)(uintptr_t)value;
}
GLESv2Decoder::GLESv2Decoder()
{
m_contextData = NULL;
m_GL2library = NULL;
}
GLESv2Decoder::~GLESv2Decoder()
{
delete m_GL2library;
}
void *GLESv2Decoder::s_getProc(const char *name, void *userData)
{
GLESv2Decoder *ctx = (GLESv2Decoder *) userData;
if (ctx == NULL || ctx->m_GL2library == NULL) {
return NULL;
}
void *func = NULL;
#ifdef USE_EGL_GETPROCADDRESS
func = (void *) eglGetProcAddress(name);
#endif
if (func == NULL) {
func = (void *) ctx->m_GL2library->findSymbol(name);
}
return func;
}
int GLESv2Decoder::initGL(get_proc_func_t getProcFunc, void *getProcFuncData)
{
this->initDispatchByName(getProcFunc, getProcFuncData);
glGetCompressedTextureFormats = s_glGetCompressedTextureFormats;
glVertexAttribPointerData = s_glVertexAttribPointerData;
glVertexAttribPointerOffset = s_glVertexAttribPointerOffset;
glDrawElementsOffset = s_glDrawElementsOffset;
glDrawElementsData = s_glDrawElementsData;
glShaderString = s_glShaderString;
glFinishRoundTrip = s_glFinishRoundTrip;
return 0;
}
int GLESv2Decoder::s_glFinishRoundTrip(void *self)
{
GLESv2Decoder *ctx = (GLESv2Decoder *)self;
ctx->glFinish();
return 0;
}
void GLESv2Decoder::s_glGetCompressedTextureFormats(void *self, int count, GLint *formats)
{
GLESv2Decoder *ctx = (GLESv2Decoder *) self;
int nFormats;
ctx->glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nFormats);
if (nFormats > count) {
fprintf(stderr, "%s: GetCompressedTextureFormats: The requested number of formats does not match the number that is reported by OpenGL\n", __FUNCTION__);
} else {
ctx->glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
}
}
void GLESv2Decoder::s_glVertexAttribPointerData(void *self, GLuint indx, GLint size, GLenum type,
GLboolean normalized, GLsizei stride, void * data, GLuint datalen)
{
GLESv2Decoder *ctx = (GLESv2Decoder *) self;
if (ctx->m_contextData != NULL) {
ctx->m_contextData->storePointerData(indx, data, datalen);
// note - the stride of the data is always zero when it comes out of the codec.
// See gl2.attrib for the packing function call.
ctx->glVertexAttribPointer(indx, size, type, normalized, 0, ctx->m_contextData->pointerData(indx));
}
}
void GLESv2Decoder::s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint size, GLenum type,
GLboolean normalized, GLsizei stride, GLuint data)
{
GLESv2Decoder *ctx = (GLESv2Decoder *) self;
ctx->glVertexAttribPointer(indx, size, type, normalized, stride, SafePointerFromUInt(data));
}
void GLESv2Decoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen)
{
GLESv2Decoder *ctx = (GLESv2Decoder *)self;
ctx->glDrawElements(mode, count, type, data);
}
void GLESv2Decoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset)
{
GLESv2Decoder *ctx = (GLESv2Decoder *)self;
ctx->glDrawElements(mode, count, type, SafePointerFromUInt(offset));
}
void GLESv2Decoder::s_glShaderString(void *self, GLuint shader, const GLchar* string, GLsizei len)
{
GLESv2Decoder *ctx = (GLESv2Decoder *)self;
ctx->glShaderSource(shader, 1, &string, NULL);
}

View file

@ -0,0 +1,48 @@
/*
* Copyright 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _GL2_DECODER_H_
#define _GL2_DECODER_H_
#include "gles2_dec.h"
#include "GLDecoderContextData.h"
#include "emugl/common/shared_library.h"
class GLESv2Decoder : public gles2_decoder_context_t
{
public:
typedef void *(*get_proc_func_t)(const char *name, void *userData);
GLESv2Decoder();
~GLESv2Decoder();
int initGL(get_proc_func_t getProcFunc, void *getProcFuncData);
void setContextData(GLDecoderContextData *contextData) { m_contextData = contextData; }
private:
GLDecoderContextData *m_contextData;
emugl::SharedLibrary* m_GL2library;
static void *s_getProc(const char *name, void *userData);
static void gles2_APIENTRY s_glGetCompressedTextureFormats(void *self, int count, GLint *formats);
static void gles2_APIENTRY s_glVertexAttribPointerData(void *self, GLuint indx, GLint size, GLenum type,
GLboolean normalized, GLsizei stride, void * data, GLuint datalen);
static void gles2_APIENTRY s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint size, GLenum type,
GLboolean normalized, GLsizei stride, GLuint offset);
static void gles2_APIENTRY s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset);
static void gles2_APIENTRY s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen);
static void gles2_APIENTRY s_glShaderString(void *self, GLuint shader, const GLchar* string, GLsizei len);
static int gles2_APIENTRY s_glFinishRoundTrip(void *self);
};
#endif

View file

@ -0,0 +1,595 @@
GLOBAL
base_opcode 2048
encoder_headers <string.h> "glUtils.h" "GLESv2EncoderUtils.h"
#void glBindAttribLocation(GLuint program, GLuint index, GLchar *name)
glBindAttribLocation
len name (strlen(name) + 1)
#void glBufferData(GLenum target, GLsizeiptr size, GLvoid *data, GLenum usage)
glBufferData
len data size
var_flag data nullAllowed isLarge
#void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)
glBufferSubData
len data size
var_flag data nullAllowed isLarge
#void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid *data)
glCompressedTexImage2D
len data imageSize
var_flag data nullAllowed isLarge
#void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLvoid *data)
glCompressedTexSubImage2D
len data imageSize
var_flag data nullAllowed isLarge
#void glDeleteBuffers(GLsizei n, GLuint *buffers)
glDeleteBuffers
len buffers (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glDeleteFramebuffers(GLsizei n, GLuint *framebuffers)
glDeleteFramebuffers
len framebuffers (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers)
glDeleteRenderbuffers
len renderbuffers (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glDeleteTextures(GLsizei n, GLuint *textures)
glDeleteTextures
len textures (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glDrawElements(GLenum mode, GLsizei count, GLenum type, GLvoid *indices)
glDrawElements
flag unsupported
#void glGenBuffers(GLsizei n, GLuint *buffers)
glGenBuffers
len buffers (n * sizeof(GLuint))
dir buffers out
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGenFramebuffers(GLsizei n, GLuint *framebuffers)
glGenFramebuffers
len framebuffers (n * sizeof(GLuint))
dir framebuffers out
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers)
glGenRenderbuffers
len renderbuffers (n * sizeof(GLuint))
dir renderbuffers out
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGenTextures(GLsizei n, GLuint *textures)
glGenTextures
len textures (n * sizeof(GLuint))
dir textures out
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
glGetActiveAttrib
len name bufsize
dir name out
var_flag name nullAllowed
dir length out
len length (sizeof(GLsizei))
var_flag length nullAllowed
dir size out
len size (sizeof(GLint))
var_flag size nullAllowed
dir type out
len type (sizeof(GLenum))
var_flag type nullAllowed
#void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
glGetActiveUniform
len name bufsize
dir name out
var_flag name nullAllowed
dir length out
len length (sizeof(GLsizei))
var_flag length nullAllowed
dir size out
len size (sizeof(GLint))
var_flag size nullAllowed
dir type out
len type (sizeof(GLenum))
var_flag type nullAllowed
#void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders)
glGetAttachedShaders
len shaders (maxcount*sizeof(GLuint))
dir shaders out
dir count out
var_flag count nullAllowed
len count (sizeof(GLsizei))
#int glGetAttribLocation(GLuint program, GLchar *name)
glGetAttribLocation
len name (strlen(name) + 1)
#void glGetBooleanv(GLenum pname, GLboolean *params)
glGetBooleanv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLboolean))
#void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
glGetBufferParameteriv
len params (sizeof(GLint))
dir params out
#void glGetFloatv(GLenum pname, GLfloat *params)
glGetFloatv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params)
glGetFramebufferAttachmentParameteriv
dir params out
len params (sizeof(GLint))
#void glGetIntegerv(GLenum pname, GLint *params)
glGetIntegerv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glGetProgramiv(GLuint program, GLenum pname, GLint *params)
glGetProgramiv
dir params out
len params sizeof(GLint)
#XXX - might change if extension constants that return more then one value
#void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog)
glGetProgramInfoLog
dir infolog out
len infolog bufsize
dir length out
len length sizeof(GLsizei)
var_flag length nullAllowed
#void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params)
glGetRenderbufferParameteriv
dir params out
len params sizeof(GLint)
# XXX - might change if pname with value larger then one is added
#void glGetShaderiv(GLuint shader, GLenum pname, GLint *params)
glGetShaderiv
dir params out
len params sizeof(GLint)
# XXX - might change if pname with value larger then one is added
#void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog)
glGetShaderInfoLog
dir length out
len length (sizeof(GLsizei))
var_flag length nullAllowed
dir infolog out
len infolog bufsize
#void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision)
glGetShaderPrecisionFormat
dir range out
len range (2 * sizeof(GLint))
dir precision out
len precision (sizeof(GLint))
#void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source)
glGetShaderSource
dir length out
len length (sizeof(GLsizei))
var_flag length nullAllowed
dir source out
len source bufsize
#GLubyte* glGetString(GLenum name)
glGetString
flag unsupported
#void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
glGetTexParameterfv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params)
glGetTexParameteriv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glGetUniformfv(GLuint program, GLint location, GLfloat *params)
glGetUniformfv
dir params out
len params glSizeof(glesv2_enc::uniformType(self, program, location))
#void glGetUniformiv(GLuint program, GLint location, GLint *params)
glGetUniformiv
dir params out
len params glSizeof(glesv2_enc::uniformType(self, program, location))
#int glGetUniformLocation(GLuint program, GLchar *name)
glGetUniformLocation
len name (strlen(name) + 1)
# client-state shall be handled locally by the encoder in most cases.
# however, GL_CURRENT_VERTEX_ATTRIB and potential others are handled by the server side,
# thus we still need to implement it.
#void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
glGetVertexAttribfv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#see glGetVertexAttribfv for comments
#void glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params)
glGetVertexAttribiv
dir params out
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
glReadPixels
dir pixels out
len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 1)
#void glShaderBinary(GLsizei n, GLuint *shaders, GLenum binaryformat, GLvoid *binary, GLsizei length)
glShaderBinary
flag unsupported
#void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels)
glTexImage2D
dir pixels in
len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
glTexParameterfv
len params (glUtilsParamSize(pname) * sizeof(GLfloat))
#void glTexParameteriv(GLenum target, GLenum pname, GLint *params)
glTexParameteriv
len params (glUtilsParamSize(pname) * sizeof(GLint))
#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
glTexSubImage2D
len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glUniform1fv(GLint location, GLsizei count, GLfloat *v)
glUniform1fv
len v (count * sizeof(GLfloat))
#void glUniform1iv(GLint location, GLsizei count, GLint *v)
glUniform1iv
len v (count * sizeof(GLint))
#void glUniform2fv(GLint location, GLsizei count, GLfloat *v)
glUniform2fv
len v (count * 2 * sizeof(GLfloat))
#void glUniform2iv(GLint location, GLsizei count, GLint *v)
glUniform2iv
len v (count * 2 * sizeof(GLint))
#void glUniform3fv(GLint location, GLsizei count, GLfloat *v)
glUniform3fv
len v (count * 3 * sizeof(GLfloat))
#void glUniform3iv(GLint location, GLsizei count, GLint *v)
glUniform3iv
len v (3 * count * sizeof(GLint))
#void glUniform4fv(GLint location, GLsizei count, GLfloat *v)
glUniform4fv
len v (4 * count * sizeof(GLfloat))
#void glUniform4iv(GLint location, GLsizei count, GLint *v)
glUniform4iv
len v (4 * count * sizeof(GLint))
#void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value)
glUniformMatrix2fv
len value (count * 4 * sizeof(GLfloat))
#void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value)
glUniformMatrix3fv
len value (count * 9 * sizeof(GLfloat))
#void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value)
glUniformMatrix4fv
len value (count * 16 * sizeof(GLfloat))
#void glVertexAttrib1fv(GLuint indx, GLfloat *values)
glVertexAttrib1fv
len values (sizeof(GLfloat))
#void glVertexAttrib2fv(GLuint indx, GLfloat *values)
glVertexAttrib2fv
len values (2 * sizeof(GLfloat))
#void glVertexAttrib3fv(GLuint indx, GLfloat *values)
glVertexAttrib3fv
len values (3 * sizeof(GLfloat))
#void glVertexAttrib4fv(GLuint indx, GLfloat *values)
glVertexAttrib4fv
len values (4 * sizeof(GLfloat))
#void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *ptr)
glVertexAttribPointer
flag unsupported
#void glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
glGetProgramBinaryOES
flag unsupported
#void glProgramBinaryOES(GLuint program, GLenum binaryFormat, GLvoid *binary, GLint length)
glProgramBinaryOES
flag unsupported
#void* glMapBufferOES(GLenum target, GLenum access)
glMapBufferOES
flag unsupported
#void glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid *pixels)
glTexImage3DOES
len pixels glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *pixels)
glTexSubImage3DOES
len pixels glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLvoid *data)
glCompressedTexImage3DOES
len data imageSize
var_flag data nullAllowed isLarge
#void glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, GLvoid *data)
glCompressedTexSubImage3DOES
len data imageSize
var_flag data nullAllowed isLarge
#void glDeleteVertexArraysOES(GLsizei n, GLuint *arrays)
glDeleteVertexArraysOES
len arrays (n * sizeof(GLuint))
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glGenVertexArraysOES(GLsizei n, GLuint *arrays)
glGenVertexArraysOES
len arrays (n * sizeof(GLuint))
dir arrays out
param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }
#void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, GLenum *attachments)
glDiscardFramebufferEXT
len attachments (numAttachments * sizeof(GLenum))
#void glMultiDrawArraysEXT(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount)
glMultiDrawArraysEXT
flag unsupported
#void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount)
glMultiDrawElementsEXT
flag unsupported
# handled by encoder
#void glShaderSource(GLuint shader, GLsizei count, GLstr *string, const GLint *length)
glShaderSource
flag unsupported
#void glGetPerfMonitorGroupsAMD(GLint *numGroups, GLsizei groupsSize, GLuint *groups)
glGetPerfMonitorGroupsAMD
flag unsupported
#void glGetPerfMonitorCountersAMD(GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters)
glGetPerfMonitorCountersAMD
flag unsupported
#void glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString)
glGetPerfMonitorGroupStringAMD
flag unsupported
#void glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString)
glGetPerfMonitorCounterStringAMD
flag unsupported
#void glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid *data)
glGetPerfMonitorCounterInfoAMD
flag unsupported
#void glGenPerfMonitorsAMD(GLsizei n, GLuint *monitors)
glGenPerfMonitorsAMD
flag unsupported
#void glDeletePerfMonitorsAMD(GLsizei n, GLuint *monitors)
glDeletePerfMonitorsAMD
flag unsupported
#void glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList)
glSelectPerfMonitorCountersAMD
flag unsupported
#void glBeginPerfMonitorAMD(GLuint monitor)
glBeginPerfMonitorAMD
flag unsupported
#void glEndPerfMonitorAMD(GLuint monitor)
glEndPerfMonitorAMD
flag unsupported
#void glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten)
glGetPerfMonitorCounterDataAMD
flag unsupported
#void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
glRenderbufferStorageMultisampleIMG
flag unsupported
#void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
glFramebufferTexture2DMultisampleIMG
flag unsupported
#void glDeleteFencesNV(GLsizei n, GLuint *fences)
glDeleteFencesNV
flag unsupported
#void glGenFencesNV(GLsizei n, GLuint *fences)
glGenFencesNV
flag unsupported
#GLboolean glIsFenceNV(GLuint fence)
glIsFenceNV
flag unsupported
#GLboolean glTestFenceNV(GLuint fence)
glTestFenceNV
flag unsupported
#void glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
glGetFenceivNV
flag unsupported
#void glFinishFenceNV(GLuint fence)
glFinishFenceNV
flag unsupported
#void glSetFenceNV(GLuint fence, GLenum condition)
glSetFenceNV
flag unsupported
#void glCoverageMaskNV(GLboolean mask)
glCoverageMaskNV
flag unsupported
#void glCoverageOperationNV(GLenum operation)
glCoverageOperationNV
flag unsupported
#void glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls)
glGetDriverControlsQCOM
flag unsupported
#void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString)
glGetDriverControlStringQCOM
flag unsupported
#void glEnableDriverControlQCOM(GLuint driverControl)
glEnableDriverControlQCOM
flag unsupported
#void glDisableDriverControlQCOM(GLuint driverControl)
glDisableDriverControlQCOM
flag unsupported
#void glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures)
glExtGetTexturesQCOM
flag unsupported
#void glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers)
glExtGetBuffersQCOM
flag unsupported
#void glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers)
glExtGetRenderbuffersQCOM
flag unsupported
#void glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers)
glExtGetFramebuffersQCOM
flag unsupported
#void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params)
glExtGetTexLevelParameterivQCOM
flag unsupported
#void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param)
glExtTexObjectStateOverrideiQCOM
flag unsupported
#void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels)
glExtGetTexSubImageQCOM
flag unsupported
#void glExtGetBufferPointervQCOM(GLenum target, GLvoidptr *params)
glExtGetBufferPointervQCOM
flag unsupported
#void glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders)
glExtGetShadersQCOM
flag unsupported
#void glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms)
glExtGetProgramsQCOM
flag unsupported
#GLboolean glExtIsProgramBinaryQCOM(GLuint program)
glExtIsProgramBinaryQCOM
flag unsupported
#void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length)
glExtGetProgramBinarySourceQCOM
flag unsupported
#void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
glStartTilingQCOM
flag unsupported
#void glEndTilingQCOM(GLbitfield preserveMask)
glEndTilingQCOM
flag unsupported
#void glVertexAttribPointerData(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void * data, GLuint datalen)
glVertexAttribPointerData
len data datalen
custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen)
flag custom_decoder
flag not_api
glVertexAttribPointerOffset
flag custom_decoder
flag not_api
#client-state, handled by the encoder
#GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, GLvoid** pointer)
glGetVertexAttribPointerv
flag unsupported
glDrawElementsData
len data datalen
flag custom_decoder
flag not_api
glDrawElementsOffset
flag custom_decoder
flag not_api
#GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats)
glGetCompressedTextureFormats
dir formats out
len formats (count * sizeof(GLint))
flag custom_decoder
flag not_api
#GL_ENTRY(void, glShaderString, GLuint shader, GLchar *string, GLsizei len)
glShaderString
len string len
flag custom_decoder
flag not_api
glFinishRoundTrip
flag custom_decoder
flag not_api

View file

@ -0,0 +1,214 @@
GL_ENTRY(void, glActiveTexture, GLenum texture)
GL_ENTRY(void, glAttachShader, GLuint program, GLuint shader)
GL_ENTRY(void, glBindAttribLocation, GLuint program, GLuint index, const GLchar* name)
GL_ENTRY(void, glBindBuffer, GLenum target, GLuint buffer)
GL_ENTRY(void, glBindFramebuffer, GLenum target, GLuint framebuffer)
GL_ENTRY(void, glBindRenderbuffer, GLenum target, GLuint renderbuffer)
GL_ENTRY(void, glBindTexture, GLenum target, GLuint texture)
GL_ENTRY(void, glBlendColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
GL_ENTRY(void, glBlendEquation, GLenum mode )
GL_ENTRY(void, glBlendEquationSeparate, GLenum modeRGB, GLenum modeAlpha)
GL_ENTRY(void, glBlendFunc, GLenum sfactor, GLenum dfactor)
GL_ENTRY(void, glBlendFuncSeparate, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
GL_ENTRY(void, glBufferData, GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
GL_ENTRY(void, glBufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
GL_ENTRY(GLenum, glCheckFramebufferStatus, GLenum target)
GL_ENTRY(void, glClear, GLbitfield mask)
GL_ENTRY(void, glClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
GL_ENTRY(void, glClearDepthf, GLclampf depth)
GL_ENTRY(void, glClearStencil, GLint s)
GL_ENTRY(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
GL_ENTRY(void, glCompileShader, GLuint shader)
GL_ENTRY(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data)
GL_ENTRY(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data)
GL_ENTRY(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
GL_ENTRY(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
GL_ENTRY(GLuint, glCreateProgram, void)
GL_ENTRY(GLuint, glCreateShader, GLenum type)
GL_ENTRY(void, glCullFace, GLenum mode)
GL_ENTRY(void, glDeleteBuffers, GLsizei n, const GLuint* buffers)
GL_ENTRY(void, glDeleteFramebuffers, GLsizei n, const GLuint* framebuffers)
GL_ENTRY(void, glDeleteProgram, GLuint program)
GL_ENTRY(void, glDeleteRenderbuffers, GLsizei n, const GLuint* renderbuffers)
GL_ENTRY(void, glDeleteShader, GLuint shader)
GL_ENTRY(void, glDeleteTextures, GLsizei n, const GLuint* textures)
GL_ENTRY(void, glDepthFunc, GLenum func)
GL_ENTRY(void, glDepthMask, GLboolean flag)
GL_ENTRY(void, glDepthRangef, GLclampf zNear, GLclampf zFar)
GL_ENTRY(void, glDetachShader, GLuint program, GLuint shader)
GL_ENTRY(void, glDisable, GLenum cap)
GL_ENTRY(void, glDisableVertexAttribArray, GLuint index)
GL_ENTRY(void, glDrawArrays, GLenum mode, GLint first, GLsizei count)
GL_ENTRY(void, glDrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
GL_ENTRY(void, glEnable, GLenum cap)
GL_ENTRY(void, glEnableVertexAttribArray, GLuint index)
GL_ENTRY(void, glFinish, void)
GL_ENTRY(void, glFlush, void)
GL_ENTRY(void, glFramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
GL_ENTRY(void, glFramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
GL_ENTRY(void, glFrontFace, GLenum mode)
GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint* buffers)
GL_ENTRY(void, glGenerateMipmap, GLenum target)
GL_ENTRY(void, glGenFramebuffers, GLsizei n, GLuint* framebuffers)
GL_ENTRY(void, glGenRenderbuffers, GLsizei n, GLuint* renderbuffers)
GL_ENTRY(void, glGenTextures, GLsizei n, GLuint* textures)
GL_ENTRY(void, glGetActiveAttrib, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
GL_ENTRY(void, glGetActiveUniform, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
GL_ENTRY(void, glGetAttachedShaders, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
GL_ENTRY(int, glGetAttribLocation, GLuint program, const GLchar* name)
GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean* params)
GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint* params)
GL_ENTRY(GLenum, glGetError, void)
GL_ENTRY(void, glGetFloatv, GLenum pname, GLfloat* params)
GL_ENTRY(void, glGetFramebufferAttachmentParameteriv, GLenum target, GLenum attachment, GLenum pname, GLint* params)
GL_ENTRY(void, glGetIntegerv, GLenum pname, GLint* params)
GL_ENTRY(void, glGetProgramiv, GLuint program, GLenum pname, GLint* params)
GL_ENTRY(void, glGetProgramInfoLog, GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
GL_ENTRY(void, glGetRenderbufferParameteriv, GLenum target, GLenum pname, GLint* params)
GL_ENTRY(void, glGetShaderiv, GLuint shader, GLenum pname, GLint* params)
GL_ENTRY(void, glGetShaderInfoLog, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
GL_ENTRY(void, glGetShaderPrecisionFormat, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
GL_ENTRY(void, glGetShaderSource, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
GL_ENTRY(const GLubyte*, glGetString, GLenum name)
GL_ENTRY(void, glGetTexParameterfv, GLenum target, GLenum pname, GLfloat* params)
GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint* params)
GL_ENTRY(void, glGetUniformfv, GLuint program, GLint location, GLfloat* params)
GL_ENTRY(void, glGetUniformiv, GLuint program, GLint location, GLint* params)
GL_ENTRY(int, glGetUniformLocation, GLuint program, const GLchar* name)
GL_ENTRY(void, glGetVertexAttribfv, GLuint index, GLenum pname, GLfloat* params)
GL_ENTRY(void, glGetVertexAttribiv, GLuint index, GLenum pname, GLint* params)
GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, GLvoid** pointer)
GL_ENTRY(void, glHint, GLenum target, GLenum mode)
GL_ENTRY(GLboolean, glIsBuffer, GLuint buffer)
GL_ENTRY(GLboolean, glIsEnabled, GLenum cap)
GL_ENTRY(GLboolean, glIsFramebuffer, GLuint framebuffer)
GL_ENTRY(GLboolean, glIsProgram, GLuint program)
GL_ENTRY(GLboolean, glIsRenderbuffer, GLuint renderbuffer)
GL_ENTRY(GLboolean, glIsShader, GLuint shader)
GL_ENTRY(GLboolean, glIsTexture, GLuint texture)
GL_ENTRY(void, glLineWidth, GLfloat width)
GL_ENTRY(void, glLinkProgram, GLuint program)
GL_ENTRY(void, glPixelStorei, GLenum pname, GLint param)
GL_ENTRY(void, glPolygonOffset, GLfloat factor, GLfloat units)
GL_ENTRY(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
GL_ENTRY(void, glReleaseShaderCompiler, void)
GL_ENTRY(void, glRenderbufferStorage, GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
GL_ENTRY(void, glSampleCoverage, GLclampf value, GLboolean invert)
GL_ENTRY(void, glScissor, GLint x, GLint y, GLsizei width, GLsizei height)
GL_ENTRY(void, glShaderBinary, GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
GL_ENTRY(void, glShaderSource, GLuint shader, GLsizei count, const GLchar*const* string, const GLint* length)
GL_ENTRY(void, glStencilFunc, GLenum func, GLint ref, GLuint mask)
GL_ENTRY(void, glStencilFuncSeparate, GLenum face, GLenum func, GLint ref, GLuint mask)
GL_ENTRY(void, glStencilMask, GLuint mask)
GL_ENTRY(void, glStencilMaskSeparate, GLenum face, GLuint mask)
GL_ENTRY(void, glStencilOp, GLenum fail, GLenum zfail, GLenum zpass)
GL_ENTRY(void, glStencilOpSeparate, GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
GL_ENTRY(void, glTexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
GL_ENTRY(void, glTexParameterf, GLenum target, GLenum pname, GLfloat param)
GL_ENTRY(void, glTexParameterfv, GLenum target, GLenum pname, const GLfloat* params)
GL_ENTRY(void, glTexParameteri, GLenum target, GLenum pname, GLint param)
GL_ENTRY(void, glTexParameteriv, GLenum target, GLenum pname, const GLint* params)
GL_ENTRY(void, glTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels)
GL_ENTRY(void, glUniform1f, GLint location, GLfloat x)
GL_ENTRY(void, glUniform1fv, GLint location, GLsizei count, const GLfloat* v)
GL_ENTRY(void, glUniform1i, GLint location, GLint x)
GL_ENTRY(void, glUniform1iv, GLint location, GLsizei count, const GLint* v)
GL_ENTRY(void, glUniform2f, GLint location, GLfloat x, GLfloat y)
GL_ENTRY(void, glUniform2fv, GLint location, GLsizei count, const GLfloat* v)
GL_ENTRY(void, glUniform2i, GLint location, GLint x, GLint y)
GL_ENTRY(void, glUniform2iv, GLint location, GLsizei count, const GLint* v)
GL_ENTRY(void, glUniform3f, GLint location, GLfloat x, GLfloat y, GLfloat z)
GL_ENTRY(void, glUniform3fv, GLint location, GLsizei count, const GLfloat* v)
GL_ENTRY(void, glUniform3i, GLint location, GLint x, GLint y, GLint z)
GL_ENTRY(void, glUniform3iv, GLint location, GLsizei count, const GLint* v)
GL_ENTRY(void, glUniform4f, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
GL_ENTRY(void, glUniform4fv, GLint location, GLsizei count, const GLfloat* v)
GL_ENTRY(void, glUniform4i, GLint location, GLint x, GLint y, GLint z, GLint w)
GL_ENTRY(void, glUniform4iv, GLint location, GLsizei count, const GLint* v)
GL_ENTRY(void, glUniformMatrix2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
GL_ENTRY(void, glUniformMatrix3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
GL_ENTRY(void, glUniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
GL_ENTRY(void, glUseProgram, GLuint program)
GL_ENTRY(void, glValidateProgram, GLuint program)
GL_ENTRY(void, glVertexAttrib1f, GLuint indx, GLfloat x)
GL_ENTRY(void, glVertexAttrib1fv, GLuint indx, const GLfloat* values)
GL_ENTRY(void, glVertexAttrib2f, GLuint indx, GLfloat x, GLfloat y)
GL_ENTRY(void, glVertexAttrib2fv, GLuint indx, const GLfloat* values)
GL_ENTRY(void, glVertexAttrib3f, GLuint indx, GLfloat x, GLfloat y, GLfloat z)
GL_ENTRY(void, glVertexAttrib3fv, GLuint indx, const GLfloat* values)
GL_ENTRY(void, glVertexAttrib4f, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
GL_ENTRY(void, glVertexAttrib4fv, GLuint indx, const GLfloat* values)
GL_ENTRY(void, glVertexAttribPointer, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
GL_ENTRY(void, glViewport, GLint x, GLint y, GLsizei width, GLsizei height)
GL_ENTRY(void, glEGLImageTargetTexture2DOES, GLenum target, GLeglImageOES image)
GL_ENTRY(void, glEGLImageTargetRenderbufferStorageOES, GLenum target, GLeglImageOES image)
GL_ENTRY(void, glGetProgramBinaryOES, GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary)
GL_ENTRY(void, glProgramBinaryOES, GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length)
GL_ENTRY(void*, glMapBufferOES, GLenum target, GLenum access)
GL_ENTRY(GLboolean, glUnmapBufferOES, GLenum target)
#GL_ENTRY(void, glGetBufferPointervOES, GLenum target, GLenum pname, GLvoid** params)
GL_ENTRY(void, glTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
GL_ENTRY(void, glTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
GL_ENTRY(void, glCopyTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
GL_ENTRY(void, glCompressedTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
GL_ENTRY(void, glCompressedTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
GL_ENTRY(void, glFramebufferTexture3DOES, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
GL_ENTRY(void, glBindVertexArrayOES, GLuint array)
GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint *arrays)
GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint *arrays)
GL_ENTRY(GLboolean, glIsVertexArrayOES, GLuint array)
GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum *attachments)
GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount)
GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid*const* indices, GLsizei primcount)
#not supported
GL_ENTRY(void, glGetPerfMonitorGroupsAMD, GLint *numGroups, GLsizei groupsSize, GLuint *groups)
GL_ENTRY(void, glGetPerfMonitorCountersAMD, GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters)
GL_ENTRY(void, glGetPerfMonitorGroupStringAMD, GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString)
GL_ENTRY(void, glGetPerfMonitorCounterStringAMD, GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString)
GL_ENTRY(void, glGetPerfMonitorCounterInfoAMD, GLuint group, GLuint counter, GLenum pname, GLvoid *data)
GL_ENTRY(void, glGenPerfMonitorsAMD, GLsizei n, GLuint *monitors)
GL_ENTRY(void, glDeletePerfMonitorsAMD, GLsizei n, GLuint *monitors)
GL_ENTRY(void, glSelectPerfMonitorCountersAMD, GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList)
GL_ENTRY(void, glBeginPerfMonitorAMD, GLuint monitor)
GL_ENTRY(void, glEndPerfMonitorAMD, GLuint monitor)
GL_ENTRY(void, glGetPerfMonitorCounterDataAMD, GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten)
GL_ENTRY(void, glRenderbufferStorageMultisampleIMG, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
GL_ENTRY(void, glFramebufferTexture2DMultisampleIMG, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples)
GL_ENTRY(void, glDeleteFencesNV, GLsizei n, const GLuint *fences)
GL_ENTRY(void, glGenFencesNV, GLsizei n, GLuint *fences)
GL_ENTRY(GLboolean, glIsFenceNV, GLuint fence)
GL_ENTRY(GLboolean, glTestFenceNV, GLuint fence)
GL_ENTRY(void, glGetFenceivNV, GLuint fence, GLenum pname, GLint *params)
GL_ENTRY(void, glFinishFenceNV, GLuint fence)
GL_ENTRY(void, glSetFenceNV, GLuint fence, GLenum condition)
GL_ENTRY(void, glCoverageMaskNV, GLboolean mask)
GL_ENTRY(void, glCoverageOperationNV, GLenum operation)
GL_ENTRY(void, glGetDriverControlsQCOM, GLint *num, GLsizei size, GLuint *driverControls)
GL_ENTRY(void, glGetDriverControlStringQCOM, GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString)
GL_ENTRY(void, glEnableDriverControlQCOM, GLuint driverControl)
GL_ENTRY(void, glDisableDriverControlQCOM, GLuint driverControl)
GL_ENTRY(void, glExtGetTexturesQCOM, GLuint *textures, GLint maxTextures, GLint *numTextures)
GL_ENTRY(void, glExtGetBuffersQCOM, GLuint *buffers, GLint maxBuffers, GLint *numBuffers)
GL_ENTRY(void, glExtGetRenderbuffersQCOM, GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers)
GL_ENTRY(void, glExtGetFramebuffersQCOM, GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers)
GL_ENTRY(void, glExtGetTexLevelParameterivQCOM, GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params)
GL_ENTRY(void, glExtTexObjectStateOverrideiQCOM, GLenum target, GLenum pname, GLint param)
GL_ENTRY(void, glExtGetTexSubImageQCOM, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels)
GL_ENTRY(void, glExtGetBufferPointervQCOM, GLenum target, GLvoidptr *params)
GL_ENTRY(void, glExtGetShadersQCOM, GLuint *shaders, GLint maxShaders, GLint *numShaders)
GL_ENTRY(void, glExtGetProgramsQCOM, GLuint *programs, GLint maxPrograms, GLint *numPrograms)
GL_ENTRY(GLboolean, glExtIsProgramBinaryQCOM, GLuint program)
GL_ENTRY(void, glExtGetProgramBinarySourceQCOM, GLuint program, GLenum shadertype, GLchar *source, GLint *length)
GL_ENTRY(void, glStartTilingQCOM, GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask)
GL_ENTRY(void, glEndTilingQCOM, GLbitfield preserveMask)
# add-ons
GL_ENTRY(void, glVertexAttribPointerData, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void * data, GLuint datalen)
GL_ENTRY(void, glVertexAttribPointerOffset, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset)
GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset)
GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen)
GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats)
GL_ENTRY(void, glShaderString, GLuint shader, const GLchar* string, GLsizei len)
GL_ENTRY(int, glFinishRoundTrip, void)

View file

@ -0,0 +1,38 @@
GLbitfield 32 0x%08x
GLboolean 8 %d
GLclampf 32 %f
GLclampx 32 0x%08x
GLeglImageOES 32 %p
GLenum 32 0x%08x
GLfixed 32 0x%08x
GLfloat 32 %f
GLint 32 %d
GLintptr 32 %p
GLshort 16 %d
GLsizei 32 %d
GLsizeiptr 32 %p
GLubyte 8 0x%02x
GLuint 32 %u
GLvoid 0 %x
GLchar 8 %d
GLenum* 32 0x%08x
GLboolean* 32 0x%08x
GLclampf* 32 0x%08x
GLclampx* 32 0x%08x
GLeglImageOES* 32 0x%08x
GLfixed* 32 0x%08x
GLfloat* 32 0x%08x
GLint* 32 0x%08x
GLshort* 32 0x%08x
GLsizei* 32 0x%08x
GLubyte* 32 0x%08x
GLuint* 32 0x%08x
GLvoid* 32 0x%08x
GLchar* 32 0x%08x
GLchar** 32 0x%08x
GLvoid** 32 0x%08x
void* 32 0x%08x
GLstr* 32 0x%08x
GLvoidptr* 32 0x%08x
GLchar*const* 32 0x%08x
GLvoid*const* 32 0x%08x

View file

@ -0,0 +1,21 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _GL_2_TYPES_H_
#define _GL_2_TYPES_H_
#include "gl_base_types.h"
typedef void *GLvoidptr;
#endif

View file

@ -0,0 +1,14 @@
LOCAL_PATH := $(call my-dir)
### host library ##########################################
$(call emugl-begin-host-static-library,libOpenGLESDispatch)
$(call emugl-import,libGLESv2_dec libGLESv1_dec)
# use Translator's egl headers
LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include
LOCAL_C_INCLUDES += $(EMUGL_PATH)/shared
LOCAL_SRC_FILES := EGLDispatch.cpp \
GLESv2Dispatch.cpp \
GLESv1Dispatch.cpp
$(call emugl-end-module)

View file

@ -0,0 +1,10 @@
set(SOURCES
EGLDispatch.cpp
GLESv2Dispatch.cpp
GLESv1Dispatch.cpp)
add_library(OpenGLESDispatch ${SOURCES} ${GENERATED_SOURCES})
target_link_libraries(OpenGLESDispatch
emugl_common
GLESv2_dec
GLESv1_dec)

View file

@ -0,0 +1,52 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "OpenGLESDispatch/EGLDispatch.h"
#include "emugl/common/shared_library.h"
#include <stdio.h>
#include <stdlib.h>
EGLDispatch s_egl;
#define DEFAULT_EGL_LIB EMUGL_LIBNAME("EGL_translator")
#define RENDER_EGL_LOAD_FIELD(return_type, function_name, signature) \
s_egl. function_name = (function_name ## _t) lib->findSymbol(#function_name);
#define RENDER_EGL_LOAD_OPTIONAL_FIELD(return_type, function_name, signature) \
if (s_egl.eglGetProcAddress) s_egl. function_name = \
(function_name ## _t) s_egl.eglGetProcAddress(#function_name); \
if (!s_egl.function_name || !s_egl.eglGetProcAddress) \
RENDER_EGL_LOAD_FIELD(return_type, function_name, signature)
bool init_egl_dispatch()
{
const char *libName = getenv("ANDROID_EGL_LIB");
if (!libName) libName = DEFAULT_EGL_LIB;
char error[256];
emugl::SharedLibrary *lib = emugl::SharedLibrary::open(libName, error, sizeof(error));
if (!lib) {
printf("Failed to open %s: [%s]\n", libName, error);
return NULL;
}
LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_LOAD_FIELD)
LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_LOAD_OPTIONAL_FIELD)
return true;
}

View file

@ -0,0 +1,95 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "OpenGLESDispatch/GLESv1Dispatch.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include <stdio.h>
#include <stdlib.h>
#include "emugl/common/shared_library.h"
extern EGLDispatch s_egl;
static emugl::SharedLibrary *s_gles1_lib = NULL;
// An unimplemented function which prints out an error message.
// To make it consistent with the guest, all GLES1 functions not supported by
// the driver should be redirected to this function.
static void gles1_unimplemented() {
fprintf(stderr, "Called unimplemented GLESv1 API\n");
}
//
// This function is called only once during initialiation before
// any thread has been created - hence it should NOT be thread safe.
//
#define DEFAULT_GLES_CM_LIB EMUGL_LIBNAME("GLES_CM_translator")
bool gles1_dispatch_init(GLESv1Dispatch* dispatch_table) {
const char* libName = getenv("ANDROID_GLESv1_LIB");
if (!libName) {
libName = DEFAULT_GLES_CM_LIB;
}
char error[256];
s_gles1_lib = emugl::SharedLibrary::open(libName, error, sizeof(error));
if (!s_gles1_lib) {
fprintf(stderr, "%s: Could not load %s [%s]\n", __FUNCTION__,
libName, error);
return false;
}
//
// init the GLES dispatch table
//
#define LOOKUP_SYMBOL(return_type,function_name,signature,callargs) \
dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \
s_gles1_lib->findSymbol(#function_name));
#define LOOKUP_EXT_SYMBOL(return_type,function_name,signature,callargs) \
dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \
s_egl.eglGetProcAddress(#function_name));
LIST_GLES1_FUNCTIONS(LOOKUP_SYMBOL,LOOKUP_EXT_SYMBOL)
return true;
}
//
// This function is called only during initialization of the decoder before
// any thread has been created - hence it should NOT be thread safe.
//
void *gles1_dispatch_get_proc_func(const char *name, void *userData)
{
void* func = NULL;
if (s_gles1_lib && !func) {
func = (void *)s_gles1_lib->findSymbol(name);
}
if (!func) {
func = (void *)s_egl.eglGetProcAddress(name);
}
// To make it consistent with the guest, redirect any unsupported functions
// to gles1_unimplemented.
if (!func) {
fprintf(stderr, "ERROR: Failed to find symbol for %s\n", name);
func = (void *)gles1_unimplemented;
}
return func;
}

View file

@ -0,0 +1,95 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "OpenGLESDispatch/GLESv2Dispatch.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include <stdio.h>
#include <stdlib.h>
#include "emugl/common/shared_library.h"
extern EGLDispatch s_egl;
static emugl::SharedLibrary *s_gles2_lib = NULL;
#define DEFAULT_GLES_V2_LIB EMUGL_LIBNAME("GLES_V2_translator")
// An unimplemented function which prints out an error message.
// To make it consistent with the guest, all GLES2 functions not supported by
// the driver should be redirected to this function.
static void gles2_unimplemented() {
fprintf(stderr, "Called unimplemented GLESv2 API\n");
}
//
// This function is called only once during initialiation before
// any thread has been created - hence it should NOT be thread safe.
//
bool gles2_dispatch_init(GLESv2Dispatch* dispatch_table)
{
const char *libName = getenv("ANDROID_GLESv2_LIB");
if (!libName) {
libName = DEFAULT_GLES_V2_LIB;
}
char error[256];
s_gles2_lib = emugl::SharedLibrary::open(libName, error, sizeof(error));
if (!s_gles2_lib) {
fprintf(stderr, "%s: Could not load %s [%s]\n", __FUNCTION__,
libName, error);
return false;
}
//
// init the GLES dispatch table
//
#define LOOKUP_SYMBOL(return_type,function_name,signature,callargs) \
dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \
s_gles2_lib->findSymbol(#function_name));
#define LOOKUP_EXT_SYMBOL(return_type,function_name,signature,callargs) \
dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \
s_egl.eglGetProcAddress(#function_name));
LIST_GLES2_FUNCTIONS(LOOKUP_SYMBOL,LOOKUP_EXT_SYMBOL)
return true;
}
//
// This function is called only during initialization before
// any thread has been created - hence it should NOT be thread safe.
//
void *gles2_dispatch_get_proc_func(const char *name, void *userData)
{
void* func = NULL;
if (s_gles2_lib && !func) {
func = (void *)s_gles2_lib->findSymbol(name);
}
if (!func) {
func = (void *)s_egl.eglGetProcAddress(name);
}
// To make it consistent with the guest, redirect any unsupported functions
// to gles2_unimplemented.
if (!func) {
func = (void *)gles2_unimplemented;
}
return func;
}

View file

@ -0,0 +1,13 @@
!gles1_extensions
# OpenGL functions which are needed ONLY for implementing GLES 1.1 EXTENSIONS
void glCurrentPaletteMatrixARB(GLint index);
void glMatrixIndexuivARB(GLint size, GLuint * indices);
void glMatrixIndexPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
void glWeightPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
void glTexGenf(GLenum coord, GLenum pname, GLfloat param );
void glTexGeni(GLenum coord, GLenum pname, GLint param );
void glTexGenfv(GLenum coord, GLenum pname, const GLfloat *params );
void glTexGeniv(GLenum coord, GLenum pname, const GLint *params );
void glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params );
void glGetTexGeniv(GLenum coord, GLenum pname, GLint *params );

View file

@ -0,0 +1,65 @@
!gles1_only
# OpenGL functions which are needed ONLY for implementing GLES 1.1
void glAlphaFunc(GLenum func, GLclampf ref);
void glBegin( GLenum mode );
void glClientActiveTexture( GLenum texture );
void glClipPlane(GLenum plane, const GLdouble *equation);
void glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
void glColor4fv( const GLfloat *v );
void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
void glColor4ubv( const GLubyte *v );
void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void glDisableClientState(GLenum array);
void glEnableClientState(GLenum array);
void glEnd(void);
void glFogf(GLenum pname, GLfloat param);
void glFogfv(GLenum pname, const GLfloat *params);
void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
void glGetClipPlane(GLenum plane, GLdouble *equation);
void glGetDoublev( GLenum pname, GLdouble *params );
void glGetLightfv(GLenum light, GLenum pname, GLfloat *params);
void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params);
void glGetPointerv(GLenum pname, GLvoid* *params);
void glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params);
void glGetTexEnviv(GLenum target, GLenum pname, GLint *params);
void glLightf(GLenum light, GLenum pname, GLfloat param);
void glLightfv(GLenum light, GLenum pname, const GLfloat *params);
void glLightModelf(GLenum pname, GLfloat param);
void glLightModelfv(GLenum pname, const GLfloat *params);
void glLoadIdentity(void);
void glLoadMatrixf(const GLfloat *m);
void glLogicOp(GLenum opcode);
void glMaterialf(GLenum face, GLenum pname, GLfloat param);
void glMaterialfv(GLenum face, GLenum pname, const GLfloat *params);
void glMultiTexCoord2fv( GLenum target, const GLfloat *v );
void glMultiTexCoord2sv( GLenum target, const GLshort *v );
void glMultiTexCoord3fv( GLenum target, const GLfloat *v );
void glMultiTexCoord3sv( GLenum target, const GLshort *v );
void glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q );
void glMultiTexCoord4fv( GLenum target, const GLfloat *v );
void glMultiTexCoord4sv( GLenum target, const GLshort *v );
void glMultMatrixf(const GLfloat *m);
void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
void glNormal3fv( const GLfloat *v );
void glNormal3sv( const GLshort *v );
void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
void glPointParameterf(GLenum param, GLfloat value);
void glPointParameterfv(GLenum param, const GLfloat *values);
void glPointSize(GLfloat size);
void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
void glScalef(GLfloat x, GLfloat y, GLfloat z);
void glTexEnvf(GLenum target, GLenum pname, GLfloat param);
void glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params);
void glMatrixMode(GLenum mode);
void glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer);
void glPopMatrix(void);
void glPushMatrix(void);
void glShadeModel(GLenum mode);
void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void glTexEnvi(GLenum target, GLenum pname, GLint param);
void glTexEnviv(GLenum target, GLenum pname, const GLint *params);
void glTranslatef(GLfloat x, GLfloat y, GLfloat z);
void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);

View file

@ -0,0 +1,6 @@
!gles2_extensions
# GLES 2.0 extensions
void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
void glReleaseShaderCompiler(void);
void glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);

View file

@ -0,0 +1,80 @@
!gles2_only
# OpenGL functions which are needed ONLY for implementing GLES 2.0
void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
void glStencilMaskSeparate(GLenum face, GLuint mask);
GLboolean glIsProgram(GLuint program);
GLboolean glIsShader(GLuint shader);
void glVertexAttrib1f(GLuint indx, GLfloat x);
void glVertexAttrib1fv(GLuint indx, const GLfloat* values);
void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
void glVertexAttrib2fv(GLuint indx, const GLfloat* values);
void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
void glVertexAttrib3fv(GLuint indx, const GLfloat* values);
void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void glVertexAttrib4fv(GLuint indx, const GLfloat* values);
void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
void glDisableVertexAttribArray(GLuint index);
void glEnableVertexAttribArray(GLuint index);
void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params);
void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params);
void glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer);
void glUniform1f(GLint location, GLfloat x);
void glUniform1fv(GLint location, GLsizei count, const GLfloat* v);
void glUniform1i(GLint location, GLint x);
void glUniform1iv(GLint location, GLsizei count, const GLint* v);
void glUniform2f(GLint location, GLfloat x, GLfloat y);
void glUniform2fv(GLint location, GLsizei count, const GLfloat* v);
void glUniform2i(GLint location, GLint x, GLint y);
void glUniform2iv(GLint location, GLsizei count, const GLint* v);
void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z);
void glUniform3fv(GLint location, GLsizei count, const GLfloat* v);
void glUniform3i(GLint location, GLint x, GLint y, GLint z);
void glUniform3iv(GLint location, GLsizei count, const GLint* v);
void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void glUniform4fv(GLint location, GLsizei count, const GLfloat* v);
void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w);
void glUniform4iv(GLint location, GLsizei count, const GLint* v);
void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
void glAttachShader(GLuint program, GLuint shader);
void glBindAttribLocation(GLuint program, GLuint index, const GLchar* name);
void glCompileShader(GLuint shader);
GLuint glCreateProgram(void);
GLuint glCreateShader(GLenum type);
void glDeleteProgram(GLuint program);
void glDeleteShader(GLuint shader);
void glDetachShader(GLuint program, GLuint shader);
void glLinkProgram(GLuint program);
void glUseProgram(GLuint program);
void glValidateProgram(GLuint program);
void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
int glGetAttribLocation(GLuint program, const GLchar* name);
void glGetProgramiv(GLuint program, GLenum pname, GLint* params);
void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
void glGetShaderiv(GLuint shader, GLenum pname, GLint* params);
void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
void glGetUniformfv(GLuint program, GLint location, GLfloat* params);
void glGetUniformiv(GLuint program, GLint location, GLint* params);
int glGetUniformLocation(GLuint program, const GLchar* name);
void glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
# The following are not used by GLDispatch but by GLESv2Dispatch
void glBindFramebuffer(GLenum target, GLuint framebuffer);
void glGenFramebuffers(GLsizei n, GLuint* framebuffers);
void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
GLenum glCheckFramebufferStatus(GLenum target);
void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers);
GLboolean glIsRenderbuffer(GLuint renderbuffer);
void glBindRenderbuffer(GLenum target, GLuint renderbuffer);
void glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers);
void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers);
void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params);
void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);

View file

@ -0,0 +1,18 @@
!gles3_only
# GLES 3.x functions required by the translator library.
# Right now, this is only use to get glGetStringi() from the host GL library
# in order to deal with the fact that glGetString(GL_EXTENSIONS) is obsolete
# in OpenGL 3.0, and some drivers don't implement it anymore (i.e. the
# function just returns NULL).
%#include <GLES/gl.h>
%
%// Used to avoid adding GLES3/gl3.h to our headers.
%#ifndef GL_NUM_EXTENSIONS
%#define GL_NUM_EXTENSIONS 0x821D
%#endif
%typedef const GLubyte* GLconstubyteptr;
GLconstubyteptr glGetStringi(GLenum name, GLint index);

View file

@ -0,0 +1,74 @@
!gles_common
# Functions common to both GLES 1.x and 2.0
%#include <GLES/gl.h>
%// Return types must be single words, see GLDispatch.cpp
%typedef const GLubyte* GLconstubyteptr;
void glActiveTexture( GLenum texture );
void glBindBuffer(GLenum target, GLuint buffer);
void glBindTexture(GLenum target, GLuint texture);
void glBlendFunc(GLenum sfactor, GLenum dfactor);
void glBlendEquation( GLenum mode );
void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
void glClear(GLbitfield mask);
void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void glClearDepth(GLclampd depth);
void glClearStencil(GLint s);
void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
void glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data );
void glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data );
void glCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
void glCullFace(GLenum mode);
void glDeleteBuffers(GLsizei n, const GLuint *buffers);
void glDeleteTextures(GLsizei n, const GLuint *textures);
void glDepthFunc(GLenum func);
void glDepthMask(GLboolean flag);
void glDepthRange(GLclampd zNear, GLclampd zFar);
void glDisable(GLenum cap);
void glDrawArrays(GLenum mode, GLint first, GLsizei count);
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
void glEnable(GLenum cap);
void glFinish(void);
void glFlush(void);
void glFrontFace(GLenum mode);
void glGenBuffers(GLsizei n, GLuint *buffers);
void glGenTextures(GLsizei n, GLuint *textures);
void glGetBooleanv(GLenum pname, GLboolean *params);
void glGetBufferParameteriv(GLenum buffer, GLenum parameter, GLint *value);
GLenum glGetError(void);
void glGetFloatv(GLenum pname, GLfloat *params);
void glGetIntegerv(GLenum pname, GLint *params);
GLconstubyteptr glGetString(GLenum name);
void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
void glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params);
void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params);
void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params);
void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params);
void glHint(GLenum target, GLenum mode);
GLboolean glIsBuffer(GLuint buffer);
GLboolean glIsEnabled(GLenum cap);
GLboolean glIsTexture(GLuint texture);
void glLineWidth(GLfloat width);
void glPolygonOffset(GLfloat factor, GLfloat units);
void glPixelStorei(GLenum pname, GLint param);
void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
void glSampleCoverage( GLclampf value, GLboolean invert );
void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
void glStencilFunc(GLenum func, GLint ref, GLuint mask);
void glStencilMask(GLuint mask);
void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass);
void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void glTexParameteri(GLenum target, GLenum pname, GLint param);
void glTexParameteriv(GLenum target, GLenum pname, const GLint *params);
void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
void glPushAttrib( GLbitfield mask );
void glPushClientAttrib( GLbitfield mask );
void glPopAttrib( void );
void glPopClientAttrib( void );

View file

@ -0,0 +1,24 @@
!gles_extensions
# Common GLES 1.x / 2.0 extension functions
GLboolean glIsRenderbufferEXT(GLuint renderbuffer);
void glBindRenderbufferEXT(GLenum target, GLuint renderbuffer);
void glDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers);
void glGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers);
void glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params);
GLboolean glIsFramebufferEXT(GLuint framebuffer);
void glBindFramebufferEXT(GLenum target, GLuint framebuffer);
void glDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers);
void glGenFramebuffersEXT(GLsizei n, GLuint *framebuffers);
GLenum glCheckFramebufferStatusEXT(GLenum target);
void glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
void glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
void glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
void glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
void glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params);
void glGenerateMipmapEXT(GLenum target);
# The following extensions are used by GLESv1Dispatch and GLESv2Dispatch, but not by GLDispatch
void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image);
void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);

View file

@ -0,0 +1,26 @@
# The list of EGL functions used by libOpenglRender, without extensions.
# This is only a subset of the full EGL API.
!Render_EGL
%#include <EGL/egl.h>
EGLint eglGetError(void);
EGLDisplay eglGetDisplay(EGLNativeDisplayType dpy);
EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor);
char* eglQueryString(EGLDisplay dpy, EGLint id);
EGLBoolean eglGetConfigs(EGLDisplay display, EGLConfig* configs, EGLint config_size, EGLint* num_config);
EGLBoolean eglChooseConfig(EGLDisplay display, const EGLint* attribs, EGLConfig* configs, EGLint config_size, EGLint* num_config);
EGLBoolean eglGetConfigAttrib(EGLDisplay display, EGLConfig config, EGLint attribute, EGLint* value);
EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, EGLNativeWindowType native_window, const EGLint* attrib_list);
EGLSurface eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, const EGLint* attrib_list);
EGLBoolean eglDestroySurface(EGLDisplay display, EGLSurface surface);
EGLBoolean eglBindAPI(EGLenum api);
EGLenum eglQueryAPI(void);
EGLBoolean eglReleaseThread(void);
EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, const EGLint* attrib_list);
EGLBoolean eglDestroyContext(EGLDisplay display, EGLContext context);
EGLBoolean eglMakeCurrent(EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context);
EGLContext eglGetCurrentContext(void);
EGLSurface eglGetCurrentSurface(EGLint readdraw);
EGLBoolean eglSwapBuffers(EGLDisplay display, EGLSurface surface);
void* eglGetProcAddress(const char* function_name);

View file

@ -0,0 +1,11 @@
# The list of EGL extension functions used by libOpenglRender.
# This is only a subset of the full EGL API.
!Render_EGL_extensions
%#include <EGL/egl.h>
%#define EGL_EGLEXT_PROTOTYPES
%#include <EGL/eglext.h>
EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list);
EGLBoolean eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image);

View file

@ -0,0 +1,70 @@
LOCAL_PATH := $(call my-dir)
host_OS_SRCS :=
host_common_LDLIBS :=
ifeq ($(BUILD_TARGET_OS),linux)
host_OS_SRCS = NativeSubWindow_x11.cpp
host_common_LDLIBS += -lX11 -lrt
endif
ifeq ($(BUILD_TARGET_OS),darwin)
host_OS_SRCS = NativeSubWindow_cocoa.m
host_common_LDLIBS += -Wl,-framework,AppKit
endif
ifeq ($(BUILD_TARGET_OS),windows)
host_OS_SRCS = NativeSubWindow_win32.cpp
host_common_LDLIBS += -lgdi32
endif
host_common_SRC_FILES := \
$(host_OS_SRCS) \
ColorBuffer.cpp \
FbConfig.cpp \
FrameBuffer.cpp \
ReadBuffer.cpp \
RenderContext.cpp \
RenderControl.cpp \
RenderServer.cpp \
RenderThread.cpp \
RenderThreadInfo.cpp \
render_api.cpp \
RenderWindow.cpp \
SocketStream.cpp \
TcpStream.cpp \
TextureDraw.cpp \
TextureResize.cpp \
TimeUtils.cpp \
WindowSurface.cpp \
ifeq ($(BUILD_TARGET_OS),windows)
host_common_SRC_FILES += Win32PipeStream.cpp
host_common_LDLIBS += -lws2_32 -lpsapi
else
host_common_SRC_FILES += UnixStream.cpp
endif
### host libOpenglRender #################################################
$(call emugl-begin-host-shared-library,lib$(BUILD_TARGET_SUFFIX)OpenglRender)
$(call emugl-import,libGLESv1_dec libGLESv2_dec lib_renderControl_dec libOpenglCodecCommon)
LOCAL_LDLIBS += $(host_common_LDLIBS)
LOCAL_SRC_FILES := $(host_common_SRC_FILES)
$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include)
$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
# use Translator's egl/gles headers
LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include
LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/libOpenGLESDispatch
LOCAL_STATIC_LIBRARIES += libemugl_common
LOCAL_STATIC_LIBRARIES += libOpenGLESDispatch
LOCAL_SYMBOL_FILE := render_api.entries
$(call emugl-export,CFLAGS,$(EMUGL_USER_CFLAGS))
$(call emugl-end-module)

View file

@ -0,0 +1,37 @@
set(SOURCES
ColorBuffer.cpp
FbConfig.cpp
FrameBuffer.cpp
NativeSubWindow_mir.cpp
ReadBuffer.cpp
RenderContext.cpp
RenderControl.cpp
RenderServer.cpp
RenderThread.cpp
RenderThreadInfo.cpp
render_api.cpp
RenderWindow.cpp
SocketStream.cpp
TcpStream.cpp
TextureDraw.cpp
TextureResize.cpp
TimeUtils.cpp
UnixStream.cpp
WindowSurface.cpp)
include_directories(BEFORE
${MIRCLIENT_INCLUDE_DIRS})
add_library(OpenglRender ${SOURCES})
target_link_libraries(OpenglRender
emugl_common
GLESv1_dec
GLESv2_dec
renderControl_dec
OpenGLESDispatch
OpenglCodecCommon
mir_support
${EGL_LDFLAGS}
${EGL_LIBRARIES}
${MIRCLIENT_LDFLAGS}
${MIRCLIENT_LIBRARIES})

View file

@ -0,0 +1,396 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ColorBuffer.h"
#include "DispatchTables.h"
#include "RenderThreadInfo.h"
#include "TextureDraw.h"
#include "TextureResize.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include <stdio.h>
namespace {
// <EGL/egl.h> defines many types as 'void*' while they're really
// implemented as unsigned integers. These convenience template functions
// help casting between them safely without generating compiler warnings.
inline void* SafePointerFromUInt(unsigned int handle) {
return (void*)(uintptr_t)(handle);
}
inline unsigned int SafeUIntFromPointer(const void* ptr) {
#if 1
// Ignore the assert below to avoid crashing when running older
// system images, which might have buggy encoder libraries. Print
// an error message though.
if ((uintptr_t)(ptr) != (unsigned int)(uintptr_t)(ptr)) {
fprintf(stderr, "EmuGL:WARNING: bad generic pointer %p\n", ptr);
}
#else
// Assertion error if the pointer contains a value that does not fit
// in an unsigned integer!
assert((uintptr_t)(ptr) == (unsigned int)(uintptr_t)(ptr));
#endif
return (unsigned int)(uintptr_t)(ptr);
}
// Lazily create and bind a framebuffer object to the current host context.
// |fbo| is the address of the framebuffer object name.
// |tex| is the name of a texture that is attached to the framebuffer object
// on creation only. I.e. all rendering operations will target it.
// returns true in case of success, false on failure.
bool bindFbo(GLuint* fbo, GLuint tex) {
if (*fbo) {
// fbo already exist - just bind
s_gles2.glBindFramebuffer(GL_FRAMEBUFFER, *fbo);
return true;
}
s_gles2.glGenFramebuffers(1, fbo);
s_gles2.glBindFramebuffer(GL_FRAMEBUFFER, *fbo);
s_gles2.glFramebufferTexture2D(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0_OES,
GL_TEXTURE_2D, tex, 0);
GLenum status = s_gles2.glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE_OES) {
ERR("ColorBuffer::bindFbo: FBO not complete: %#x\n", status);
s_gles2.glBindFramebuffer(GL_FRAMEBUFFER, 0);
s_gles2.glDeleteFramebuffers(1, fbo);
*fbo = 0;
return false;
}
return true;
}
void unbindFbo() {
s_gles2.glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
// Helper class to use a ColorBuffer::Helper context.
// Usage is pretty simple:
//
// {
// ScopedHelperContext context(m_helper);
// if (!context.isOk()) {
// return false; // something bad happened.
// }
// .... do something ....
// } // automatically calls m_helper->teardownContext();
//
class ScopedHelperContext {
public:
ScopedHelperContext(ColorBuffer::Helper* helper) : mHelper(helper) {
if (!helper->setupContext()) {
mHelper = NULL;
}
}
bool isOk() const { return mHelper != NULL; }
~ScopedHelperContext() {
release();
}
void release() {
if (mHelper) {
mHelper->teardownContext();
mHelper = NULL;
}
}
private:
ColorBuffer::Helper* mHelper;
};
} // namespace
// static
ColorBuffer* ColorBuffer::create(EGLDisplay p_display,
int p_width,
int p_height,
GLenum p_internalFormat,
bool has_eglimage_texture_2d,
Helper* helper) {
GLenum texInternalFormat = 0;
printf("Creating new color buffer width %i height %i\n", p_width, p_height);
switch (p_internalFormat) {
case GL_RGB:
case GL_RGB565_OES:
texInternalFormat = GL_RGB;
break;
case GL_RGBA:
case GL_RGB5_A1_OES:
case GL_RGBA4_OES:
texInternalFormat = GL_RGBA;
break;
default:
return NULL;
break;
}
ScopedHelperContext context(helper);
if (!context.isOk()) {
return NULL;
}
ColorBuffer *cb = new ColorBuffer(p_display, helper);
s_gles2.glGenTextures(1, &cb->m_tex);
s_gles2.glBindTexture(GL_TEXTURE_2D, cb->m_tex);
int nComp = (texInternalFormat == GL_RGB ? 3 : 4);
char* zBuff = static_cast<char*>(::calloc(nComp * p_width * p_height, 1));
s_gles2.glTexImage2D(GL_TEXTURE_2D,
0,
texInternalFormat,
p_width,
p_height,
0,
texInternalFormat,
GL_UNSIGNED_BYTE,
zBuff);
::free(zBuff);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//
// create another texture for that colorbuffer for blit
//
s_gles2.glGenTextures(1, &cb->m_blitTex);
s_gles2.glBindTexture(GL_TEXTURE_2D, cb->m_blitTex);
s_gles2.glTexImage2D(GL_TEXTURE_2D,
0,
texInternalFormat,
p_width,
p_height,
0,
texInternalFormat,
GL_UNSIGNED_BYTE,
NULL);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
cb->m_width = p_width;
cb->m_height = p_height;
cb->m_internalFormat = texInternalFormat;
if (has_eglimage_texture_2d) {
cb->m_eglImage = s_egl.eglCreateImageKHR(
p_display,
s_egl.eglGetCurrentContext(),
EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)SafePointerFromUInt(cb->m_tex),
NULL);
cb->m_blitEGLImage = s_egl.eglCreateImageKHR(
p_display,
s_egl.eglGetCurrentContext(),
EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)SafePointerFromUInt(cb->m_blitTex),
NULL);
}
cb->m_resizer = new TextureResize(p_width, p_height);
return cb;
}
ColorBuffer::ColorBuffer(EGLDisplay display, Helper* helper) :
m_tex(0),
m_blitTex(0),
m_eglImage(NULL),
m_blitEGLImage(NULL),
m_fbo(0),
m_internalFormat(0),
m_display(display),
m_helper(helper) {}
ColorBuffer::~ColorBuffer() {
ScopedHelperContext context(m_helper);
if (m_blitEGLImage) {
s_egl.eglDestroyImageKHR(m_display, m_blitEGLImage);
}
if (m_eglImage) {
s_egl.eglDestroyImageKHR(m_display, m_eglImage);
}
if (m_fbo) {
s_gles2.glDeleteFramebuffers(1, &m_fbo);
}
GLuint tex[2] = {m_tex, m_blitTex};
s_gles2.glDeleteTextures(2, tex);
delete m_resizer;
}
void ColorBuffer::readPixels(int x,
int y,
int width,
int height,
GLenum p_format,
GLenum p_type,
void* pixels) {
ScopedHelperContext context(m_helper);
if (!context.isOk()) {
return;
}
if (bindFbo(&m_fbo, m_tex)) {
s_gles2.glReadPixels(x, y, width, height, p_format, p_type, pixels);
unbindFbo();
}
}
void ColorBuffer::subUpdate(int x,
int y,
int width,
int height,
GLenum p_format,
GLenum p_type,
void* pixels) {
ScopedHelperContext context(m_helper);
if (!context.isOk()) {
return;
}
s_gles2.glBindTexture(GL_TEXTURE_2D, m_tex);
s_gles2.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
s_gles2.glTexSubImage2D(
GL_TEXTURE_2D, 0, x, y, width, height, p_format, p_type, pixels);
}
bool ColorBuffer::blitFromCurrentReadBuffer()
{
RenderThreadInfo *tInfo = RenderThreadInfo::get();
if (!tInfo->currContext.Ptr()) {
// no Current context
return false;
}
// Copy the content of the current read surface into m_blitEGLImage.
// This is done by creating a temporary texture, bind it to the EGLImage
// then call glCopyTexSubImage2D().
GLuint tmpTex;
GLint currTexBind;
if (tInfo->currContext->isGL2()) {
s_gles2.glGetIntegerv(GL_TEXTURE_BINDING_2D, &currTexBind);
s_gles2.glGenTextures(1,&tmpTex);
s_gles2.glBindTexture(GL_TEXTURE_2D, tmpTex);
s_gles2.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_blitEGLImage);
s_gles2.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0,
m_width, m_height);
s_gles2.glDeleteTextures(1, &tmpTex);
s_gles2.glBindTexture(GL_TEXTURE_2D, currTexBind);
}
else {
s_gles1.glGetIntegerv(GL_TEXTURE_BINDING_2D, &currTexBind);
s_gles1.glGenTextures(1,&tmpTex);
s_gles1.glBindTexture(GL_TEXTURE_2D, tmpTex);
s_gles1.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_blitEGLImage);
s_gles1.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0,
m_width, m_height);
s_gles1.glDeleteTextures(1, &tmpTex);
s_gles1.glBindTexture(GL_TEXTURE_2D, currTexBind);
}
ScopedHelperContext context(m_helper);
if (!context.isOk()) {
return false;
}
if (!bindFbo(&m_fbo, m_tex)) {
return false;
}
// Save current viewport and match it to the current colorbuffer size.
GLint vport[4] = { 0, };
s_gles2.glGetIntegerv(GL_VIEWPORT, vport);
s_gles2.glViewport(0, 0, m_width, m_height);
// render m_blitTex
m_helper->getTextureDraw()->draw(m_blitTex, 0., 0, 0);
// Restore previous viewport.
s_gles2.glViewport(vport[0], vport[1], vport[2], vport[3]);
unbindFbo();
return true;
}
bool ColorBuffer::bindToTexture() {
if (!m_eglImage) {
return false;
}
RenderThreadInfo *tInfo = RenderThreadInfo::get();
if (!tInfo->currContext.Ptr()) {
return false;
}
if (tInfo->currContext->isGL2()) {
s_gles2.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_eglImage);
}
else {
s_gles1.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, m_eglImage);
}
return true;
}
bool ColorBuffer::bindToRenderbuffer() {
if (!m_eglImage) {
return false;
}
RenderThreadInfo *tInfo = RenderThreadInfo::get();
if (!tInfo->currContext.Ptr()) {
return false;
}
if (tInfo->currContext->isGL2()) {
s_gles2.glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER_OES, m_eglImage);
}
else {
s_gles1.glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER_OES, m_eglImage);
}
return true;
}
bool ColorBuffer::post(float rotation, float dx, float dy) {
// NOTE: Do not call m_helper->setupContext() here!
return m_helper->getTextureDraw()->draw(m_resizer->update(m_tex), rotation, dx, dy);
}
void ColorBuffer::readback(unsigned char* img) {
ScopedHelperContext context(m_helper);
if (!context.isOk()) {
return;
}
if (bindFbo(&m_fbo, m_tex)) {
s_gles2.glReadPixels(
0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, img);
unbindFbo();
}
}

View file

@ -0,0 +1,161 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBRENDER_COLORBUFFER_H
#define _LIBRENDER_COLORBUFFER_H
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES/gl.h>
#include "emugl/common/smart_ptr.h"
#include <memory>
class TextureDraw;
class TextureResize;
// A class used to model a guest color buffer, and used to implement several
// related things:
//
// - Every gralloc native buffer with HW read or write requirements will
// allocate a host ColorBuffer instance. When gralloc_lock() is called,
// the guest will use ColorBuffer::readPixels() to read the current content
// of the buffer. When gralloc_unlock() is later called, it will call
// ColorBuffer::subUpdate() to send the updated pixels.
//
// - Every guest window EGLSurface is implemented by a host PBuffer
// (see WindowSurface.h) that can have a ColorBuffer instance attached to
// it (through WindowSurface::attachColorBuffer()). When such an attachment
// exists, WindowSurface::flushColorBuffer() will copy the PBuffer's
// pixel data into the ColorBuffer. The latter can then be displayed
// in the client's UI sub-window with ColorBuffer::post().
//
// - Guest EGLImages are implemented as native gralloc buffers too.
// The guest glEGLImageTargetTexture2DOES() implementations will end up
// calling ColorBuffer::bindToTexture() to bind the current context's
// GL_TEXTURE_2D to the buffer. Similarly, the guest versions of
// glEGLImageTargetRenderbufferStorageOES() will end up calling
// ColorBuffer::bindToRenderbuffer().
//
// This forces the implementation to use a host EGLImage to implement each
// ColorBuffer.
//
// As an additional twist.
class ColorBuffer {
public:
// Helper interface class used during ColorBuffer operations. This is
// introduced to remove coupling from the FrameBuffer class implementation.
class Helper {
public:
Helper() {}
virtual ~Helper() {}
virtual bool setupContext() = 0;
virtual void teardownContext() = 0;
virtual TextureDraw* getTextureDraw() const = 0;
};
// Create a new ColorBuffer instance.
// |p_display| is the host EGLDisplay handle.
// |p_width| and |p_height| are the buffer's dimensions in pixels.
// |p_internalFormat| is the internal pixel format to use, valid values
// are: GL_RGB, GL_RGB565, GL_RGBA, GL_RGB5_A1_OES and GL_RGBA4_OES.
// Implementation is free to use something else though.
// |has_eglimage_texture_2d| should be true iff the display supports
// the EGL_KHR_gl_texture_2D_image extension.
// Returns NULL on failure.
static ColorBuffer* create(EGLDisplay p_display,
int p_width,
int p_height,
GLenum p_internalFormat,
bool has_eglimage_texture_2d,
Helper* helper);
// Destructor.
~ColorBuffer();
// Return ColorBuffer width and height in pixels
GLuint getWidth() const { return m_width; }
GLuint getHeight() const { return m_height; }
// Read the ColorBuffer instance's pixel values into host memory.
void readPixels(int x,
int y,
int width,
int height,
GLenum p_format,
GLenum p_type,
void *pixels);
// Update the ColorBuffer instance's pixel values from host memory.
void subUpdate(int x,
int y,
int width,
int height,
GLenum p_format,
GLenum p_type,
void *pixels);
// Draw a ColorBuffer instance, i.e. blit it to the current guest
// framebuffer object / window surface. This doesn't display anything.
bool draw();
// Post this ColorBuffer to the host native sub-window.
// |rotation| is the rotation angle in degrees, clockwise in the GL
// coordinate space.
bool post(float rotation, float dx, float dy);
// Bind the current context's EGL_TEXTURE_2D texture to this ColorBuffer's
// EGLImage. This is intended to implement glEGLImageTargetTexture2DOES()
// for all GLES versions.
bool bindToTexture();
// Bind the current context's EGL_RENDERBUFFER_OES render buffer to this
// ColorBuffer's EGLImage. This is intended to implement
// glEGLImageTargetRenderbufferStorageOES() for all GLES versions.
bool bindToRenderbuffer();
// Copy the content of the current context's read surface to this
// ColorBuffer. This is used from WindowSurface::flushColorBuffer().
// Return true on success, false on failure (e.g. no current context).
bool blitFromCurrentReadBuffer();
// Read the content of the whole ColorBuffer as 32-bit RGBA pixels.
// |img| must be a buffer large enough (i.e. width * height * 4).
void readback(unsigned char* img);
private:
ColorBuffer(); // no default constructor.
explicit ColorBuffer(EGLDisplay display, Helper* helper);
private:
GLuint m_tex;
GLuint m_blitTex;
EGLImageKHR m_eglImage;
EGLImageKHR m_blitEGLImage;
GLuint m_width;
GLuint m_height;
GLuint m_fbo;
GLenum m_internalFormat;
EGLDisplay m_display;
Helper* m_helper;
TextureResize * m_resizer;
};
typedef emugl::SmartPtr<ColorBuffer> ColorBufferPtr;
#endif

View file

@ -0,0 +1,22 @@
/*
* Copyright (C) 2011-2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "OpenGLESDispatch/GLESv1Dispatch.h"
#include "OpenGLESDispatch/GLESv2Dispatch.h"
extern GLESv2Dispatch s_gles2;
extern GLESv1Dispatch s_gles1;

View file

@ -0,0 +1,275 @@
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "FbConfig.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include <stdio.h>
#include <string.h>
namespace {
#define E(...) fprintf(stderr, __VA_ARGS__)
const GLuint kConfigAttributes[] = {
EGL_DEPTH_SIZE, // must be first - see getDepthSize()
EGL_STENCIL_SIZE, // must be second - see getStencilSize()
EGL_RENDERABLE_TYPE,// must be third - see getRenderableType()
EGL_SURFACE_TYPE, // must be fourth - see getSurfaceType()
EGL_CONFIG_ID, // must be fifth - see chooseConfig()
EGL_BUFFER_SIZE,
EGL_ALPHA_SIZE,
EGL_BLUE_SIZE,
EGL_GREEN_SIZE,
EGL_RED_SIZE,
EGL_CONFIG_CAVEAT,
EGL_LEVEL,
EGL_MAX_PBUFFER_HEIGHT,
EGL_MAX_PBUFFER_PIXELS,
EGL_MAX_PBUFFER_WIDTH,
EGL_NATIVE_RENDERABLE,
EGL_NATIVE_VISUAL_ID,
EGL_NATIVE_VISUAL_TYPE,
EGL_SAMPLES,
EGL_SAMPLE_BUFFERS,
EGL_TRANSPARENT_TYPE,
EGL_TRANSPARENT_BLUE_VALUE,
EGL_TRANSPARENT_GREEN_VALUE,
EGL_TRANSPARENT_RED_VALUE,
EGL_BIND_TO_TEXTURE_RGB,
EGL_BIND_TO_TEXTURE_RGBA,
EGL_MIN_SWAP_INTERVAL,
EGL_MAX_SWAP_INTERVAL,
EGL_LUMINANCE_SIZE,
EGL_ALPHA_MASK_SIZE,
EGL_COLOR_BUFFER_TYPE,
//EGL_MATCH_NATIVE_PIXMAP,
EGL_CONFORMANT
};
const size_t kConfigAttributesLen =
sizeof(kConfigAttributes) / sizeof(kConfigAttributes[0]);
bool isCompatibleHostConfig(EGLConfig config, EGLDisplay display) {
// Filter out configs which do not support pbuffers, since they
// are used to implement window surfaces.
EGLint surfaceType;
s_egl.eglGetConfigAttrib(
display, config, EGL_SURFACE_TYPE, &surfaceType);
if (!(surfaceType & EGL_PBUFFER_BIT)) {
return false;
}
// Filter out configs that do not support RGB pixel values.
EGLint redSize = 0, greenSize = 0, blueSize = 0, alphaSize = 0;
s_egl.eglGetConfigAttrib(
display, config,EGL_RED_SIZE, &redSize);
s_egl.eglGetConfigAttrib(
display, config, EGL_GREEN_SIZE, &greenSize);
s_egl.eglGetConfigAttrib(
display, config, EGL_BLUE_SIZE, &blueSize);
s_egl.eglGetConfigAttrib(
display, config, EGL_ALPHA_SIZE, &alphaSize);
if (!redSize || !greenSize || !blueSize || !alphaSize) {
return false;
}
return true;
}
} // namespace
FbConfig::~FbConfig() {
delete [] mAttribValues;
}
FbConfig::FbConfig(EGLConfig hostConfig, EGLDisplay hostDisplay) :
mEglConfig(hostConfig), mAttribValues(NULL) {
mAttribValues = new GLint[kConfigAttributesLen];
for (size_t i = 0; i < kConfigAttributesLen; ++i) {
mAttribValues[i] = 0;
s_egl.eglGetConfigAttrib(hostDisplay,
hostConfig,
kConfigAttributes[i],
&mAttribValues[i]);
// This implementation supports guest window surfaces by wrapping
// them around host Pbuffers, so always report it to the guest.
if (kConfigAttributes[i] == EGL_SURFACE_TYPE) {
mAttribValues[i] |= EGL_WINDOW_BIT;
}
}
}
FbConfigList::FbConfigList(EGLDisplay display) :
mCount(0), mConfigs(NULL), mDisplay(display) {
if (display == EGL_NO_DISPLAY) {
E("%s: Invalid display value %p (EGL_NO_DISPLAY)\n",
__FUNCTION__, (void*)display);
return;
}
EGLint numHostConfigs = 0;
if (!s_egl.eglGetConfigs(display, NULL, 0, &numHostConfigs)) {
E("%s: Could not get number of host EGL configs\n", __FUNCTION__);
return;
}
EGLConfig* hostConfigs = new EGLConfig[numHostConfigs];
s_egl.eglGetConfigs(display, hostConfigs, numHostConfigs, &numHostConfigs);
mConfigs = new FbConfig*[numHostConfigs];
for (EGLint i = 0; i < numHostConfigs; ++i) {
// Filter out configs that are not compatible with our implementation.
if (!isCompatibleHostConfig(hostConfigs[i], display)) {
continue;
}
mConfigs[mCount] = new FbConfig(hostConfigs[i], display);
mCount++;
}
delete [] hostConfigs;
}
FbConfigList::~FbConfigList() {
for (int n = 0; n < mCount; ++n) {
delete mConfigs[n];
}
delete [] mConfigs;
}
int FbConfigList::chooseConfig(const EGLint* attribs,
EGLint* configs,
EGLint configsSize) const {
EGLint numHostConfigs = 0;
if (!s_egl.eglGetConfigs(mDisplay, NULL, 0, &numHostConfigs)) {
E("%s: Could not get number of host EGL configs\n", __FUNCTION__);
return 0;
}
EGLConfig* matchedConfigs = new EGLConfig[numHostConfigs];
// If EGL_SURFACE_TYPE appears in |attribs|, the value passed to
// eglChooseConfig should be forced to EGL_PBUFFER_BIT because that's
// what it used by the current implementation, exclusively. This forces
// the rewrite of |attribs| into a new array.
bool hasSurfaceType = false;
bool mustReplaceSurfaceType = false;
int numAttribs = 0;
while (attribs[numAttribs] != EGL_NONE) {
if (attribs[numAttribs] == EGL_SURFACE_TYPE) {
hasSurfaceType = true;
if (attribs[numAttribs + 1] != EGL_PBUFFER_BIT) {
mustReplaceSurfaceType = true;
}
}
numAttribs += 2;
}
EGLint* newAttribs = NULL;
if (mustReplaceSurfaceType) {
// There is at least on EGL_SURFACE_TYPE in |attribs|. Copy the
// array and replace all values with EGL_PBUFFER_BIT
newAttribs = new GLint[numAttribs + 1];
memcpy(newAttribs, attribs, numAttribs * sizeof(GLint));
newAttribs[numAttribs] = EGL_NONE;
for (int n = 0; n < numAttribs; n += 2) {
if (newAttribs[n] == EGL_SURFACE_TYPE) {
newAttribs[n + 1] = EGL_PBUFFER_BIT;
}
}
} else if (!hasSurfaceType) {
// There is no EGL_SURFACE_TYPE in |attribs|, then add one entry
// with the value EGL_PBUFFER_BIT.
newAttribs = new GLint[numAttribs + 3];
memcpy(newAttribs, attribs, numAttribs * sizeof(GLint));
newAttribs[numAttribs] = EGL_SURFACE_TYPE;
newAttribs[numAttribs + 1] = EGL_PBUFFER_BIT;
newAttribs[numAttribs + 2] = EGL_NONE;
}
if (!s_egl.eglChooseConfig(mDisplay,
newAttribs ? newAttribs : attribs,
matchedConfigs,
numHostConfigs,
&numHostConfigs)) {
numHostConfigs = 0;
}
delete [] newAttribs;
int result = 0;
for (int n = 0; n < numHostConfigs; ++n) {
// Don't count or write more than |configsSize| items if |configs|
// is not NULL.
if (configs && configsSize > 0 && result >= configsSize) {
break;
}
// Skip incompatible host configs.
if (!isCompatibleHostConfig(matchedConfigs[n], mDisplay)) {
continue;
}
// Find the FbConfig with the same EGL_CONFIG_ID
EGLint hostConfigId;
s_egl.eglGetConfigAttrib(
mDisplay, matchedConfigs[n], EGL_CONFIG_ID, &hostConfigId);
for (int k = 0; k < mCount; ++k) {
int guestConfigId = mConfigs[k]->getConfigId();
if (guestConfigId == hostConfigId) {
// There is a match. Write it to |configs| if it is not NULL.
if (configs && result < configsSize) {
configs[result] = (uint32_t)k;
}
result ++;
break;
}
}
}
delete [] matchedConfigs;
return result;
}
void FbConfigList::getPackInfo(EGLint* numConfigs,
EGLint* numAttributes) const {
if (numConfigs) {
*numConfigs = mCount;
}
if (numAttributes) {
*numAttributes = static_cast<EGLint>(kConfigAttributesLen);
}
}
EGLint FbConfigList::packConfigs(GLuint bufferByteSize, GLuint* buffer) const {
GLuint numAttribs = static_cast<GLuint>(kConfigAttributesLen);
GLuint kGLuintSize = static_cast<GLuint>(sizeof(GLuint));
GLuint neededByteSize = (mCount + 1) * numAttribs * kGLuintSize;
if (!buffer || bufferByteSize < neededByteSize) {
return -neededByteSize;
}
// Write to the buffer the config attribute ids, followed for each one
// of the configs, their values.
memcpy(buffer, kConfigAttributes, kConfigAttributesLen * kGLuintSize);
for (int i = 0; i < mCount; ++i) {
memcpy(buffer + (i + 1) * kConfigAttributesLen,
mConfigs[i]->mAttribValues,
kConfigAttributesLen * kGLuintSize);
}
return mCount;
}

View file

@ -0,0 +1,163 @@
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _LIBRENDER_FB_CONFIG_H
#define _LIBRENDER_FB_CONFIG_H
#include <EGL/egl.h>
#include <GLES/gl.h>
#include <stddef.h>
// A class used to model a guest EGL config.
// This really wraps a host EGLConfig handle, and provides a few cached
// attributes that can be retrieved through direct accessors, like
// getDepthSize().
//
// Each FbConfig is identified by a unique id which is its index in
// an FbConfigList instance (as declared below). It is not related to
// the host EGLConfig value or its EGL_CONFIG_ID.
//
// One doesn't create an FbConfig instance. Instead, create and initialize
// an FbConfigList from the host EGLDisplay, and use its size() and get()
// methods to access it.
class FbConfig {
public:
// Destructor
~FbConfig();
// Retrieve host EGLConfig.
EGLConfig getEglConfig() const { return mEglConfig; }
// Get depth size in bits.
GLuint getDepthSize() const { return getAttribValue(0); }
// Get stencil size in bits.
GLuint getStencilSize() const { return getAttribValue(1); }
// Get renderable type mask.
GLuint getRenderableType() const { return getAttribValue(2); }
// Get surface type mask.
GLuint getSurfaceType() const { return getAttribValue(3); }
// Get the EGL_CONFIG_ID value. This is the same as the one of the
// underlying host EGLConfig handle.
GLint getConfigId() const { return (GLint)getAttribValue(4); }
private:
FbConfig();
FbConfig(FbConfig& other);
explicit FbConfig(EGLConfig hostConfig, EGLDisplay hostDisplay);
friend class FbConfigList;
GLuint getAttribValue(int n) const {
return mAttribValues ? mAttribValues[n] : 0U;
}
EGLConfig mEglConfig;
GLint* mAttribValues;
};
// A class to model the list of FbConfig for a given EGLDisplay, this is
// built from the list of host EGLConfig handles, filtered to only accept
// configs that are useful by the rendering library (e.g. they must support
// PBuffers and RGB pixel values).
//
// Usage is the following:
//
// 1) Create new instance by passing host EGLDisplay value.
//
// 2) Call empty() to check that the list is not empty, which would indicate
// an error during creation.
//
// 3) FbConfig instances are identified by numbers in 0..(N-1) range, where
// N is the result of the size() method.
//
// 4) Convert an FbConfig id into an FbConfig instance with get().
//
// 5) Use getPackInfo() and packConfigs() to retrieve information about
// available configs to the guest.
class FbConfigList {
public:
// Create a new list of FbConfig instance, by querying all compatible
// host configs from |display|. A compatible config is one that supports
// Pbuffers and RGB pixel values.
//
// After construction, call empty() to check if there are items.
// An empty list means there was an error during construction.
explicit FbConfigList(EGLDisplay display);
// Destructor.
~FbConfigList();
// Return true iff the list is empty. true means there was an error
// during construction.
bool empty() const { return mCount == 0; }
// Return the number of FbConfig instances in the list.
// Each instance is identified by a number from 0 to N-1,
// where N is the result of this function.
size_t size() const { return static_cast<size_t>(mCount); }
// Retrieve the FbConfig instance associated with |guestId|,
// which must be an integer between 0 and |size() - 1|. Returns
// NULL in case of failure.
const FbConfig* get(int guestId) const {
if (guestId >= 0 && guestId < mCount) {
return mConfigs[guestId];
} else {
return NULL;
}
}
// Use |attribs| a list of EGL attribute name/values terminated by
// EGL_NONE, to select a set of matching FbConfig instances.
//
// On success, returns the number of matching instances.
// If |configs| is not NULL, it will be populated with the guest IDs
// of the matched FbConfig instances.
//
// |configsSize| is the number of entries in the |configs| array. The
// function will never write more than |configsSize| entries into
// |configsSize|.
EGLint chooseConfig(const EGLint* attribs,
EGLint* configs,
EGLint configsSize) const;
// Retrieve information that can be sent to the guest before packed
// config list information. If |numConfigs| is NULL, then |*numConfigs|
// will be set on return to the number of config instances.
// If |numAttribs| is not NULL, then |*numAttribs| will be set on return
// to the number of attribute values cached by each FbConfig instance.
void getPackInfo(EGLint* mumConfigs, EGLint* numAttribs) const;
// Write the full list information into an array of EGLuint items.
// |buffer| is the output buffer that will receive the data.
// |bufferByteSize| is teh buffer size in bytes.
// On success, this returns
EGLint packConfigs(GLuint bufferByteSize, GLuint* buffer) const;
private:
FbConfigList();
FbConfigList(const FbConfigList& other);
int mCount;
FbConfig** mConfigs;
EGLDisplay mDisplay;
};
#endif // _LIBRENDER_FB_CONFIG_H

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,360 @@
/*
* Copyright (C) 2011-2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBRENDER_FRAMEBUFFER_H
#define _LIBRENDER_FRAMEBUFFER_H
#include "ColorBuffer.h"
#include "emugl/common/mutex.h"
#include "FbConfig.h"
#include "RenderContext.h"
#include "TextureDraw.h"
#include "WindowSurface.h"
#include "OpenglRender/render_api.h"
#include <EGL/egl.h>
#include <map>
#include <stdint.h>
// Type of handles, a.k.a. "object names" in the GL specification.
// These are integers used to uniquely identify a resource of a given type.
typedef uint32_t HandleType;
struct ColorBufferRef {
ColorBufferPtr cb;
uint32_t refcount; // number of client-side references
};
typedef std::map<HandleType, RenderContextPtr> RenderContextMap;
typedef std::map<HandleType, std::pair<WindowSurfacePtr, HandleType> > WindowSurfaceMap;
typedef std::map<HandleType, ColorBufferRef> ColorBufferMap;
// A structure used to list the capabilities of the underlying EGL
// implementation that the FrameBuffer instance depends on.
// |has_eglimage_texture_2d| is true iff the EGL_KHR_gl_texture_2D_image
// extension is supported.
// |has_eglimage_renderbuffer| is true iff the EGL_KHR_gl_renderbuffer_image
// extension is supported.
// |eglMajor| and |eglMinor| are the major and minor version numbers of
// the underlying EGL implementation.
struct FrameBufferCaps {
bool has_eglimage_texture_2d;
bool has_eglimage_renderbuffer;
EGLint eglMajor;
EGLint eglMinor;
};
// The FrameBuffer class holds the global state of the emulation library on
// top of the underlying EGL/GLES implementation. It should probably be
// named "Display" instead of "FrameBuffer".
//
// There is only one global instance, that can be retrieved with getFB(),
// and which must be previously setup by calling initialize().
//
class FrameBuffer {
public:
// Initialize the global instance.
// |width| and |height| are the dimensions of the emulator GPU display
// in pixels. |useSubWindow| is true to indicate that the caller
// will use setupSubWindow() to let EmuGL display the GPU content in its
// own sub-windows. If false, this means the caller will use
// setPostCallback() instead to retrieve the content.
// Returns true on success, false otherwise.
static bool initialize(int width, int height, bool useSubWindow);
// Setup a sub-window to display the content of the emulated GPU
// on-top of an existing UI window. |p_window| is the platform-specific
// parent window handle. |wx|, |wy|, |ww| and |wh| are the
// dimensions in pixels of the sub-window, relative to the parent window's
// coordinate. |fbw| and |fbh| are the dimensions used to initialize
// the framebuffer, which may be different from the dimensions of the
// sub-window (in which case scaling will be applied automatically).
// |dpr| is the device pixel ratio of the monitor, which is needed for
// proper panning on high-density displays (like retina)
// |zRot| is a rotation angle in degrees, (clockwise in the Y-upwards GL
// coordinate space).
//
// If a sub-window already exists, this function updates the subwindow
// and framebuffer properties to match the given values.
//
// Return true on success, false otherwise.
//
// NOTE: This can return false for software-only EGL engines like OSMesa.
bool setupSubWindow(FBNativeWindowType p_window,
int wx, int wy,
int ww, int wh,
int fbw, int fbh, float dpr, float zRot);
// Remove the sub-window created by setupSubWindow(), if any.
// Return true on success, false otherwise.
bool removeSubWindow();
// Finalize the instance.
void finalize();
// Return a pointer to the global instance. initialize() must be called
// previously, or this will return NULL.
static FrameBuffer *getFB() { return s_theFrameBuffer; }
// Return the capabilities of the underlying display.
const FrameBufferCaps &getCaps() const { return m_caps; }
// Return the emulated GPU display width in pixels.
int getWidth() const { return m_framebufferWidth; }
// Return the emulated GPU display height in pixels.
int getHeight() const { return m_framebufferHeight; }
// Return the list of configs available from this display.
const FbConfigList* getConfigs() const { return m_configs; }
// Set a callback that will be called each time the emulated GPU content
// is updated. This can be relatively slow with host-based GPU emulation,
// so only do this when you need to.
void setPostCallback(OnPostFn onPost, void* onPostContext);
// Retrieve the GL strings of the underlying EGL/GLES implementation.
// On return, |*vendor|, |*renderer| and |*version| will point to strings
// that are owned by the instance (and must not be freed by the caller).
void getGLStrings(const char** vendor,
const char** renderer,
const char** version) const {
*vendor = m_glVendor;
*renderer = m_glRenderer;
*version = m_glVersion;
}
// Create a new RenderContext instance for this display instance.
// |p_config| is the index of one of the configs returned by getConfigs().
// |p_share| is either EGL_NO_CONTEXT or the handle of a shared context.
// |p_isGL2| is true to create a GLES 2.x context, or false for a GLES 1.x
// one.
// Return a new handle value, which will be 0 in case of error.
HandleType createRenderContext(
int p_config, HandleType p_share, bool p_isGL2 = false);
// Create a new WindowSurface instance from this display instance.
// |p_config| is the index of one of the configs returned by getConfigs().
// |p_width| and |p_height| are the window dimensions in pixels.
// Return a new handle value, or 0 in case of error.
HandleType createWindowSurface(int p_config, int p_width, int p_height);
// Create a new ColorBuffer instance from this display instance.
// |p_width| and |p_height| are its dimensions in pixels.
// |p_internalFormat| is the pixel format. See ColorBuffer::create() for
// list of valid values. Note that ColorBuffer instances are reference-
// counted. Use openColorBuffer / closeColorBuffer to operate on the
// internal count.
HandleType createColorBuffer(
int p_width, int p_height, GLenum p_internalFormat);
// Call this function when a render thread terminates to destroy all
// the remaining contexts it created. Necessary to avoid leaking host
// contexts when a guest application crashes, for example.
void drainRenderContext();
// Call this function when a render thread terminates to destroy all
// remaining window surfqce it created. Necessary to avoid leaking
// host buffers when a guest application crashes, for example.
void drainWindowSurface();
// Destroy a given RenderContext instance. |p_context| is its handle
// value as returned by createRenderContext().
void DestroyRenderContext(HandleType p_context);
// Destroy a given WindowSurface instance. |p_surcace| is its handle
// value as returned by createWindowSurface().
void DestroyWindowSurface(HandleType p_surface);
// Increment the reference count associated with a given ColorBuffer
// instance. |p_colorbuffer| is its handle value as returned by
// createColorBuffer().
int openColorBuffer(HandleType p_colorbuffer);
// Decrement the reference count associated with a given ColorBuffer
// instance. |p_colorbuffer| is its handle value as returned by
// createColorBuffer(). Note that if the reference count reaches 0,
// the instance is destroyed automatically.
void closeColorBuffer(HandleType p_colorbuffer);
// Equivalent for eglMakeCurrent() for the current display.
// |p_context|, |p_drawSurface| and |p_readSurface| are the handle values
// of the context, the draw surface and the read surface, respectively.
// Returns true on success, false on failure.
// Note: if all handle values are 0, this is an unbind operation.
bool bindContext(HandleType p_context,
HandleType p_drawSurface,
HandleType p_readSurface);
// Attach a ColorBuffer to a WindowSurface instance.
// See the documentation for WindowSurface::setColorBuffer().
// |p_surface| is the target WindowSurface's handle value.
// |p_colorbuffer| is the ColorBuffer handle value.
// Returns true on success, false otherwise.
bool setWindowSurfaceColorBuffer(
HandleType p_surface, HandleType p_colorbuffer);
// Copy the content of a WindowSurface's Pbuffer to its attached
// ColorBuffer. See the documentation for WindowSurface::flushColorBuffer()
// |p_surface| is the target WindowSurface's handle value.
// Returns true on success, false on failure.
bool flushWindowSurfaceColorBuffer(HandleType p_surface);
// Bind the current context's EGL_TEXTURE_2D texture to a ColorBuffer
// instance's EGLImage. This is intended to implement
// glEGLImageTargetTexture2DOES() for all GLES versions.
// |p_colorbuffer| is the ColorBuffer's handle value.
// Returns true on success, false on failure.
bool bindColorBufferToTexture(HandleType p_colorbuffer);
// Bind the current context's EGL_RENDERBUFFER_OES render buffer to this
// ColorBuffer's EGLImage. This is intended to implement
// glEGLImageTargetRenderbufferStorageOES() for all GLES versions.
// |p_colorbuffer| is the ColorBuffer's handle value.
// Returns true on success, false on failure.
bool bindColorBufferToRenderbuffer(HandleType p_colorbuffer);
// Read the content of a given ColorBuffer into client memory.
// |p_colorbuffer| is the ColorBuffer's handle value. Similar
// to glReadPixels(), this can be a slow operation.
// |x|, |y|, |width| and |height| are the position and dimensions of
// a rectangle whose pixel values will be transfered to the host.
// |format| indicates the format of the pixel data, e.g. GL_RGB or GL_RGBA.
// |type| is the type of pixel data, e.g. GL_UNSIGNED_BYTE.
// |pixels| is the address of a caller-provided buffer that will be filled
// with the pixel data.
void readColorBuffer(HandleType p_colorbuffer,
int x, int y, int width, int height,
GLenum format, GLenum type, void *pixels);
// Update the content of a given ColorBuffer from client data.
// |p_colorbuffer| is the ColorBuffer's handle value. Similar
// to glReadPixels(), this can be a slow operation.
// |x|, |y|, |width| and |height| are the position and dimensions of
// a rectangle whose pixel values will be transfered to the GPU
// |format| indicates the format of the pixel data, e.g. GL_RGB or GL_RGBA.
// |type| is the type of pixel data, e.g. GL_UNSIGNED_BYTE.
// |pixels| is the address of a buffer containing the new pixel data.
// Returns true on success, false otherwise.
bool updateColorBuffer(HandleType p_colorbuffer,
int x, int y, int width, int height,
GLenum format, GLenum type, void *pixels);
// Display the content of a given ColorBuffer into the framebuffer's
// sub-window. |p_colorbuffer| is a handle value.
// |needLock| is used to indicate whether the operation requires
// acquiring/releasing the FrameBuffer instance's lock. It should be
// false only when called internally.
bool post(HandleType p_colorbuffer, bool needLock = true);
// Re-post the last ColorBuffer that was displayed through post().
// This is useful if you detect that the sub-window content needs to
// be re-displayed for any reason.
bool repost();
// Return the host EGLDisplay used by this instance.
EGLDisplay getDisplay() const { return m_eglDisplay; }
// Change the rotation of the displayed GPU sub-window.
void setDisplayRotation(float zRot) {
m_zRot = zRot;
repost();
}
// Changes what coordinate of this framebuffer will be displayed at the
// corner of the GPU sub-window. Specifically, |px| and |py| = 0 means
// align the bottom-left of the framebuffer with the bottom-left of the
// sub-window, and |px| and |py| = 1 means align the top right of the
// framebuffer with the top right of the sub-window. Intermediate values
// interpolate between these states.
void setDisplayTranslation(float px, float py) {
// Sanity check the values to ensure they are between 0 and 1
m_px = px > 1 ? 1 : (px < 0 ? 0 : px);
m_py = py > 1 ? 1 : (py < 0 ? 0 : py);
repost();
}
// Return a TextureDraw instance that can be used with this surfaces
// and windows created by this instance.
TextureDraw* getTextureDraw() const { return m_textureDraw; }
HandleType createClientImage(HandleType context, EGLenum target, GLuint buffer);
EGLBoolean destroyClientImage(HandleType image);
// Used internally.
bool bind_locked();
bool unbind_locked();
private:
FrameBuffer(int p_width, int p_height, bool useSubWindow);
~FrameBuffer();
HandleType genHandle();
bool bindSubwin_locked();
private:
static FrameBuffer *s_theFrameBuffer;
static HandleType s_nextHandle;
int m_x;
int m_y;
int m_framebufferWidth;
int m_framebufferHeight;
int m_windowWidth;
int m_windowHeight;
float m_dpr;
bool m_useSubWindow;
emugl::Mutex m_lock;
FbConfigList* m_configs;
FBNativeWindowType m_nativeWindow;
FrameBufferCaps m_caps;
EGLDisplay m_eglDisplay;
RenderContextMap m_contexts;
WindowSurfaceMap m_windows;
ColorBufferMap m_colorbuffers;
ColorBuffer::Helper* m_colorBufferHelper;
EGLSurface m_eglSurface;
EGLContext m_eglContext;
EGLSurface m_pbufSurface;
EGLContext m_pbufContext;
EGLContext m_prevContext;
EGLSurface m_prevReadSurf;
EGLSurface m_prevDrawSurf;
EGLNativeWindowType m_subWin;
TextureDraw* m_textureDraw;
EGLConfig m_eglConfig;
HandleType m_lastPostedColorBuffer;
float m_zRot;
float m_px;
float m_py;
bool m_eglContextInitialized;
int m_statsNumFrames;
long long m_statsStartTime;
bool m_fpsStats;
OnPostFn m_onPost;
void* m_onPostContext;
unsigned char* m_fbImage;
const char* m_glVendor;
const char* m_glRenderer;
const char* m_glVersion;
};
#endif

View file

@ -0,0 +1,70 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NATIVE_SUB_WINDOW_H
#define NATIVE_SUB_WINDOW_H
#include "OpenglRender/render_api_platform_types.h"
#include <EGL/egl.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*SubWindowRepaintCallback)(void*);
// Create a new sub-window that will be used to display the content of the
// emulated GPU on top of the regular UI window.
// |p_window| is the platform-specific handle to the main UI window.
// |x|, |y| is the position sub-window relative to the top-left corner of the
// main window.
// |width| and |height| are the dimensions of the sub-window, as well as of
// the emulated framebuffer.
// |repaint_callback| may be invoked every time the window has to be repainted
// (such as receiving a WM_PAINT event on Windows). If the provided argument is
// NULL, nothing will be invoked.
// |repaint_callback_param| an additional parameter that will be passed to the
// repaint callback when/if it's invoked.
// On success, return a new platform-specific window handle, cast as an
// EGLNativeWindowType. Or 0/NULL in case of failure.
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
int x,
int y,
int width,
int height,
SubWindowRepaintCallback repaint_callback,
void* repaint_callback_param);
// Destroy a sub-window previously created through createSubWindow() above.
void destroySubWindow(EGLNativeWindowType win);
// Moves a sub-window previously created through createSubWindow() above.
// |p_parent_window| is the platform-specific handle to the main UI window.
// |p_sub_window| is the platform-specific handle to the EGL subwindow.
// |x|,|y|,|width|,|height| are the new location and dimensions of the
// subwindow.
int moveSubWindow(FBNativeWindowType p_parent_window,
EGLNativeWindowType p_sub_window,
int x,
int y,
int width,
int height);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,101 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "NativeSubWindow.h"
#include <Cocoa/Cocoa.h>
/*
* EmuGLView inherit from NSView and override the isOpaque
* method to return YES. That prevents drawing of underlying window/view
* when the view needs to be redrawn.
*/
@interface EmuGLView : NSView {
} @end
@implementation EmuGLView
- (BOOL)isOpaque {
return YES;
}
@end
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
int x,
int y,
int width,
int height,
SubWindowRepaintCallback repaint_callback,
void* repaint_callback_param) {
NSWindow* win = (NSWindow *)p_window;
if (!win) {
return NULL;
}
/* (x,y) assume an upper-left origin, but Cocoa uses a lower-left origin */
NSRect content_rect = [win contentRectForFrameRect:[win frame]];
int cocoa_y = (int)content_rect.size.height - (y + height);
NSRect contentRect = NSMakeRect(x, cocoa_y, width, height);
NSView *glView = [[EmuGLView alloc] initWithFrame:contentRect];
if (glView) {
[glView setWantsBestResolutionOpenGLSurface:YES];
[[win contentView] addSubview:glView];
[win makeKeyAndOrderFront:nil];
}
return (EGLNativeWindowType)glView;
}
void destroySubWindow(EGLNativeWindowType win) {
if(win){
NSView *glView = (NSView *)win;
[glView removeFromSuperview];
[glView release];
}
}
int moveSubWindow(FBNativeWindowType p_parent_window,
EGLNativeWindowType p_sub_window,
int x,
int y,
int width,
int height) {
NSWindow *win = (NSWindow *)p_parent_window;
if (!win) {
return 0;
}
NSView *glView = (NSView *)p_sub_window;
if (!glView) {
return 0;
}
/* The view must be removed from the hierarchy to be properly resized */
[glView removeFromSuperview];
/* (x,y) assume an upper-left origin, but Cocoa uses a lower-left origin */
NSRect content_rect = [win contentRectForFrameRect:[win frame]];
int cocoa_y = (int)content_rect.size.height - (y + height);
NSRect newFrame = NSMakeRect(x, cocoa_y, width, height);
[glView setFrame:newFrame];
/* Re-add the sub-window to the view hierarchy */
[[win contentView] addSubview:glView];
[win makeKeyAndOrderFront:nil];
return 1;
}

View file

@ -0,0 +1,201 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define MIR_EGL_PLATFORM
#include "mir_support/shared_state.h"
#include "NativeSubWindow.h"
#include "OpenglCodecCommon/ErrorLog.h"
#include <stdexcept>
#include <string>
#include <map>
#include <mirclient/mir_toolkit/mir_client_library.h>
namespace {
std::map<EGLNativeWindowType,MirSurface*> surfaces;
static const MirDisplayOutput *find_active_output(
const MirDisplayConfiguration *conf)
{
const MirDisplayOutput *output = NULL;
int d;
for (d = 0; d < (int)conf->num_outputs; d++)
{
const MirDisplayOutput *out = conf->outputs + d;
if (out->used &&
out->connected &&
out->num_modes &&
out->current_mode < out->num_modes)
{
output = out;
break;
}
}
return output;
}
}
MirPixelFormat defaultPixelFormatFor(MirConnection *connection)
{
MirPixelFormat format;
unsigned int nformats;
mir_connection_get_available_surface_formats(connection, &format, 1, &nformats);
return format;
}
void handleSurfaceEvent(const MirSurfaceEvent *event) {
MirSurfaceAttrib attrib = mir_surface_event_get_attribute(event);
if (attrib != mir_surface_attrib_visibility)
return;
switch (mir_surface_event_get_attribute(event)) {
case mir_surface_visibility_exposed:
ERR("Surface exposed\n");
break;
case mir_surface_visibility_occluded:
ERR("Surface occluded\n");
break;
default:
break;
}
}
void surfaceEventHandler(MirSurface *surface, MirEvent const *event, void *context) {
switch (mir_event_get_type(event)) {
case mir_event_type_input:
break;
case mir_event_type_surface:
handleSurfaceEvent(mir_event_get_surface_event(event));
break;
case mir_event_type_resize:
{
MirResizeEvent const *resize_event = mir_event_get_resize_event(event);
ERR("Resized to %dx%d\n",
mir_resize_event_get_width(resize_event),
mir_resize_event_get_height(resize_event));
}
break;
case mir_event_type_close_surface:
break;
case mir_event_type_surface_output:
{
MirSurfaceOutputEvent const *output_event = mir_event_get_surface_output_event(event);
ERR("dpi %i output id %d\n",
mir_surface_output_event_get_dpi(output_event),
mir_surface_output_event_get_output_id(output_event));
}
break;
default:
break;
}
}
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
int x,
int y,
int width,
int height,
SubWindowRepaintCallback repaint_callback,
void* repaint_callback_param) {
(void) p_window;
(void) x;
(void) y;
(void) width;
(void) height;
(void) repaint_callback;
(void) repaint_callback_param;
mir::support::SharedState::get()->ensure_connection();
const auto pixel_format = defaultPixelFormatFor(mir::support::SharedState::get()->connection());
ERR("Selected pixel format %d\n", pixel_format);
MirDisplayConfiguration* display_config =
mir_connection_create_display_config(mir::support::SharedState::get()->connection());
const MirDisplayOutput *output = find_active_output(display_config);
if (!output)
throw new std::runtime_error("Failed to find active output display");
const MirDisplayMode *mode = &output->modes[output->current_mode];
auto spec = mir_connection_create_spec_for_normal_surface(
mir::support::SharedState::get()->connection(),
mode->vertical_resolution,
mode->horizontal_resolution,
pixel_format);
mir_surface_spec_set_name(spec, "anbox");
mir_surface_spec_set_event_handler(spec, surfaceEventHandler, nullptr);
ERR("Selecting output id %d", output->output_id);
mir_surface_spec_set_fullscreen_on_output(spec, output->output_id);
mir_surface_spec_set_buffer_usage(spec, mir_buffer_usage_hardware);
mir_display_config_destroy(display_config);
auto surface = mir_surface_create_sync(spec);
mir_surface_spec_release(spec);
if (!mir_surface_is_valid(surface)) {
ERR("surface error: %s\n", mir_surface_get_error_message(surface));
throw std::runtime_error("Failed to create a Mir surface");
}
MirSurfaceParameters parameters;
mir_surface_get_parameters(surface, &parameters);
ERR("width %i height %i output id %i\n",
parameters.width,
parameters.height,
parameters.output_id);
auto surface_buffer_stream = mir_surface_get_buffer_stream(surface);
auto native_window = reinterpret_cast<EGLNativeWindowType>(
mir_buffer_stream_get_egl_native_window(surface_buffer_stream));
surfaces.insert({ native_window, surface });
return native_window;
}
void destroySubWindow(EGLNativeWindowType win) {
if (surfaces.find(win) == surfaces.end())
return;
auto surface = surfaces[win];
surfaces.erase(win);
mir_surface_release_sync(surface);
}
int moveSubWindow(FBNativeWindowType p_parent_window,
EGLNativeWindowType p_sub_window,
int x,
int y,
int width,
int height) {
ERR("%s: Not implemented", __func__);
return true;
}

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "NativeSubWindow.h"
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
int x,
int y,
int width,
int height,
SubWindowRepaintCallback repaint_callback,
void* repaint_callback_param) {
return NULL;
}
void destroySubWindow(EGLNativeWindowType win) {
}
int moveSubWindow(FBNativeWindowType p_parent_window,
EGLNativeWindowType p_sub_window,
int x,
int y,
int width,
int height) {
return false;
}

View file

@ -0,0 +1,90 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "NativeSubWindow.h"
struct SubWindowUserData {
SubWindowRepaintCallback repaint_callback;
void* repaint_callback_param;
};
static LRESULT CALLBACK subWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (uMsg == WM_PAINT) {
auto user_data =
(SubWindowUserData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (user_data && user_data->repaint_callback) {
user_data->repaint_callback(user_data->repaint_callback_param);
}
} else if (uMsg == WM_NCDESTROY) {
SubWindowUserData* user_data =
(SubWindowUserData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
delete user_data;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
int x, int y,int width, int height,
SubWindowRepaintCallback repaint_callback,
void* repaint_callback_param){
static const char className[] = "subWin";
WNDCLASS wc = {};
if (!GetClassInfo(GetModuleHandle(NULL), className, &wc)) {
wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;// redraw if size changes
wc.lpfnWndProc = &subWindowProc; // points to window procedure
wc.cbWndExtra = sizeof(void*) ; // save extra window memory
wc.lpszClassName = className; // name of window class
RegisterClass(&wc);
}
EGLNativeWindowType ret = CreateWindowEx(
WS_EX_NOPARENTNOTIFY, // do not bother our parent window
className,
"sub",
WS_CHILD|WS_DISABLED,
x,y,width,height,
p_window,
NULL,
NULL,
NULL);
auto user_data = new SubWindowUserData();
user_data->repaint_callback = repaint_callback;
user_data->repaint_callback_param = repaint_callback_param;
SetWindowLongPtr(ret, GWLP_USERDATA, (LONG_PTR)user_data);
ShowWindow(ret, SW_SHOW);
return ret;
}
void destroySubWindow(EGLNativeWindowType win){
PostMessage(win, WM_CLOSE, 0, 0);
}
int moveSubWindow(FBNativeWindowType p_parent_window,
EGLNativeWindowType p_sub_window,
int x,
int y,
int width,
int height) {
BOOL ret = MoveWindow(p_sub_window,
x,
y,
width,
height,
TRUE);
return ret;
}

View file

@ -0,0 +1,105 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "NativeSubWindow.h"
#include <stdio.h>
static Bool WaitForMapNotify(Display *d, XEvent *e, char *arg) {
if (e->type == MapNotify && e->xmap.window == (Window)arg) {
return 1;
}
return 0;
}
static Bool WaitForConfigureNotify(Display *d, XEvent *e, char *arg) {
if (e->type == ConfigureNotify && e->xmap.window == (Window)arg) {
return 1;
}
return 0;
}
static Display *s_display = NULL;
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
int x,
int y,
int width,
int height,
SubWindowRepaintCallback repaint_callback,
void* repaint_callback_param) {
// The call to this function is protected by a lock
// in FrameBuffer so it is safe to check and initialize s_display here
if (!s_display) {
s_display = XOpenDisplay(NULL);
}
XSetWindowAttributes wa;
wa.event_mask = StructureNotifyMask;
wa.override_redirect = True;
Window win = XCreateWindow(s_display,
p_window,
x,
y,
width,
height,
0,
CopyFromParent,
CopyFromParent,
CopyFromParent,
CWEventMask,
&wa);
XMapWindow(s_display,win);
XSetWindowBackground(s_display, win, BlackPixel(s_display, 0));
XEvent e;
XIfEvent(s_display, &e, WaitForMapNotify, (char *)win);
return win;
}
void destroySubWindow(EGLNativeWindowType win) {
if (!s_display) {
return;
}
XDestroyWindow(s_display, win);
}
int moveSubWindow(FBNativeWindowType p_parent_window,
EGLNativeWindowType p_sub_window,
int x,
int y,
int width,
int height) {
// This value is set during create, so if it is still null, simply
// return because the global state is corrupted
if (!s_display) {
return false;
}
// This prevents flicker on resize.
XSetWindowBackgroundPixmap(s_display, p_sub_window, None);
int ret = XMoveResizeWindow(
s_display,
p_sub_window,
x,
y,
width,
height);
XEvent e;
XIfEvent(s_display, &e, WaitForConfigureNotify, (char *)p_sub_window);
return ret;
}

View file

@ -0,0 +1,74 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ReadBuffer.h"
#include <string.h>
#include <assert.h>
#include <limits.h>
#include "ErrorLog.h"
ReadBuffer::ReadBuffer(size_t bufsize)
{
m_size = bufsize;
m_buf = (unsigned char*)malloc(m_size*sizeof(unsigned char));
m_validData = 0;
m_readPtr = m_buf;
}
ReadBuffer::~ReadBuffer()
{
free(m_buf);
}
int ReadBuffer::getData(IOStream *stream)
{
if(stream == NULL)
return -1;
if ((m_validData > 0) && (m_readPtr > m_buf)) {
memmove(m_buf, m_readPtr, m_validData);
}
// get fresh data into the buffer;
size_t len = m_size - m_validData;
if (len==0) {
//we need to inc our buffer
size_t new_size = m_size*2;
unsigned char* new_buf;
if (new_size < m_size) { // overflow check
new_size = INT_MAX;
}
new_buf = (unsigned char*)realloc(m_buf, new_size);
if (!new_buf) {
ERR("Failed to alloc %zu bytes for ReadBuffer\n", new_size);
return -1;
}
m_size = new_size;
m_buf = new_buf;
len = m_size - m_validData;
}
m_readPtr = m_buf;
if (NULL != stream->read(m_buf + m_validData, &len)) {
m_validData += len;
return len;
}
return -1;
}
void ReadBuffer::consume(size_t amount)
{
assert(amount <= m_validData);
m_validData -= amount;
m_readPtr += amount;
}

View file

@ -0,0 +1,35 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _READ_BUFFER_H
#define _READ_BUFFER_H
#include "IOStream.h"
class ReadBuffer {
public:
ReadBuffer(size_t bufSize);
~ReadBuffer();
int getData(IOStream *stream); // get fresh data from the stream
unsigned char *buf() { return m_readPtr; } // return the next read location
size_t validData() { return m_validData; } // return the amount of valid data in readptr
void consume(size_t amount); // notify that 'amount' data has been consumed;
private:
unsigned char *m_buf;
unsigned char *m_readPtr;
size_t m_size;
size_t m_validData;
};
#endif

View file

@ -0,0 +1,49 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "RenderContext.h"
#include "OpenGLESDispatch/EGLDispatch.h"
RenderContext* RenderContext::create(EGLDisplay display,
EGLConfig config,
EGLContext sharedContext,
bool isGl2) {
const EGLint contextAttribs[] = {
EGL_CONTEXT_CLIENT_VERSION, isGl2 ? 2 : 1,
EGL_NONE
};
EGLContext context = s_egl.eglCreateContext(
display, config, sharedContext, contextAttribs);
if (context == EGL_NO_CONTEXT) {
return NULL;
}
return new RenderContext(display, context, isGl2);
}
RenderContext::RenderContext(EGLDisplay display,
EGLContext context,
bool isGl2) :
mDisplay(display),
mContext(context),
mIsGl2(isGl2),
mContextData() {}
RenderContext::~RenderContext() {
if (mContext != EGL_NO_CONTEXT) {
s_egl.eglDestroyContext(mDisplay, mContext);
}
}

View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBRENDER_RENDER_CONTEXT_H
#define _LIBRENDER_RENDER_CONTEXT_H
#include "emugl/common/smart_ptr.h"
#include "GLDecoderContextData.h"
#include <EGL/egl.h>
// A class used to model a guest EGLContext. This simply wraps a host
// EGLContext, associated with an GLDecoderContextData instance that is
// used to store copies of guest-side arrays.
class RenderContext {
public:
// Create a new RenderContext instance.
// |display| is the host EGLDisplay handle.
// |config| is the host EGLConfig to use.
// |sharedContext| is either EGL_NO_CONTEXT of a host EGLContext handle.
// |isGl2| is true iff the new context will be used with GLESv2, or
// GLESv1 otherwise.
static RenderContext *create(EGLDisplay display,
EGLConfig config,
EGLContext sharedContext,
bool isGL2 = false);
// Destructor.
~RenderContext();
// Retrieve host EGLContext value.
EGLContext getEGLContext() const { return mContext; }
// Return true iff this is a GLESv2 context.
bool isGL2() const { return mIsGl2; }
// Retrieve GLDecoderContextData instance reference for this
// RenderContext instance.
GLDecoderContextData& decoderContextData() { return mContextData; }
private:
RenderContext();
RenderContext(EGLDisplay display,
EGLContext context,
bool isGl2);
private:
EGLDisplay mDisplay;
EGLContext mContext;
bool mIsGl2;
GLDecoderContextData mContextData;
};
typedef emugl::SmartPtr<RenderContext> RenderContextPtr;
#endif // _LIBRENDER_RENDER_CONTEXT_H

View file

@ -0,0 +1,417 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "RenderControl.h"
#include "DispatchTables.h"
#include "FbConfig.h"
#include "FrameBuffer.h"
#include "RenderThreadInfo.h"
#include "ChecksumCalculatorThreadInfo.h"
#include "OpenGLESDispatch/EGLDispatch.h"
static const GLint rendererVersion = 1;
static GLint rcGetRendererVersion()
{
return rendererVersion;
}
static EGLint rcGetEGLVersion(EGLint* major, EGLint* minor)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return EGL_FALSE;
}
*major = (EGLint)fb->getCaps().eglMajor;
*minor = (EGLint)fb->getCaps().eglMinor;
return EGL_TRUE;
}
static EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return 0;
}
const char *str = s_egl.eglQueryString(fb->getDisplay(), name);
if (!str) {
return 0;
}
int len = strlen(str) + 1;
if (!buffer || len > bufferSize) {
return -len;
}
strcpy((char *)buffer, str);
return len;
}
static EGLint rcGetGLString(EGLenum name, void* buffer, EGLint bufferSize)
{
RenderThreadInfo *tInfo = RenderThreadInfo::get();
const char *str = NULL;
int len = 0;
if (tInfo && tInfo->currContext.Ptr()) {
if (tInfo->currContext->isGL2()) {
str = (const char *)s_gles2.glGetString(name);
}
else {
str = (const char *)s_gles1.glGetString(name);
}
if (str) {
len = strlen(str) + 1;
}
}
// We add the maximum supported GL protocol number into GL_EXTENSIONS
const char* glProtocolStr = NULL;
if (name == GL_EXTENSIONS) {
glProtocolStr = ChecksumCalculatorThreadInfo::getMaxVersionString();
if (len==0) len = 1; // the last byte
len += strlen(glProtocolStr) + 1;
}
if (!buffer || len > bufferSize) {
return -len;
}
if (name == GL_EXTENSIONS) {
snprintf((char *)buffer, bufferSize, "%s%s ", str ? str : "", glProtocolStr);
} else if (str) {
strcpy((char *)buffer, str);
} else {
if (bufferSize >= 1) {
((char*)buffer)[0] = '\0';
}
len = 0;
}
return len;
}
static EGLint rcGetNumConfigs(uint32_t* p_numAttribs)
{
int numConfigs = 0, numAttribs = 0;
FrameBuffer::getFB()->getConfigs()->getPackInfo(&numConfigs, &numAttribs);
if (p_numAttribs) {
*p_numAttribs = static_cast<uint32_t>(numAttribs);
}
return numConfigs;
}
static EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer)
{
GLuint bufferSize = (GLuint)bufSize;
return FrameBuffer::getFB()->getConfigs()->packConfigs(bufferSize, buffer);
}
static EGLint rcChooseConfig(EGLint *attribs,
uint32_t attribs_size,
uint32_t *configs,
uint32_t configs_size)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb || attribs_size==0) {
return 0;
}
return fb->getConfigs()->chooseConfig(
attribs, (EGLint*)configs, (EGLint)configs_size);
}
static EGLint rcGetFBParam(EGLint param)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return 0;
}
EGLint ret = 0;
switch(param) {
case FB_WIDTH:
ret = fb->getWidth();
break;
case FB_HEIGHT:
ret = fb->getHeight();
break;
case FB_XDPI:
ret = 72; // XXX: should be implemented
break;
case FB_YDPI:
ret = 72; // XXX: should be implemented
break;
case FB_FPS:
ret = 60;
break;
case FB_MIN_SWAP_INTERVAL:
ret = 1; // XXX: should be implemented
break;
case FB_MAX_SWAP_INTERVAL:
ret = 1; // XXX: should be implemented
break;
default:
break;
}
return ret;
}
static uint32_t rcCreateContext(uint32_t config,
uint32_t share, uint32_t glVersion)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return 0;
}
// To make it consistent with the guest, create GLES2 context when GL
// version==2 or 3
HandleType ret = fb->createRenderContext(config, share, glVersion == 2 || glVersion == 3);
return ret;
}
static void rcDestroyContext(uint32_t context)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return;
}
fb->DestroyRenderContext(context);
}
static uint32_t rcCreateWindowSurface(uint32_t config,
uint32_t width, uint32_t height)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return 0;
}
return fb->createWindowSurface(config, width, height);
}
static void rcDestroyWindowSurface(uint32_t windowSurface)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return;
}
fb->DestroyWindowSurface( windowSurface );
}
static uint32_t rcCreateColorBuffer(uint32_t width,
uint32_t height, GLenum internalFormat)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return 0;
}
return fb->createColorBuffer(width, height, internalFormat);
}
static int rcOpenColorBuffer2(uint32_t colorbuffer)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return -1;
}
return fb->openColorBuffer( colorbuffer );
}
// Deprecated, kept for compatibility with old system images only.
// Use rcOpenColorBuffer2 instead.
static void rcOpenColorBuffer(uint32_t colorbuffer)
{
(void) rcOpenColorBuffer2(colorbuffer);
}
static void rcCloseColorBuffer(uint32_t colorbuffer)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return;
}
fb->closeColorBuffer( colorbuffer );
}
static int rcFlushWindowColorBuffer(uint32_t windowSurface)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return -1;
}
if (!fb->flushWindowSurfaceColorBuffer(windowSurface)) {
return -1;
}
return 0;
}
static void rcSetWindowColorBuffer(uint32_t windowSurface,
uint32_t colorBuffer)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return;
}
fb->setWindowSurfaceColorBuffer(windowSurface, colorBuffer);
}
static EGLint rcMakeCurrent(uint32_t context,
uint32_t drawSurf, uint32_t readSurf)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return EGL_FALSE;
}
bool ret = fb->bindContext(context, drawSurf, readSurf);
return (ret ? EGL_TRUE : EGL_FALSE);
}
static void rcFBPost(uint32_t colorBuffer)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return;
}
fb->post(colorBuffer);
}
static void rcFBSetSwapInterval(EGLint interval)
{
// XXX: TBD - should be implemented
}
static void rcBindTexture(uint32_t colorBuffer)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return;
}
fb->bindColorBufferToTexture(colorBuffer);
}
static void rcBindRenderbuffer(uint32_t colorBuffer)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return;
}
fb->bindColorBufferToRenderbuffer(colorBuffer);
}
static EGLint rcColorBufferCacheFlush(uint32_t colorBuffer,
EGLint postCount, int forRead)
{
// XXX: TBD - should be implemented
return 0;
}
static void rcReadColorBuffer(uint32_t colorBuffer,
GLint x, GLint y,
GLint width, GLint height,
GLenum format, GLenum type, void* pixels)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return;
}
fb->readColorBuffer(colorBuffer, x, y, width, height, format, type, pixels);
}
static int rcUpdateColorBuffer(uint32_t colorBuffer,
GLint x, GLint y,
GLint width, GLint height,
GLenum format, GLenum type, void* pixels)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return -1;
}
fb->updateColorBuffer(colorBuffer, x, y, width, height, format, type, pixels);
return 0;
}
static uint32_t rcCreateClientImage(uint32_t context, EGLenum target, GLuint buffer)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return 0;
}
return fb->createClientImage(context, target, buffer);
}
static int rcDestroyClientImage(uint32_t image)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
return 0;
}
return fb->destroyClientImage(image);
}
static void rcSelectChecksumCalculator(uint32_t protocol, uint32_t reserved) {
ChecksumCalculatorThreadInfo::setVersion(protocol);
}
void initRenderControlContext(renderControl_decoder_context_t *dec)
{
dec->rcGetRendererVersion = rcGetRendererVersion;
dec->rcGetEGLVersion = rcGetEGLVersion;
dec->rcQueryEGLString = rcQueryEGLString;
dec->rcGetGLString = rcGetGLString;
dec->rcGetNumConfigs = rcGetNumConfigs;
dec->rcGetConfigs = rcGetConfigs;
dec->rcChooseConfig = rcChooseConfig;
dec->rcGetFBParam = rcGetFBParam;
dec->rcCreateContext = rcCreateContext;
dec->rcDestroyContext = rcDestroyContext;
dec->rcCreateWindowSurface = rcCreateWindowSurface;
dec->rcDestroyWindowSurface = rcDestroyWindowSurface;
dec->rcCreateColorBuffer = rcCreateColorBuffer;
dec->rcOpenColorBuffer = rcOpenColorBuffer;
dec->rcCloseColorBuffer = rcCloseColorBuffer;
dec->rcSetWindowColorBuffer = rcSetWindowColorBuffer;
dec->rcFlushWindowColorBuffer = rcFlushWindowColorBuffer;
dec->rcMakeCurrent = rcMakeCurrent;
dec->rcFBPost = rcFBPost;
dec->rcFBSetSwapInterval = rcFBSetSwapInterval;
dec->rcBindTexture = rcBindTexture;
dec->rcBindRenderbuffer = rcBindRenderbuffer;
dec->rcColorBufferCacheFlush = rcColorBufferCacheFlush;
dec->rcReadColorBuffer = rcReadColorBuffer;
dec->rcUpdateColorBuffer = rcUpdateColorBuffer;
dec->rcOpenColorBuffer2 = rcOpenColorBuffer2;
dec->rcCreateClientImage = rcCreateClientImage;
dec->rcDestroyClientImage = rcDestroyClientImage;
dec->rcSelectChecksumCalculator = rcSelectChecksumCalculator;
}

View file

@ -0,0 +1,23 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _RENDER_CONTROL_H
#define _RENDER_CONTROL_H
#include "renderControl_dec.h"
void initRenderControlContext(renderControl_decoder_context_t *dec);
#endif

View file

@ -0,0 +1,170 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "RenderServer.h"
#include "RenderThread.h"
#include "TcpStream.h"
#ifndef _WIN32
#include "UnixStream.h"
#include <signal.h>
#include <pthread.h>
#endif
#ifdef _WIN32
#include "Win32PipeStream.h"
#endif
#include "OpenglRender/render_api.h"
#include <set>
#include <string.h>
typedef std::set<RenderThread *> RenderThreadsSet;
RenderServer::RenderServer() :
m_lock(),
m_listenSock(NULL),
m_exiting(false)
{
}
RenderServer::~RenderServer()
{
delete m_listenSock;
}
extern "C" int gRendererStreamMode;
RenderServer *RenderServer::create(char* addr, size_t addrLen)
{
RenderServer *server = new RenderServer();
if (!server) {
return NULL;
}
if (gRendererStreamMode == RENDER_API_STREAM_MODE_TCP) {
server->m_listenSock = new TcpStream();
} else {
#ifdef _WIN32
server->m_listenSock = new Win32PipeStream();
#else
server->m_listenSock = new UnixStream();
#endif
}
char addrstr[SocketStream::MAX_ADDRSTR_LEN];
if (server->m_listenSock->listen(addrstr) < 0) {
ERR("RenderServer::create failed to listen\n");
delete server;
return NULL;
}
size_t len = strlen(addrstr) + 1;
if (len > addrLen) {
ERR("RenderServer address name too big for provided buffer: %zu > %zu\n",
len, addrLen);
delete server;
return NULL;
}
memcpy(addr, addrstr, len);
return server;
}
intptr_t RenderServer::main()
{
RenderThreadsSet threads;
#ifndef _WIN32
sigset_t set;
sigfillset(&set);
pthread_sigmask(SIG_SETMASK, &set, NULL);
#endif
while(1) {
SocketStream *stream = m_listenSock->accept();
if (!stream) {
fprintf(stderr,"Error accepting gles connection, ignoring.\n");
continue;
}
unsigned int clientFlags;
if (!stream->readFully(&clientFlags, sizeof(unsigned int))) {
fprintf(stderr,"Error reading clientFlags\n");
delete stream;
continue;
}
DBG("RenderServer: Got new stream!\n");
// check if we have been requested to exit while waiting on accept
if ((clientFlags & IOSTREAM_CLIENT_EXIT_SERVER) != 0) {
m_exiting = true;
delete stream;
break;
}
RenderThread *rt = RenderThread::create(stream, &m_lock);
if (!rt) {
fprintf(stderr,"Failed to create RenderThread\n");
delete stream;
} else if (!rt->start()) {
fprintf(stderr,"Failed to start RenderThread\n");
delete rt;
delete stream;
}
//
// remove from the threads list threads which are
// no longer running
//
for (RenderThreadsSet::iterator n,t = threads.begin();
t != threads.end();
t = n) {
// first find next iterator
n = t;
n++;
// delete and erase the current iterator
// if thread is no longer running
if ((*t)->isFinished()) {
delete (*t);
threads.erase(t);
}
}
// if the thread has been created and started, insert it to the list
if (rt) {
threads.insert(rt);
DBG("Started new RenderThread\n");
}
}
//
// Wait for all threads to finish
//
for (RenderThreadsSet::iterator t = threads.begin();
t != threads.end();
t++) {
(*t)->forceStop();
(*t)->wait(NULL);
delete (*t);
}
threads.clear();
return 0;
}

View file

@ -0,0 +1,42 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIB_OPENGL_RENDER_RENDER_SERVER_H
#define _LIB_OPENGL_RENDER_RENDER_SERVER_H
#include "SocketStream.h"
#include "emugl/common/mutex.h"
#include "emugl/common/thread.h"
class RenderServer : public emugl::Thread
{
public:
static RenderServer *create(char* addr, size_t addrLen);
virtual ~RenderServer();
virtual intptr_t main();
bool isExiting() const { return m_exiting; }
private:
RenderServer();
private:
emugl::Mutex m_lock;
SocketStream *m_listenSock;
bool m_exiting;
};
#endif

View file

@ -0,0 +1,165 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "RenderThread.h"
#include "FrameBuffer.h"
#include "ReadBuffer.h"
#include "RenderControl.h"
#include "RenderThreadInfo.h"
#include "TimeUtils.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include "OpenGLESDispatch/GLESv2Dispatch.h"
#include "OpenGLESDispatch/GLESv1Dispatch.h"
#include "../../../shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.h"
#define STREAM_BUFFER_SIZE 4*1024*1024
RenderThread::RenderThread(IOStream *stream, emugl::Mutex *lock) :
emugl::Thread(),
m_lock(lock),
m_stream(stream) {}
RenderThread::~RenderThread() {
delete m_stream;
}
// static
RenderThread* RenderThread::create(IOStream *stream, emugl::Mutex *lock) {
return new RenderThread(stream, lock);
}
void RenderThread::forceStop() {
m_stream->forceStop();
}
intptr_t RenderThread::main() {
RenderThreadInfo tInfo;
ChecksumCalculatorThreadInfo tChecksumInfo;
//
// initialize decoders
//
tInfo.m_glDec.initGL(gles1_dispatch_get_proc_func, NULL);
tInfo.m_gl2Dec.initGL(gles2_dispatch_get_proc_func, NULL);
initRenderControlContext(&tInfo.m_rcDec);
ReadBuffer readBuf(STREAM_BUFFER_SIZE);
int stats_totalBytes = 0;
long long stats_t0 = GetCurrentTimeMS();
//
// open dump file if RENDER_DUMP_DIR is defined
//
const char *dump_dir = getenv("RENDERER_DUMP_DIR");
FILE *dumpFP = NULL;
if (dump_dir) {
size_t bsize = strlen(dump_dir) + 32;
char *fname = new char[bsize];
snprintf(fname,bsize,"%s/stream_%p", dump_dir, this);
dumpFP = fopen(fname, "wb");
if (!dumpFP) {
fprintf(stderr,"Warning: stream dump failed to open file %s\n",fname);
}
delete [] fname;
}
while (1) {
int stat = readBuf.getData(m_stream);
if (stat <= 0) {
break;
}
//
// log received bandwidth statistics
//
stats_totalBytes += readBuf.validData();
long long dt = GetCurrentTimeMS() - stats_t0;
if (dt > 1000) {
float dts = (float)dt / 1000.0f;
printf("Used Bandwidth %5.3f MB/s\n", ((float)stats_totalBytes / dts) / (1024.0f*1024.0f));
stats_totalBytes = 0;
stats_t0 = GetCurrentTimeMS();
}
//
// dump stream to file if needed
//
if (dumpFP) {
int skip = readBuf.validData() - stat;
fwrite(readBuf.buf()+skip, 1, readBuf.validData()-skip, dumpFP);
fflush(dumpFP);
}
bool progress;
do {
progress = false;
m_lock->lock();
//
// try to process some of the command buffer using the GLESv1 decoder
//
size_t last = tInfo.m_glDec.decode(readBuf.buf(), readBuf.validData(), m_stream);
if (last > 0) {
progress = true;
readBuf.consume(last);
}
//
// try to process some of the command buffer using the GLESv2 decoder
//
last = tInfo.m_gl2Dec.decode(readBuf.buf(), readBuf.validData(), m_stream);
if (last > 0) {
progress = true;
readBuf.consume(last);
}
//
// try to process some of the command buffer using the
// renderControl decoder
//
last = tInfo.m_rcDec.decode(readBuf.buf(), readBuf.validData(), m_stream);
if (last > 0) {
readBuf.consume(last);
progress = true;
}
m_lock->unlock();
} while( progress );
}
if (dumpFP) {
fclose(dumpFP);
}
//
// Release references to the current thread's context/surfaces if any
//
FrameBuffer::getFB()->bindContext(0, 0, 0);
if (tInfo.currContext || tInfo.currDrawSurf || tInfo.currReadSurf) {
fprintf(stderr, "ERROR: RenderThread exiting with current context/surfaces\n");
}
FrameBuffer::getFB()->drainWindowSurface();
FrameBuffer::getFB()->drainRenderContext();
return 0;
}

View file

@ -0,0 +1,58 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIB_OPENGL_RENDER_RENDER_THREAD_H
#define _LIB_OPENGL_RENDER_RENDER_THREAD_H
#include "IOStream.h"
#include "emugl/common/mutex.h"
#include "emugl/common/thread.h"
// A class used to model a thread of the RenderServer. Each one of them
// handles a single guest client / protocol byte stream.
class RenderThread : public emugl::Thread {
public:
// Create a new RenderThread instance.
// |stream| is an input stream that will be read from the thread,
// and deleted by it when it exits.
// |mutex| is a pointer to a shared mutex used to serialize
// decoding operations between all threads.
// TODO(digit): Why is this needed here? Shouldn't this be handled
// by the decoders themselves or at a lower-level?
static RenderThread* create(IOStream* stream, emugl::Mutex* mutex);
// Destructor.
virtual ~RenderThread();
// Returns true iff the thread has finished.
// Note that this also means that the thread's stack has been
bool isFinished() { return tryWait(NULL); }
// Force a thread to stop.
void forceStop();
private:
RenderThread(); // No default constructor
RenderThread(IOStream* stream, emugl::Mutex* mutex);
virtual intptr_t main();
emugl::Mutex* m_lock;
IOStream* m_stream;
};
#endif

View file

@ -0,0 +1,43 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "RenderThreadInfo.h"
#include "emugl/common/lazy_instance.h"
#include "emugl/common/thread_store.h"
namespace {
class ThreadInfoStore : public ::emugl::ThreadStore {
public:
ThreadInfoStore() : ::emugl::ThreadStore(NULL) {}
};
} // namespace
static ::emugl::LazyInstance<ThreadInfoStore> s_tls = LAZY_INSTANCE_INIT;
RenderThreadInfo::RenderThreadInfo() {
s_tls->set(this);
}
RenderThreadInfo::~RenderThreadInfo() {
s_tls->set(NULL);
}
RenderThreadInfo* RenderThreadInfo::get() {
return static_cast<RenderThreadInfo*>(s_tls->get());
}

View file

@ -0,0 +1,60 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIB_OPENGL_RENDER_THREAD_INFO_H
#define _LIB_OPENGL_RENDER_THREAD_INFO_H
#include "RenderContext.h"
#include "WindowSurface.h"
#include "GLESv1Decoder.h"
#include "GLESv2Decoder.h"
#include "renderControl_dec.h"
#include <set>
typedef uint32_t HandleType;
typedef std::set<HandleType> ThreadContextSet;
typedef std::set<HandleType> WindowSurfaceSet;
// A class used to model the state of each RenderThread related
struct RenderThreadInfo {
// Create new instance. Only call this once per thread.
// Future callls to get() will return this instance until
// it is destroyed.
RenderThreadInfo();
// Destructor.
~RenderThreadInfo();
// Return the current thread's instance, if any, or NULL.
static RenderThreadInfo* get();
// Current EGL context, draw surface and read surface.
RenderContextPtr currContext;
WindowSurfacePtr currDrawSurf;
WindowSurfacePtr currReadSurf;
// Decoder states.
GLESv1Decoder m_glDec;
GLESv2Decoder m_gl2Dec;
renderControl_decoder_context_t m_rcDec;
// all the contexts that are created by this render thread
ThreadContextSet m_contextSet;
// all the window surfaces that are created by this render thread
WindowSurfaceSet m_windowSet;
};
#endif

View file

@ -0,0 +1,454 @@
// Copyright 2014-2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "RenderWindow.h"
#include "emugl/common/logging.h"
#include "emugl/common/message_channel.h"
#include "emugl/common/mutex.h"
#include "emugl/common/thread.h"
#include "FrameBuffer.h"
#include <stdarg.h>
#include <stdio.h>
#ifndef _WIN32
#include <signal.h>
#include <pthread.h>
#endif
#define DEBUG 0
#if DEBUG
# define D(...) my_debug(__PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
#else
# define D(...) ((void)0)
#endif
namespace {
#if DEBUG
void my_debug(const char* function, int line, const char* format, ...) {
static ::emugl::Mutex mutex;
va_list args;
va_start(args, format);
mutex.lock();
fprintf(stderr, "%s:%d:", function, line);
vfprintf(stderr, format, args);
mutex.unlock();
va_end(args);
}
#endif
// List of possible commands to send to the render window thread from
// the main one.
enum Command {
CMD_INITIALIZE,
CMD_SET_POST_CALLBACK,
CMD_SETUP_SUBWINDOW,
CMD_REMOVE_SUBWINDOW,
CMD_SET_ROTATION,
CMD_SET_TRANSLATION,
CMD_REPAINT,
CMD_FINALIZE,
};
} // namespace
// A single message sent from the main thread to the render window thread.
// |cmd| determines which fields are valid to read.
struct RenderWindowMessage {
Command cmd;
union {
// CMD_INITIALIZE
struct {
int width;
int height;
bool useSubWindow;
} init;
// CMD_SET_POST_CALLBACK
struct {
OnPostFn on_post;
void* on_post_context;
} set_post_callback;
// CMD_SETUP_SUBWINDOW
struct {
FBNativeWindowType parent;
int wx;
int wy;
int ww;
int wh;
int fbw;
int fbh;
float dpr;
float rotation;
} subwindow;
// CMD_SET_TRANSLATION;
struct {
float px;
float py;
} trans;
// CMD_SET_ROTATION
float rotation;
// result of operations.
bool result;
};
// Process the current message, and updates its |result| field.
// Returns true on success, or false on failure.
bool process() const {
const RenderWindowMessage& msg = *this;
FrameBuffer* fb;
bool result = false;
switch (msg.cmd) {
case CMD_INITIALIZE:
D("CMD_INITIALIZE w=%d h=%d\n", msg.init.width, msg.init.height);
GL_LOG("RenderWindow: CMD_INITIALIZE w=%d h=%d",
msg.init.width, msg.init.height);
result = FrameBuffer::initialize(msg.init.width,
msg.init.height,
msg.init.useSubWindow);
break;
case CMD_FINALIZE:
D("CMD_FINALIZE\n");
// this command may be issued even when frame buffer is not
// yet created (e.g. if CMD_INITIALIZE failed),
// so make sure we check if it is there before finalizing
if (const auto fb = FrameBuffer::getFB()) {
fb->finalize();
}
result = true;
break;
case CMD_SET_POST_CALLBACK:
D("CMD_SET_POST_CALLBACK\n");
fb = FrameBuffer::getFB();
fb->setPostCallback(msg.set_post_callback.on_post,
msg.set_post_callback.on_post_context);
result = true;
break;
case CMD_SETUP_SUBWINDOW:
D("CMD_SETUP_SUBWINDOW: parent=%p wx=%d wy=%d ww=%d wh=%d fbw=%d fbh=%d dpr=%f rotation=%f\n",
(void*)msg.subwindow.parent,
msg.subwindow.wx,
msg.subwindow.wy,
msg.subwindow.ww,
msg.subwindow.wh,
msg.subwindow.fbw,
msg.subwindow.fbh,
msg.subwindow.dpr,
msg.subwindow.rotation);
result = FrameBuffer::getFB()->setupSubWindow(
msg.subwindow.parent,
msg.subwindow.wx,
msg.subwindow.wy,
msg.subwindow.ww,
msg.subwindow.wh,
msg.subwindow.fbw,
msg.subwindow.fbh,
msg.subwindow.dpr,
msg.subwindow.rotation);
break;
case CMD_REMOVE_SUBWINDOW:
D("CMD_REMOVE_SUBWINDOW\n");
result = FrameBuffer::getFB()->removeSubWindow();
break;
case CMD_SET_ROTATION:
D("CMD_SET_ROTATION rotation=%f\n", msg.rotation);
fb = FrameBuffer::getFB();
if (fb) {
fb->setDisplayRotation(msg.rotation);
result = true;
}
break;
case CMD_SET_TRANSLATION:
D("CMD_SET_TRANSLATION translation=%f,%f\n", msg.trans.px, msg.trans.py);
fb = FrameBuffer::getFB();
if (fb) {
fb->setDisplayTranslation(msg.trans.px, msg.trans.py);
result = true;
}
break;
case CMD_REPAINT:
D("CMD_REPAINT\n");
fb = FrameBuffer::getFB();
if (fb) {
fb->repost();
result = true;
}
break;
default:
;
}
return result;
}
};
// Simple synchronization structure used to exchange data between the
// main and render window threads. Usage is the following:
//
// The main thread does the following in a loop:
//
// canWriteCmd.wait()
// updates |message| by writing a new |cmd| value and appropriate
// parameters.
// canReadCmd.signal()
// canReadResult.wait()
// reads |message.result|
// canWriteResult.signal()
//
// The render window thread will do the following:
//
// canReadCmd.wait()
// reads |message.cmd| and acts upon it.
// canWriteResult.wait()
// writes |message.result|
// canReadResult.signal()
// canWriteCmd.signal()
//
class RenderWindowChannel {
public:
RenderWindowChannel() : mIn(), mOut() {}
~RenderWindowChannel() {}
// Send a message from the main thread.
// Note that the content of |msg| is copied into the channel.
// Returns with the command's result (true or false).
bool sendMessageAndGetResult(const RenderWindowMessage& msg) {
D("msg.cmd=%d\n", msg.cmd);
mIn.send(msg);
D("waiting for result\n");
bool result = false;
mOut.receive(&result);
D("result=%s\n", result ? "success" : "failure");
return result;
}
// Receive a message from the render window thread.
// On exit, |*msg| gets a copy of the message. The caller
// must always call sendResult() after processing the message.
void receiveMessage(RenderWindowMessage* msg) {
D("entering\n");
mIn.receive(msg);
D("message cmd=%d\n", msg->cmd);
}
// Send result from the render window thread to the main one.
// Must always be called after receiveMessage().
void sendResult(bool result) {
D("waiting to send result (%s)\n", result ? "success" : "failure");
mOut.send(result);
D("result sent\n");
}
private:
emugl::MessageChannel<RenderWindowMessage, 16U> mIn;
emugl::MessageChannel<bool, 16U> mOut;
};
namespace {
// This class implements the window render thread.
// Its purpose is to listen for commands from the main thread in a loop,
// process them, then return a boolean result for each one of them.
//
// The thread ends with a CMD_FINALIZE.
//
class RenderWindowThread : public emugl::Thread {
public:
RenderWindowThread(RenderWindowChannel* channel) : mChannel(channel) {}
virtual intptr_t main() {
D("Entering render window thread thread\n");
#ifndef _WIN32
sigset_t set;
sigfillset(&set);
pthread_sigmask(SIG_SETMASK, &set, NULL);
#endif
bool running = true;
while (running) {
RenderWindowMessage msg;
D("Waiting for message from main thread\n");
mChannel->receiveMessage(&msg);
bool result = msg.process();
if (msg.cmd == CMD_FINALIZE) {
running = false;
}
D("Sending result (%s) to main thread\n", result ? "success" : "failure");
mChannel->sendResult(result);
}
D("Exiting thread\n");
return 0;
}
private:
RenderWindowChannel* mChannel;
};
} // namespace
RenderWindow::RenderWindow(int width,
int height,
bool use_thread,
bool use_sub_window) :
mValid(false),
mHasSubWindow(false),
mThread(NULL),
mChannel(NULL) {
if (use_thread) {
mChannel = new RenderWindowChannel();
mThread = new RenderWindowThread(mChannel);
mThread->start();
}
RenderWindowMessage msg;
msg.cmd = CMD_INITIALIZE;
msg.init.width = width;
msg.init.height = height;
msg.init.useSubWindow = use_sub_window;
mValid = processMessage(msg);
}
RenderWindow::~RenderWindow() {
D("Entering\n");
removeSubWindow();
D("Sending CMD_FINALIZE\n");
RenderWindowMessage msg;
msg.cmd = CMD_FINALIZE;
(void) processMessage(msg);
if (mThread) {
mThread->wait(NULL);
delete mThread;
delete mChannel;
}
}
bool RenderWindow::getHardwareStrings(const char** vendor,
const char** renderer,
const char** version) {
D("Entering\n");
// TODO(digit): Move this to render window thread.
FrameBuffer* fb = FrameBuffer::getFB();
if (!fb) {
D("No framebuffer!\n");
return false;
}
fb->getGLStrings(vendor, renderer, version);
D("Exiting vendor=[%s] renderer=[%s] version=[%s]\n",
*vendor, *renderer, *version);
return true;
}
void RenderWindow::setPostCallback(OnPostFn onPost, void* onPostContext) {
D("Entering\n");
RenderWindowMessage msg;
msg.cmd = CMD_SET_POST_CALLBACK;
msg.set_post_callback.on_post = onPost;
msg.set_post_callback.on_post_context = onPostContext;
(void) processMessage(msg);
D("Exiting\n");
}
bool RenderWindow::setupSubWindow(FBNativeWindowType window,
int wx,
int wy,
int ww,
int wh,
int fbw,
int fbh,
float dpr,
float zRot) {
D("Entering mHasSubWindow=%s\n", mHasSubWindow ? "true" : "false");
RenderWindowMessage msg;
msg.cmd = CMD_SETUP_SUBWINDOW;
msg.subwindow.parent = window;
msg.subwindow.wx = wx;
msg.subwindow.wy = wy;
msg.subwindow.ww = ww;
msg.subwindow.wh = wh;
msg.subwindow.fbw = fbw;
msg.subwindow.fbh = fbh;
msg.subwindow.dpr = dpr;
msg.subwindow.rotation = zRot;
mHasSubWindow = processMessage(msg);
D("Exiting mHasSubWindow=%s\n", mHasSubWindow ? "true" : "false");
return mHasSubWindow;
}
bool RenderWindow::removeSubWindow() {
D("Entering mHasSubWindow=%s\n", mHasSubWindow ? "true" : "false");
if (!mHasSubWindow) {
return false;
}
mHasSubWindow = false;
RenderWindowMessage msg;
msg.cmd = CMD_REMOVE_SUBWINDOW;
bool result = processMessage(msg);
D("Exiting result=%s\n", result ? "success" : "failure");
return result;
}
void RenderWindow::setRotation(float zRot) {
D("Entering rotation=%f\n", zRot);
RenderWindowMessage msg;
msg.cmd = CMD_SET_ROTATION;
msg.rotation = zRot;
(void) processMessage(msg);
D("Exiting\n");
}
void RenderWindow::setTranslation(float px, float py) {
D("Entering translation=%f,%f\n", px, py);
RenderWindowMessage msg;
msg.cmd = CMD_SET_TRANSLATION;
msg.trans.px = px;
msg.trans.py = py;
(void) processMessage(msg);
D("Exiting\n");
}
void RenderWindow::repaint() {
D("Entering\n");
RenderWindowMessage msg;
msg.cmd = CMD_REPAINT;
(void) processMessage(msg);
D("Exiting\n");
}
bool RenderWindow::processMessage(const RenderWindowMessage& msg) {
if (mChannel) {
return mChannel->sendMessageAndGetResult(msg);
} else {
return msg.process();
}
}

View file

@ -0,0 +1,135 @@
// Copyright 2014-2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef ANDROID_EMUGL_LIBRENDER_RENDER_WINDOW_H
#define ANDROID_EMUGL_LIBRENDER_RENDER_WINDOW_H
#include "OpenglRender/render_api.h"
namespace emugl {
class Thread;
} // namespace emugl
class RenderWindowChannel;
struct RenderWindowMessage;
// Helper class used to manage the sub-window that displays the emulated GPU
// output. To use it, do the following:
//
// 1) Create a new instance, passing the size of the emulated accelerated
// framebuffer in pixels you need.
//
// 2) Check isValid() after construction. If false, the library could not
// initialize the class properly, and one should abort.
//
// 3) Optional: call setPostCallback() to specify a callback function which
// will be called everytime a new frame is drawn.
//
// 4) Call setupSubWindow() to setup a new sub-window within the UI window.
// One can call removeSubWindow() to remove it, and one can call
// setupSubWindow() + removeSubWindow() any number of time (e.g. for
// changing the position / rotation of the subwindow).
//
// 5) Optional: call setRotation() to only change the display rotation of
// the sub-window content.
//
// 6) Call repaint() to force a repaint().
//
class RenderWindow {
public:
// Create new instance. |width| and |height| are the dimensions of the
// emulated accelerated framebuffer. |use_thread| can be true to force
// the use of a separate thread, which might be required on some platforms
// to avoid GL-realted corruption issues in the main window. Call
// isValid() after construction to verify that it worked properly.
//
// |use_sub_window| is true if the client will call setupSubWindow(),
// and false if it will call setPostCallback().
//
// Note that this call doesn't display anything, it just initializes
// the library, use setupSubWindow() to display something.
RenderWindow(int width, int height, bool use_thread, bool use_sub_window);
// Destructor. This will automatically call removeSubWindow() is needed.
~RenderWindow();
// Returns true if the RenderWindow instance is valid, which really
// means that the constructor succeeded.
bool isValid() const { return mValid; }
// Return misc. GL strings to the caller. On success, return true and sets
// |*vendor| to the GL vendor string, |*renderer| to the GL renderer one,
// and |*version| to the GL version one. On failure, return false.
bool getHardwareStrings(const char** vendor,
const char** renderer,
const char** version);
// Specify a function that will be called everytime a new frame is
// displayed. This is relatively slow but allows one to capture the
// output.
void setPostCallback(OnPostFn onPost, void* onPostContext);
// Start displaying the emulated framebuffer using a sub-window of a
// parent |window| id. |wx|, |wy|, |ww| and |wh| are the position
// and dimension of the sub-window, relative to its parent.
// |fbw| and |fbh| are the dimensions of the underlying guest framebuffer.
// |dpr| is the device pixel ratio for the monitor, which is required for
// higher-density displays (such as retina).
// |rotation| is a clockwise-rotation for the content. Only multiples of
// 90. are accepted. Returns true on success, false otherwise.
//
// If the subwindow already exists, this function will update
// the dimensions of the subwindow, backing framebuffer, and rendering
// pipeline to reflect the new values.
//
// One can call removeSubWindow() to remove the sub-window.
bool setupSubWindow(FBNativeWindowType window,
int wx,
int wy,
int ww,
int wh,
int fbw,
int fbh,
float dpr,
float rotation);
// Remove the sub-window created by calling setupSubWindow().
// Note that this doesn't discard the content of the emulated framebuffer,
// it just hides it from the main window. Returns true on success, false
// otherwise.
bool removeSubWindow();
// Change the display rotation on the fly. |zRot| is a clockwise rotation
// angle in degrees. Only multiples of 90. are accepted.
void setRotation(float zRot);
// Change the display translation. |px|,|py| are numbers between 0 and 1,
// with (0,0) indicating "align the bottom left of the framebuffer with the
// bottom left of the subwindow", and (1,1) indicating "align the top right of
// the framebuffer with the top right of the subwindow."
void setTranslation(float px, float py);
// Force a repaint of the whole content into the sub-window.
void repaint();
private:
bool processMessage(const RenderWindowMessage& msg);
bool mValid;
bool mHasSubWindow;
emugl::Thread* mThread;
RenderWindowChannel* mChannel;
};
#endif // ANDROID_EMUGL_LIBRENDER_RENDER_WINDOW_H

View file

@ -0,0 +1,183 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "SocketStream.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#ifndef _WIN32
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/un.h>
#else
#include <ws2tcpip.h>
#endif
SocketStream::SocketStream(size_t bufSize) :
IOStream(bufSize),
m_sock(-1),
m_bufsize(bufSize),
m_buf(NULL)
{
}
SocketStream::SocketStream(int sock, size_t bufSize) :
IOStream(bufSize),
m_sock(sock),
m_bufsize(bufSize),
m_buf(NULL)
{
}
SocketStream::~SocketStream()
{
if (m_sock >= 0) {
forceStop();
#ifndef _WIN32
if(close(m_sock) < 0)
perror("Closing SocketStream failed");
#endif
// DBG("SocketStream::~close @ %d \n", m_sock);
m_sock = -1;
}
if (m_buf != NULL) {
free(m_buf);
m_buf = NULL;
}
}
void *SocketStream::allocBuffer(size_t minSize)
{
size_t allocSize = (m_bufsize < minSize ? minSize : m_bufsize);
if (!m_buf) {
m_buf = (unsigned char *)malloc(allocSize);
}
else if (m_bufsize < allocSize) {
unsigned char *p = (unsigned char *)realloc(m_buf, allocSize);
if (p != NULL) {
m_buf = p;
m_bufsize = allocSize;
} else {
ERR("%s: realloc (%zu) failed\n", __FUNCTION__, allocSize);
free(m_buf);
m_buf = NULL;
m_bufsize = 0;
}
}
return m_buf;
};
int SocketStream::commitBuffer(size_t size)
{
return writeFully(m_buf, size);
}
int SocketStream::writeFully(const void* buffer, size_t size)
{
if (!valid()) return -1;
size_t res = size;
int retval = 0;
while (res > 0) {
ssize_t stat = ::send(m_sock, (const char *)buffer + (size - res), res, 0);
if (stat < 0) {
if (errno != EINTR) {
retval = stat;
ERR("%s: failed: %s\n", __FUNCTION__, strerror(errno));
break;
}
} else {
res -= stat;
}
}
return retval;
}
const unsigned char *SocketStream::readFully(void *buf, size_t len)
{
if (!valid()) return NULL;
if (!buf) {
return NULL; // do not allow NULL buf in that implementation
}
size_t res = len;
while (res > 0) {
ssize_t stat = ::recv(m_sock, (char *)(buf) + len - res, res, 0);
if (stat > 0) {
res -= stat;
continue;
}
if (stat == 0 || errno != EINTR) { // client shutdown or error
return NULL;
}
}
return (const unsigned char *)buf;
}
const unsigned char *SocketStream::read( void *buf, size_t *inout_len)
{
if (!valid()) return NULL;
if (!buf) {
return NULL; // do not allow NULL buf in that implementation
}
int n;
do {
n = this->recv(buf, *inout_len);
} while( n < 0 && errno == EINTR );
if (n > 0) {
*inout_len = n;
return (const unsigned char *)buf;
}
return NULL;
}
int SocketStream::recv(void *buf, size_t len)
{
if (!valid()) return int(ERR_INVALID_SOCKET);
int res = 0;
while(true) {
res = ::recv(m_sock, (char *)buf, len, 0);
if (res < 0) {
if (errno == EINTR) {
continue;
}
}
break;
}
return res;
}
void SocketStream::forceStop() {
// Shutdown socket to force read/write errors.
#ifdef _WIN32
::shutdown(m_sock, SD_BOTH);
// As documented by programmers on MSDN, shutdown implementation in Windows does
// NOT result to unblocking threads that are blocked on a recv on the socket
// being shut down. The only way to actually implement this behavior (expected
// by this forceStop() implementation) is to rudely close the socket.
::closesocket(m_sock);
m_sock = -1;
#else
::shutdown(m_sock, SHUT_RDWR);
#endif
}

View file

@ -0,0 +1,53 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __SOCKET_STREAM_H
#define __SOCKET_STREAM_H
#include <stdlib.h>
#include "IOStream.h"
class SocketStream : public IOStream {
public:
typedef enum { ERR_INVALID_SOCKET = -1000 } SocketStreamError;
static const size_t MAX_ADDRSTR_LEN = 256;
explicit SocketStream(size_t bufsize = 10000);
virtual ~SocketStream();
virtual int listen(char addrstr[MAX_ADDRSTR_LEN]) = 0;
virtual SocketStream *accept() = 0;
virtual int connect(const char* addr) = 0;
virtual void *allocBuffer(size_t minSize);
virtual int commitBuffer(size_t size);
virtual const unsigned char *readFully(void *buf, size_t len);
virtual const unsigned char *read(void *buf, size_t *inout_len);
bool valid() { return m_sock >= 0; }
virtual int recv(void *buf, size_t len);
virtual int writeFully(const void *buf, size_t len);
virtual void forceStop();
protected:
int m_sock;
size_t m_bufsize;
unsigned char *m_buf;
SocketStream(int sock, size_t bufSize);
};
#endif /* __SOCKET_STREAM_H */

View file

@ -0,0 +1,78 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "TcpStream.h"
#include "emugl/common/sockets.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#ifndef _WIN32
#include <netinet/in.h>
#include <netinet/tcp.h>
#else
#include <ws2tcpip.h>
#endif
#define LISTEN_BACKLOG 4
TcpStream::TcpStream(size_t bufSize) : SocketStream(bufSize) {}
TcpStream::TcpStream(int sock, size_t bufSize) :
SocketStream(sock, bufSize) {
// disable Nagle algorithm to improve bandwidth of small
// packets which are quite common in our implementation.
emugl::socketTcpDisableNagle(sock);
}
int TcpStream::listen(char addrstr[MAX_ADDRSTR_LEN]) {
m_sock = emugl::socketTcpLoopbackServer(0, SOCK_STREAM);
if (!valid())
return int(ERR_INVALID_SOCKET);
int port = emugl::socketGetPort(m_sock);
if (port < 0) {
::close(m_sock);
return int(ERR_INVALID_SOCKET);
}
snprintf(addrstr, MAX_ADDRSTR_LEN - 1, "%hu", port);
addrstr[MAX_ADDRSTR_LEN-1] = '\0';
return 0;
}
SocketStream * TcpStream::accept() {
int clientSock = emugl::socketAccept(m_sock);
if (clientSock < 0)
return NULL;
return new TcpStream(clientSock, m_bufsize);
}
int TcpStream::connect(const char* addr) {
int port = atoi(addr);
m_sock = emugl::socketTcpLoopbackClient(port, SOCK_STREAM);
return valid() ? 0 : -1;
}
int TcpStream::connect(const char* hostname, unsigned short port)
{
m_sock = emugl::socketTcpClient(hostname, port, SOCK_STREAM);
return valid() ? 0 : -1;
}

View file

@ -0,0 +1,32 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __TCP_STREAM_H
#define __TCP_STREAM_H
#include "SocketStream.h"
class TcpStream : public SocketStream {
public:
explicit TcpStream(size_t bufsize = 10000);
virtual int listen(char addrstr[MAX_ADDRSTR_LEN]);
virtual SocketStream *accept();
virtual int connect(const char* addr);
int connect(const char* hostname, unsigned short port);
private:
TcpStream(int sock, size_t bufSize);
};
#endif

View file

@ -0,0 +1,287 @@
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "TextureDraw.h"
#include "DispatchTables.h"
#include <math.h>
#include <string.h>
#include <vector>
#include <stdio.h>
#define ERR(...) fprintf(stderr, __VA_ARGS__)
// M_PI isn't defined in C++ (when strict ISO compliance is enabled)
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327
#endif
namespace {
// Helper function to create a new shader.
// |shaderType| is the shader type (e.g. GL_VERTEX_SHADER).
// |shaderText| is a 0-terminated C string for the shader source to use.
// On success, return the handle of the new compiled shader, or 0 on failure.
GLuint createShader(GLint shaderType, const char* shaderText) {
// Create new shader handle and attach source.
GLuint shader = s_gles2.glCreateShader(shaderType);
if (!shader) {
return 0;
}
const GLchar* text = static_cast<const GLchar*>(shaderText);
const GLint textLen = ::strlen(shaderText);
s_gles2.glShaderSource(shader, 1, &text, &textLen);
// Compiler the shader.
GLint success;
s_gles2.glCompileShader(shader);
s_gles2.glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
if (success == GL_FALSE) {
s_gles2.glDeleteShader(shader);
return 0;
}
return shader;
}
// No scaling / projection since we want to fill the whole viewport with
// the texture, hence a trivial vertex shader that only supports clockwise
// rotation.
const char kVertexShaderSource[] =
"#version 100\n"
"const int _translator_gl_MaxVertexUniformVectors = 256;\n"
"const int _translator_gl_MaxFragmentUniformVectors = 256;\n"
"const int _translator_gl_MaxVaryingVectors = 15;\n"
"#define gl_MaxVertexUniformVectors _translator_gl_MaxVertexUniformVectors\n"
"#define gl_MaxFragmentUniformVectors _translator_gl_MaxFragmentUniformVectors\n"
"#define gl_MaxVaryingVectors _translator_gl_MaxVaryingVectors\n"
"#line 1\n"
"attribute vec4 position;\n"
"attribute vec2 inCoord;\n"
"varying lowp vec2 outCoord;\n"
"uniform float rotation;\n"
"uniform vec2 translation;\n"
"void main(void) {\n"
" float cs = cos(rotation);\n"
" float sn = sin(rotation);\n"
" gl_Position.x = position.x * cs + position.y * sn - translation.x;\n"
" gl_Position.y = position.y * cs - position.x * sn - translation.y;\n"
" gl_Position.zw = position.zw;\n"
" outCoord = inCoord;\n"
"}\n";
// Similarly, just interpolate texture coordinates.
const char kFragmentShaderSource[] =
"#version 100\n"
"const int _translator_gl_MaxVertexUniformVectors = 256;\n"
"const int _translator_gl_MaxFragmentUniformVectors = 256;\n"
"const int _translator_gl_MaxVaryingVectors = 15;\n"
"#define gl_MaxVertexUniformVectors _translator_gl_MaxVertexUniformVectors\n"
"#define gl_MaxFragmentUniformVectors _translator_gl_MaxFragmentUniformVectors\n"
"#define gl_MaxVaryingVectors _translator_gl_MaxVaryingVectors\n"
"#line 1\n"
"varying lowp vec2 outCoord;\n"
"uniform sampler2D texture;\n"
"void main(void) {\n"
" gl_FragColor = texture2D(texture, outCoord);\n"
"}\n";
// Hard-coded arrays of vertex information.
struct Vertex {
float pos[3];
float coord[2];
};
const Vertex kVertices[] = {
{{ +1, -1, +0 }, { +1, +1 }},
{{ +1, +1, +0 }, { +1, +0 }},
{{ -1, +1, +0 }, { +0, +0 }},
{{ -1, -1, +0 }, { +0, +1 }},
};
const GLubyte kIndices[] = { 0, 1, 2, 2, 3, 0 };
const GLint kIndicesLen = sizeof(kIndices) / sizeof(kIndices[0]);
} // namespace
TextureDraw::TextureDraw(EGLDisplay display) :
mDisplay(display),
mVertexShader(0),
mFragmentShader(0),
mProgram(0),
mPositionSlot(-1),
mInCoordSlot(-1),
mTextureSlot(-1),
mRotationSlot(-1),
mTranslationSlot(-1) {
// Create shaders and program.
mVertexShader = createShader(GL_VERTEX_SHADER, kVertexShaderSource);
mFragmentShader = createShader(GL_FRAGMENT_SHADER, kFragmentShaderSource);
mProgram = s_gles2.glCreateProgram();
s_gles2.glAttachShader(mProgram, mVertexShader);
s_gles2.glAttachShader(mProgram, mFragmentShader);
GLint success;
s_gles2.glLinkProgram(mProgram);
s_gles2.glGetProgramiv(mProgram, GL_LINK_STATUS, &success);
if (success == GL_FALSE) {
GLchar messages[256];
s_gles2.glGetProgramInfoLog(
mProgram, sizeof(messages), 0, &messages[0]);
ERR("%s: Could not create/link program: %s\n", __FUNCTION__, messages);
s_gles2.glDeleteProgram(mProgram);
mProgram = 0;
return;
}
s_gles2.glUseProgram(mProgram);
// Retrieve attribute/uniform locations.
mPositionSlot = s_gles2.glGetAttribLocation(mProgram, "position");
s_gles2.glEnableVertexAttribArray(mPositionSlot);
mInCoordSlot = s_gles2.glGetAttribLocation(mProgram, "inCoord");
s_gles2.glEnableVertexAttribArray(mInCoordSlot);
mRotationSlot = s_gles2.glGetUniformLocation(mProgram, "rotation");
mTranslationSlot = s_gles2.glGetUniformLocation(mProgram, "translation");
mTextureSlot = s_gles2.glGetUniformLocation(mProgram, "texture");
#if 0
printf("SLOTS position=%d inCoord=%d texture=%d rotation=%d\n",
mPositionSlot, mInCoordSlot, mTextureSlot, mRotationSlot);
#endif
// Create vertex and index buffers.
s_gles2.glGenBuffers(1, &mVertexBuffer);
s_gles2.glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
s_gles2.glBufferData(
GL_ARRAY_BUFFER, sizeof(kVertices), kVertices, GL_STATIC_DRAW);
s_gles2.glGenBuffers(1, &mIndexBuffer);
s_gles2.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer);
s_gles2.glBufferData(GL_ELEMENT_ARRAY_BUFFER,
sizeof(kIndices),
kIndices,
GL_STATIC_DRAW);
}
bool TextureDraw::draw(GLuint texture, float rotation, float dx, float dy) {
if (!mProgram) {
ERR("%s: no program\n", __FUNCTION__);
return false;
}
// TODO(digit): Save previous program state.
GLenum err;
s_gles2.glUseProgram(mProgram);
err = s_gles2.glGetError();
if (err != GL_NO_ERROR) {
ERR("%s: Could not use program error=0x%x\n",
__FUNCTION__, err);
}
// Setup the |position| attribute values.
s_gles2.glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
err = s_gles2.glGetError();
if (err != GL_NO_ERROR) {
ERR("%s: Could not bind GL_ARRAY_BUFFER error=0x%x\n",
__FUNCTION__, err);
}
s_gles2.glEnableVertexAttribArray(mPositionSlot);
s_gles2.glVertexAttribPointer(mPositionSlot,
3,
GL_FLOAT,
GL_FALSE,
sizeof(Vertex),
0);
err = s_gles2.glGetError();
if (err != GL_NO_ERROR) {
ERR("%s: Could glVertexAttribPointer with mPositionSlot error=0x%x\n",
__FUNCTION__, err);
}
// Setup the |inCoord| attribute values.
s_gles2.glEnableVertexAttribArray(mInCoordSlot);
s_gles2.glVertexAttribPointer(mInCoordSlot,
2,
GL_FLOAT,
GL_FALSE,
sizeof(Vertex),
reinterpret_cast<GLvoid*>(
static_cast<uintptr_t>(
sizeof(float) * 3)));
// setup the |texture| uniform value.
s_gles2.glActiveTexture(GL_TEXTURE0);
s_gles2.glBindTexture(GL_TEXTURE_2D, texture);
s_gles2.glUniform1i(mTextureSlot, 0);
// setup the |rotation| uniform value.
s_gles2.glUniform1f(mRotationSlot, rotation * M_PI / 180.);
s_gles2.glUniform2f(mTranslationSlot, dx, dy);
#if 1
// Validate program, just to be sure.
s_gles2.glValidateProgram(mProgram);
GLint validState = 0;
s_gles2.glGetProgramiv(mProgram, GL_VALIDATE_STATUS, &validState);
if (validState == GL_FALSE) {
GLchar messages[256];
s_gles2.glGetProgramInfoLog(
mProgram, sizeof(messages), 0, &messages[0]);
ERR("%s: Could not run program: %s\n", __FUNCTION__, messages);
return false;
}
#endif
// Do the rendering.
s_gles2.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer);
err = s_gles2.glGetError();
if (err != GL_NO_ERROR) {
ERR("%s: Could not glBindBuffer(GL_ELEMENT_ARRAY_BUFFER) error=0x%x\n",
__FUNCTION__, err);
}
s_gles2.glDrawElements(GL_TRIANGLES, kIndicesLen, GL_UNSIGNED_BYTE, 0);
err = s_gles2.glGetError();
if (err != GL_NO_ERROR) {
ERR("%s: Could not glDrawElements() error=0x%x\n",
__FUNCTION__, err);
}
// TODO(digit): Restore previous program state.
return true;
}
TextureDraw::~TextureDraw() {
s_gles2.glDeleteBuffers(1, &mIndexBuffer);
s_gles2.glDeleteBuffers(1, &mVertexBuffer);
if (mFragmentShader) {
s_gles2.glDeleteShader(mFragmentShader);
}
if (mVertexShader) {
s_gles2.glDeleteShader(mVertexShader);
}
}

View file

@ -0,0 +1,61 @@
// Copyright (C) 2015 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef TEXTURE_DRAW_H
#define TEXTURE_DRAW_H
#include <EGL/egl.h>
#include <GLES2/gl2.h>
// Helper class used to draw a simple texture to the current framebuffer.
// Usage is pretty simple:
//
// 1) Create a TextureDraw instance, passing the current EGLDisplay to it.
//
// 2) Each time you want to draw a texture, call draw(texture, rotation),
// where |texture| is the name of a GLES 2.x texture object, and
// |rotation| is an angle in degrees describing the clockwise rotation
// in the GL y-upwards coordinate space. This function fills the whole
// framebuffer with texture content.
//
class TextureDraw {
public:
// Create a new instance.
TextureDraw(EGLDisplay display);
// Destructor
~TextureDraw();
// Fill the current framebuffer with the content of |texture|, which must
// be the name of a GLES 2.x texture object. |rotationDegrees| is a
// clockwise rotation angle in degrees (clockwise in the GL Y-upwards
// coordinate space). |dx,dy| is the translation of the image towards the
// origin.
bool draw(GLuint texture, float rotationDegrees, float dx, float dy);
private:
EGLDisplay mDisplay;
GLuint mVertexShader;
GLuint mFragmentShader;
GLuint mProgram;
GLint mPositionSlot;
GLint mInCoordSlot;
GLint mTextureSlot;
GLint mRotationSlot;
GLint mTranslationSlot;
GLuint mVertexBuffer;
GLuint mIndexBuffer;
};
#endif // TEXTURE_DRAW_H

View file

@ -0,0 +1,344 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "TextureResize.h"
#include "DispatchTables.h"
#include <stdio.h>
#include <sstream>
#include <string>
#include <utility>
#define ERR(...) fprintf(stderr, __VA_ARGS__)
#define MAX_FACTOR_POWER 4
static const char kCommonShaderSource[] =
"precision mediump float;\n"
"varying vec2 vUV00, vUV01;\n"
"#if FACTOR > 2\n"
"varying vec2 vUV02, vUV03;\n"
"#if FACTOR > 4\n"
"varying vec2 vUV04, vUV05, vUV06, vUV07;\n"
"#if FACTOR > 8\n"
"varying vec2 vUV08, vUV09, vUV10, vUV11, vUV12, vUV13, vUV14, vUV15;\n"
"#endif\n"
"#endif\n"
"#endif\n";
static const char kVertexShaderSource[] =
"attribute vec2 aPosition;\n"
"void main() {\n"
" gl_Position = vec4(aPosition, 0, 1);\n"
" vec2 uv = ((aPosition + 1.0) / 2.0) + 0.5 / kDimension;\n"
" vUV00 = uv;\n"
" #ifdef HORIZONTAL\n"
" vUV01 = uv + vec2( 1.0 / kDimension.x, 0);\n"
" #if FACTOR > 2\n"
" vUV02 = uv + vec2( 2.0 / kDimension.x, 0);\n"
" vUV03 = uv + vec2( 3.0 / kDimension.x, 0);\n"
" #if FACTOR > 4\n"
" vUV04 = uv + vec2( 4.0 / kDimension.x, 0);\n"
" vUV05 = uv + vec2( 5.0 / kDimension.x, 0);\n"
" vUV06 = uv + vec2( 6.0 / kDimension.x, 0);\n"
" vUV07 = uv + vec2( 7.0 / kDimension.x, 0);\n"
" #if FACTOR > 8\n"
" vUV08 = uv + vec2( 8.0 / kDimension.x, 0);\n"
" vUV09 = uv + vec2( 9.0 / kDimension.x, 0);\n"
" vUV10 = uv + vec2(10.0 / kDimension.x, 0);\n"
" vUV11 = uv + vec2(11.0 / kDimension.x, 0);\n"
" vUV12 = uv + vec2(12.0 / kDimension.x, 0);\n"
" vUV13 = uv + vec2(13.0 / kDimension.x, 0);\n"
" vUV14 = uv + vec2(14.0 / kDimension.x, 0);\n"
" vUV15 = uv + vec2(15.0 / kDimension.x, 0);\n"
" #endif\n" // FACTOR > 8
" #endif\n" // FACTOR > 4
" #endif\n" // FACTOR > 2
" #else\n"
" vUV01 = uv + vec2(0, 1.0 / kDimension.y);\n"
" #if FACTOR > 2\n"
" vUV02 = uv + vec2(0, 2.0 / kDimension.y);\n"
" vUV03 = uv + vec2(0, 3.0 / kDimension.y);\n"
" #if FACTOR > 4\n"
" vUV04 = uv + vec2(0, 4.0 / kDimension.y);\n"
" vUV05 = uv + vec2(0, 5.0 / kDimension.y);\n"
" vUV06 = uv + vec2(0, 6.0 / kDimension.y);\n"
" vUV07 = uv + vec2(0, 7.0 / kDimension.y);\n"
" #if FACTOR > 8\n"
" vUV08 = uv + vec2(0, 8.0 / kDimension.y);\n"
" vUV09 = uv + vec2(0, 9.0 / kDimension.y);\n"
" vUV10 = uv + vec2(0, 10.0 / kDimension.y);\n"
" vUV11 = uv + vec2(0, 11.0 / kDimension.y);\n"
" vUV12 = uv + vec2(0, 12.0 / kDimension.y);\n"
" vUV13 = uv + vec2(0, 13.0 / kDimension.y);\n"
" vUV14 = uv + vec2(0, 14.0 / kDimension.y);\n"
" vUV15 = uv + vec2(0, 15.0 / kDimension.y);\n"
" #endif\n" // FACTOR > 8
" #endif\n" // FACTOR > 4
" #endif\n" // FACTOR > 2
" #endif\n" // HORIZONTAL/VERTICAL
"}\n";
const char kFragmentShaderSource[] =
"uniform sampler2D uTexture;\n"
"vec4 read(vec2 uv) {\n"
" vec4 r = texture2D(uTexture, uv);\n"
" #ifdef HORIZONTAL\n"
" r.rgb = pow(r.rgb, vec3(2.2));\n"
" #endif\n"
" return r;\n"
"}\n"
"void main() {\n"
" vec4 sum = read(vUV00) + read(vUV01);\n"
" #if FACTOR > 2\n"
" sum += read(vUV02) + read(vUV03);\n"
" #if FACTOR > 4\n"
" sum += read(vUV04) + read(vUV05) + read(vUV06) + read(vUV07);\n"
" #if FACTOR > 8\n"
" sum += read(vUV08) + read(vUV09) + read(vUV10) + read(vUV11) +"
" read(vUV12) + read(vUV13) + read(vUV14) + read(vUV15);\n"
" #endif\n"
" #endif\n"
" #endif\n"
" sum /= float(FACTOR);\n"
" #ifdef VERTICAL\n"
" sum.rgb = pow(sum.rgb, vec3(1.0 / 2.2));\n"
" #endif\n"
" gl_FragColor = sum;\n"
"}\n";
static const float kVertexData[] = {-1, -1, 3, -1, -1, 3};
static void detachShaders(GLuint program) {
GLuint shaders[2] = {};
GLsizei count = 0;
s_gles2.glGetAttachedShaders(program, 2, &count, shaders);
if (s_gles2.glGetError() == GL_NO_ERROR) {
for (GLsizei i = 0; i < count; i++) {
s_gles2.glDetachShader(program, shaders[i]);
s_gles2.glDeleteShader(shaders[i]);
}
}
}
static GLuint createShader(GLenum type, const std::initializer_list<const char*>& source) {
GLint success, infoLength;
GLuint shader = s_gles2.glCreateShader(type);
if (shader) {
s_gles2.glShaderSource(shader, source.size(), source.begin(), nullptr);
s_gles2.glCompileShader(shader);
s_gles2.glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
if (success == GL_FALSE) {
s_gles2.glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLength);
std::string infoLog(infoLength + 1, '\0');
s_gles2.glGetShaderInfoLog(shader, infoLength, nullptr, &infoLog[0]);
ERR("%s shader compile failed:\n%s\n",
(type == GL_VERTEX_SHADER) ? "Vertex" : "Fragment",
infoLog.c_str());
s_gles2.glDeleteShader(shader);
shader = 0;
}
}
return shader;
}
static void attachShaders(TextureResize::Framebuffer* fb, const char* factorDefine,
const char* dimensionDefine, GLuint width, GLuint height) {
std::ostringstream dimensionConst;
dimensionConst << "const vec2 kDimension = vec2(" << width << ", " << height << ");\n";
GLuint vShader = createShader(GL_VERTEX_SHADER, {
factorDefine, dimensionDefine,
kCommonShaderSource, dimensionConst.str().c_str(), kVertexShaderSource
});
GLuint fShader = createShader(GL_FRAGMENT_SHADER, {
factorDefine, dimensionDefine, kCommonShaderSource, kFragmentShaderSource
});
if (!vShader || !fShader) {
return;
}
s_gles2.glAttachShader(fb->program, vShader);
s_gles2.glAttachShader(fb->program, fShader);
s_gles2.glLinkProgram(fb->program);
s_gles2.glUseProgram(fb->program);
fb->aPosition = s_gles2.glGetAttribLocation(fb->program, "aPosition");
fb->uTexture = s_gles2.glGetUniformLocation(fb->program, "uTexture");
}
TextureResize::TextureResize(GLuint width, GLuint height) :
mWidth(width),
mHeight(height),
mFactor(1),
mFBWidth({0,}),
mFBHeight({0,}) {
s_gles2.glGenTextures(1, &mFBWidth.texture);
s_gles2.glBindTexture(GL_TEXTURE_2D, mFBWidth.texture);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
s_gles2.glGenTextures(1, &mFBHeight.texture);
s_gles2.glBindTexture(GL_TEXTURE_2D, mFBHeight.texture);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
s_gles2.glGenFramebuffers(1, &mFBWidth.framebuffer);
s_gles2.glGenFramebuffers(1, &mFBHeight.framebuffer);
mFBWidth.program = s_gles2.glCreateProgram();
mFBHeight.program = s_gles2.glCreateProgram();
s_gles2.glGenBuffers(1, &mVertexBuffer);
s_gles2.glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
s_gles2.glBufferData(GL_ARRAY_BUFFER, sizeof(kVertexData), kVertexData, GL_STATIC_DRAW);
}
TextureResize::~TextureResize() {
GLuint fb[2] = {mFBWidth.framebuffer, mFBHeight.framebuffer};
s_gles2.glDeleteFramebuffers(2, fb);
GLuint tex[2] = {mFBWidth.texture, mFBHeight.texture};
s_gles2.glDeleteTextures(2, tex);
s_gles2.glDeleteProgram(mFBWidth.program);
s_gles2.glDeleteProgram(mFBHeight.program);
s_gles2.glDeleteBuffers(1, &mVertexBuffer);
}
GLuint TextureResize::update(GLuint texture) {
// Store the viewport. The viewport is clobbered due to the framebuffers.
GLint vport[4] = { 0, };
s_gles2.glGetIntegerv(GL_VIEWPORT, vport);
// Correctly deal with rotated screens.
GLint tWidth = vport[2], tHeight = vport[3];
if ((mWidth < mHeight) != (tWidth < tHeight)) {
std::swap(tWidth, tHeight);
}
// Compute the scaling factor needed to get an image just larger than the target viewport.
unsigned int factor = 1;
for (int i = 0, w = mWidth / 2, h = mHeight / 2;
i < MAX_FACTOR_POWER && w >= tWidth && h >= tHeight;
i++, w /= 2, h /= 2, factor *= 2) {
}
// No resizing needed.
if (factor == 1) {
return texture;
}
s_gles2.glGetError(); // Clear any GL errors.
setupFramebuffers(factor);
resize(texture);
s_gles2.glViewport(vport[0], vport[1], vport[2], vport[3]); // Restore the viewport.
// If there was an error while resizing, just use the unscaled texture.
GLenum error = s_gles2.glGetError();
if (error != GL_NO_ERROR) {
ERR("GL error while resizing: 0x%x (ignored)\n", error);
return texture;
}
return mFBHeight.texture;
}
void TextureResize::setupFramebuffers(unsigned int factor) {
if (factor == mFactor) {
// The factor hasn't changed, no need to update the framebuffers.
return;
}
// Update the framebuffer sizes to match the new factor.
s_gles2.glBindTexture(GL_TEXTURE_2D, mFBWidth.texture);
s_gles2.glTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA, mWidth / factor, mHeight, 0, GL_RGBA, GL_FLOAT, nullptr);
s_gles2.glBindFramebuffer(GL_FRAMEBUFFER, mFBWidth.framebuffer);
s_gles2.glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mFBWidth.texture, 0);
s_gles2.glBindTexture(GL_TEXTURE_2D, mFBHeight.texture);
s_gles2.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mWidth / factor, mHeight / factor, 0, GL_RGBA,
GL_UNSIGNED_BYTE, nullptr);
s_gles2.glBindFramebuffer(GL_FRAMEBUFFER, mFBHeight.framebuffer);
s_gles2.glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mFBHeight.texture, 0);
// Update the shaders to the new factor. First detach the old shaders...
detachShaders(mFBWidth.program);
detachShaders(mFBHeight.program);
// ... then attach the new ones.
std::ostringstream factorDefine;
factorDefine << "#define FACTOR " << factor << "\n";
attachShaders(&mFBWidth, factorDefine.str().c_str(), "#define HORIZONTAL\n", mWidth, mHeight);
attachShaders(&mFBHeight, factorDefine.str().c_str(), "#define VERTICAL\n", mWidth, mHeight);
mFactor = factor;
}
void TextureResize::resize(GLuint texture) {
s_gles2.glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
s_gles2.glActiveTexture(GL_TEXTURE0);
// First scale the horizontal dimension by rendering the input texture to a scaled framebuffer.
s_gles2.glBindFramebuffer(GL_FRAMEBUFFER, mFBWidth.framebuffer);
s_gles2.glViewport(0, 0, mWidth / mFactor, mHeight);
s_gles2.glUseProgram(mFBWidth.program);
s_gles2.glEnableVertexAttribArray(mFBWidth.aPosition);
s_gles2.glVertexAttribPointer(mFBWidth.aPosition, 2, GL_FLOAT, GL_FALSE, 0, 0);
s_gles2.glBindTexture(GL_TEXTURE_2D, texture);
// Store the current texture filters and set to nearest for scaling.
GLint mag_filter, min_filter;
s_gles2.glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &mag_filter);
s_gles2.glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &min_filter);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
s_gles2.glUniform1i(mFBWidth.uTexture, 0);
s_gles2.glDrawArrays(GL_TRIANGLES, 0, sizeof(kVertexData) / (2 * sizeof(float)));
// Restore the previous texture filters.
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
s_gles2.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
// Secondly, scale the vertical dimension using the second framebuffer.
s_gles2.glBindFramebuffer(GL_FRAMEBUFFER, mFBHeight.framebuffer);
s_gles2.glViewport(0, 0, mWidth / mFactor, mHeight / mFactor);
s_gles2.glUseProgram(mFBHeight.program);
s_gles2.glEnableVertexAttribArray(mFBHeight.aPosition);
s_gles2.glVertexAttribPointer(mFBHeight.aPosition, 2, GL_FLOAT, GL_FALSE, 0, 0);
s_gles2.glBindTexture(GL_TEXTURE_2D, mFBWidth.texture);
s_gles2.glUniform1i(mFBHeight.uTexture, 0);
s_gles2.glDrawArrays(GL_TRIANGLES, 0, sizeof(kVertexData) / (2 * sizeof(float)));
// Clear the bindings.
s_gles2.glBindBuffer(GL_ARRAY_BUFFER, 0);
s_gles2.glBindFramebuffer(GL_FRAMEBUFFER, 0);
s_gles2.glBindTexture(GL_TEXTURE_2D, 0);
}

View file

@ -0,0 +1,51 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBRENDER_TEXTURERESIZE_H
#define _LIBRENDER_TEXTURERESIZE_H
#include <GLES2/gl2.h>
class TextureResize {
public:
TextureResize(GLuint width, GLuint height);
~TextureResize();
// Scales the given texture for the current viewport and returns the scaled
// texture. May return the input if no scaling is required.
GLuint update(GLuint texture);
struct Framebuffer {
GLuint texture;
GLuint framebuffer;
GLuint program;
GLuint aPosition;
GLuint uTexture;
};
private:
void setupFramebuffers(unsigned int factor);
void resize(GLuint texture);
private:
GLuint mWidth;
GLuint mHeight;
unsigned int mFactor;
Framebuffer mFBWidth;
Framebuffer mFBHeight;
GLuint mVertexBuffer;
};
#endif

View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "TimeUtils.h"
#ifdef _WIN32
#include <windows.h>
#include <time.h>
#include <stdio.h>
#elif defined(__linux__)
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#else
#include <sys/time.h>
#include <unistd.h>
#endif
long long GetCurrentTimeMS()
{
#ifdef _WIN32
static LARGE_INTEGER freq;
static bool bNotInit = true;
if ( bNotInit ) {
bNotInit = (QueryPerformanceFrequency( &freq ) == FALSE);
}
LARGE_INTEGER currVal;
QueryPerformanceCounter( &currVal );
return currVal.QuadPart / (freq.QuadPart / 1000);
#elif defined(__linux__)
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
long long iDiff = (now.tv_sec * 1000LL) + now.tv_nsec/1000000LL;
return iDiff;
#else /* Others, e.g. OS X */
struct timeval now;
gettimeofday(&now, NULL);
long long iDiff = (now.tv_sec * 1000LL) + now.tv_usec/1000LL;
return iDiff;
#endif
}
void TimeSleepMS(int p_mili)
{
#ifdef _WIN32
Sleep(p_mili);
#else
usleep(p_mili * 1000);
#endif
}

View file

@ -0,0 +1,22 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _TIME_UTILS_H
#define _TIME_UTILS_H
long long GetCurrentTimeMS();
void TimeSleepMS(int p_mili);
#endif

View file

@ -0,0 +1,174 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "UnixStream.h"
#include "emugl/common/sockets.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/un.h>
#include <sys/stat.h>
/* Not all systems define PATH_MAX, those who don't generally don't
* have a limit on the maximum path size, so use a value that is
* large enough for our very limited needs.
*/
#ifndef PATH_MAX
#define PATH_MAX 128
#endif
UnixStream::UnixStream(size_t bufSize) :
SocketStream(bufSize),
bound_socket_path(NULL)
{
}
UnixStream::UnixStream(int sock, size_t bufSize) :
SocketStream(sock, bufSize),
bound_socket_path(NULL)
{
}
UnixStream::~UnixStream()
{
if (bound_socket_path != NULL) {
int ret = 0;
do {
ret = unlink(bound_socket_path);
} while (ret < 0 && errno == EINTR);
if(ret != 0) {
ERR("Failed to unlink UNIX socket at \"%s\"\n", bound_socket_path);
perror("UNIX socket could not be unlinked");
}
free(bound_socket_path);
}
}
/* Initialize a sockaddr_un with the appropriate values corresponding
* to a given 'virtual port'. Returns 0 on success, -1 on error.
*/
static int
make_unix_path(char *path, size_t pathlen, int port_number)
{
char tmp[PATH_MAX]; // temp directory
int ret = 0;
// First, create user-specific temp directory if needed
const char* user = getenv("XDG_RUNTIME_DIR");
if (user != NULL) {
struct stat st;
snprintf(tmp, sizeof(tmp), "%s/anbox", user);
do {
ret = ::lstat(tmp, &st);
} while (ret < 0 && errno == EINTR);
if (ret < 0 && errno == ENOENT) {
do {
ret = ::mkdir(tmp, 0766);
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
ERR("Could not create temp directory: %s", tmp);
user = NULL; // will fall-back to /tmp
}
}
else if (ret < 0) {
user = NULL; // will fallback to /tmp
}
}
if (user == NULL) { // fallback to /tmp in case of error
snprintf(tmp, sizeof(tmp), "/tmp");
}
// Now, initialize it properly
snprintf(path, pathlen, "%s/qemu-gles-%d", tmp, port_number);
// If the emulator is killed, it can leave the socket file behind.
// Since the filename has PID in it, we can be sure that this socket
// is not supposed to be here and delete it, to prevent EADDRINUSE
// later in bind()
if (::access(path, F_OK) == 0) {
ret = ::remove(path);
if (ret < 0) {
ERR("Failed to remove stale socket file at %s: %s\n", path, strerror(errno));
} else {
DBG("Stale socket file at %s was removed.\n", path);
}
}
return 0;
}
int UnixStream::listen(char addrstr[MAX_ADDRSTR_LEN])
{
if (make_unix_path(addrstr, MAX_ADDRSTR_LEN, getpid()) < 0) {
return -1;
}
m_sock = emugl::socketLocalServer(addrstr, SOCK_STREAM);
if (!valid())
return int(ERR_INVALID_SOCKET);
bound_socket_path = strdup(addrstr);
if(bound_socket_path == NULL) {
ERR("WARNING: UNIX socket at \"%s\" should be manually removed \n",
addrstr);
return -1;
}
return 0;
}
SocketStream * UnixStream::accept()
{
int clientSock = -1;
while (true) {
struct sockaddr_un addr;
socklen_t len = sizeof(addr);
clientSock = ::accept(m_sock, (sockaddr *)&addr, &len);
// DBG("UnixStream::accept @ %d \n", clientSock);
if (clientSock < 0 && errno == EINTR) {
continue;
}
break;
}
UnixStream *clientStream = NULL;
if (clientSock >= 0) {
clientStream = new UnixStream(clientSock, m_bufsize);
}
return clientStream;
}
int UnixStream::connect(const char* addr)
{
m_sock = emugl::socketLocalClient(addr, SOCK_STREAM);
// DBG("UnixStream::connect @ %d \n", m_sock);
if (!valid()) return -1;
return 0;
}

View file

@ -0,0 +1,33 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __UNIX_STREAM_H
#define __UNIX_STREAM_H
#include "SocketStream.h"
class UnixStream : public SocketStream {
public:
explicit UnixStream(size_t bufsize = 10000);
~UnixStream();
virtual int listen(char addrstr[MAX_ADDRSTR_LEN]);
virtual SocketStream *accept();
virtual int connect(const char* addr);
private:
char *bound_socket_path;
UnixStream(int sock, size_t bufSize);
};
#endif

View file

@ -0,0 +1,241 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "Win32PipeStream.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <windows.h>
#ifndef _WIN32
#error ONLY BUILD THIS SOURCE FILE FOR WINDOWS!
#endif
/* The official documentation states that the name of a given named
* pipe cannot be more than 256 characters long.
*/
#define NAMED_PIPE_MAX 256
Win32PipeStream::Win32PipeStream(size_t bufSize) :
SocketStream(bufSize),
m_pipe(INVALID_HANDLE_VALUE)
{
}
Win32PipeStream::Win32PipeStream(HANDLE pipe, size_t bufSize) :
SocketStream(-1, bufSize),
m_pipe(pipe)
{
}
Win32PipeStream::~Win32PipeStream()
{
if (m_pipe != INVALID_HANDLE_VALUE) {
CloseHandle(m_pipe);
m_pipe = INVALID_HANDLE_VALUE;
}
}
/* Initialize the pipe name corresponding to a given port
*/
static void
make_pipe_name(char *path, size_t pathlen, int port_number)
{
snprintf(path, pathlen, "\\\\.\\pipe\\qemu-gles-%d", port_number);
}
/* Technical note: Named pipes work differently from BSD Sockets.
* One does not create/bind a pipe, and collect a new handle each
* time a client connects with accept().
*
* Instead, the server creates a new pipe instance each time it wants
* to get a new client connection, then calls ConnectNamedPipe() to
* wait for a connection.
*
* So listen() is a no-op, and accept() really creates the pipe handle.
*
* Also, connect() must create a pipe handle with CreateFile() and
* wait for a server instance with WaitNamedPipe()
*/
int Win32PipeStream::listen(char addrstr[MAX_ADDRSTR_LEN])
{
m_port = GetCurrentProcessId();
make_pipe_name(addrstr, MAX_ADDRSTR_LEN, m_port);
return 0;
}
SocketStream * Win32PipeStream::accept()
{
char path[NAMED_PIPE_MAX+1];
SocketStream* clientStream;
HANDLE pipe;
make_pipe_name(path, sizeof(path), m_port);
pipe = ::CreateNamedPipe(
path, // pipe name
PIPE_ACCESS_DUPLEX, // read-write access
PIPE_TYPE_BYTE | // byte-oriented writes
PIPE_READMODE_BYTE | // byte-oriented reads
PIPE_WAIT, // blocking operations
PIPE_UNLIMITED_INSTANCES, // no limit on clients
4096, // input buffer size
4096, // output buffer size
0, // client time-out
NULL); // default security attributes
if (pipe == INVALID_HANDLE_VALUE) {
ERR("%s: CreateNamedPipe failed %d\n", __FUNCTION__, (int)GetLastError());
return NULL;
}
// Stupid Win32 API design: If a client is already connected, then
// ConnectNamedPipe will return 0, and GetLastError() will return
// ERROR_PIPE_CONNECTED. This is not an error! It just means that the
// function didn't have to wait.
//
if (::ConnectNamedPipe(pipe, NULL) == 0 && GetLastError() != ERROR_PIPE_CONNECTED) {
ERR("%s: ConnectNamedPipe failed: %d\n", __FUNCTION__, (int)GetLastError());
CloseHandle(pipe);
return NULL;
}
clientStream = new Win32PipeStream(pipe, m_bufsize);
return clientStream;
}
int Win32PipeStream::connect(const char* addr)
{
HANDLE pipe;
int tries = 10;
/* We're going to loop in order to wait for the pipe server to
* be setup properly.
*/
for (; tries > 0; tries--) {
pipe = ::CreateFile(
addr, // pipe name
GENERIC_READ | GENERIC_WRITE, // read & write
0, // no sharing
NULL, // default security attrs
OPEN_EXISTING, // open existing pipe
0, // default attributes
NULL); // no template file
/* If we have a valid pipe handle, break from the loop */
if (pipe != INVALID_HANDLE_VALUE) {
break;
}
/* We can get here if the pipe is busy, i.e. if the server hasn't
* create a new pipe instance to service our request. In which case
* GetLastError() will return ERROR_PIPE_BUSY.
*
* If so, then use WaitNamedPipe() to wait for a decent time
* to try again.
*/
if (GetLastError() != ERROR_PIPE_BUSY) {
/* Not ERROR_PIPE_BUSY */
ERR("%s: CreateFile failed: %d\n", __FUNCTION__, (int)GetLastError());
errno = EINVAL;
return -1;
}
/* Wait for 5 seconds */
if ( !WaitNamedPipe(addr, 5000) ) {
ERR("%s: WaitNamedPipe failed: %d\n", __FUNCTION__, (int)GetLastError());
errno = EINVAL;
return -1;
}
}
m_pipe = pipe;
return 0;
}
/* Special buffer methods, since we can't use socket functions here */
int Win32PipeStream::commitBuffer(size_t size)
{
if (m_pipe == INVALID_HANDLE_VALUE)
return -1;
size_t res = size;
int retval = 0;
while (res > 0) {
DWORD written;
if (! ::WriteFile(m_pipe, (const char *)m_buf + (size - res), res, &written, NULL)) {
retval = -1;
ERR("%s: failed: %d\n", __FUNCTION__, (int)GetLastError());
break;
}
res -= written;
}
return retval;
}
const unsigned char *Win32PipeStream::readFully(void *buf, size_t len)
{
if (m_pipe == INVALID_HANDLE_VALUE)
return NULL;
if (!buf) {
return NULL; // do not allow NULL buf in that implementation
}
size_t res = len;
while (res > 0) {
DWORD readcount = 0;
if (! ::ReadFile(m_pipe, (char *)buf + (len - res), res, &readcount, NULL) || readcount == 0) {
errno = (int)GetLastError();
return NULL;
}
res -= readcount;
}
return (const unsigned char *)buf;
}
const unsigned char *Win32PipeStream::read( void *buf, size_t *inout_len)
{
size_t len = *inout_len;
DWORD readcount;
if (m_pipe == INVALID_HANDLE_VALUE)
return NULL;
if (!buf) {
return NULL; // do not allow NULL buf in that implementation
}
if (!::ReadFile(m_pipe, (char *)buf, len, &readcount, NULL)) {
errno = (int)GetLastError();
return NULL;
}
*inout_len = (size_t)readcount;
return (const unsigned char *)buf;
}
void Win32PipeStream::forceStop()
{
HANDLE handle = m_pipe;
m_pipe = INVALID_HANDLE_VALUE;
CloseHandle(handle);
}

View file

@ -0,0 +1,42 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __WIN32_PIPE_STREAM_H
#define __WIN32_PIPE_STREAM_H
#include "SocketStream.h"
#include <windows.h>
class Win32PipeStream : public SocketStream {
public:
explicit Win32PipeStream(size_t bufsize = 10000);
virtual ~Win32PipeStream();
virtual int listen(char addrstr[MAX_ADDRSTR_LEN]);
virtual SocketStream *accept();
virtual int connect(const char* addr);
virtual int commitBuffer(size_t size);
virtual const unsigned char *readFully(void *buf, size_t len);
virtual const unsigned char *read(void *buf, size_t *inout_len);
virtual void forceStop();
private:
Win32PipeStream(HANDLE pipe, size_t bufSize);
HANDLE m_pipe;
int m_port;
};
#endif

View file

@ -0,0 +1,187 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "WindowSurface.h"
#include "ErrorLog.h"
#include "FbConfig.h"
#include "OpenGLESDispatch/EGLDispatch.h"
#include <GLES/glext.h>
#include <stdio.h>
#include <string.h>
WindowSurface::WindowSurface(EGLDisplay display,
EGLConfig config) :
mSurface(NULL),
mAttachedColorBuffer(NULL),
mReadContext(NULL),
mDrawContext(NULL),
mWidth(0),
mHeight(0),
mConfig(config),
mDisplay(display) {}
WindowSurface::~WindowSurface() {
if (mSurface) {
s_egl.eglDestroySurface(mDisplay, mSurface);
}
}
WindowSurface *WindowSurface::create(EGLDisplay display,
EGLConfig config,
int p_width,
int p_height) {
// allocate space for the WindowSurface object
WindowSurface *win = new WindowSurface(display, config);
if (!win) {
return NULL;
}
// Create a pbuffer to be used as the egl surface
// for that window.
if (!win->resize(p_width, p_height)) {
delete win;
return NULL;
}
return win;
}
void WindowSurface::setColorBuffer(ColorBufferPtr p_colorBuffer) {
mAttachedColorBuffer = p_colorBuffer;
// resize the window if the attached color buffer is of different
// size.
unsigned int cbWidth = mAttachedColorBuffer->getWidth();
unsigned int cbHeight = mAttachedColorBuffer->getHeight();
if (cbWidth != mWidth || cbHeight != mHeight) {
resize(cbWidth, cbHeight);
}
}
void WindowSurface::bind(RenderContextPtr p_ctx, BindType p_bindType) {
if (p_bindType == BIND_READ) {
mReadContext = p_ctx;
} else if (p_bindType == BIND_DRAW) {
mDrawContext = p_ctx;
} else if (p_bindType == BIND_READDRAW) {
mReadContext = p_ctx;
mDrawContext = p_ctx;
}
}
bool WindowSurface::flushColorBuffer() {
if (!mAttachedColorBuffer.Ptr()) {
return true;
}
if (!mWidth || !mHeight) {
return false;
}
if (mAttachedColorBuffer->getWidth() != mWidth ||
mAttachedColorBuffer->getHeight() != mHeight) {
// XXX: should never happen - how this needs to be handled?
fprintf(stderr, "Dimensions do not match\n");
return false;
}
if (!mDrawContext.Ptr()) {
fprintf(stderr, "Draw context is NULL\n");
return false;
}
// Make the surface current
EGLContext prevContext = s_egl.eglGetCurrentContext();
EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ);
EGLSurface prevDrawSurf = s_egl.eglGetCurrentSurface(EGL_DRAW);
if (!s_egl.eglMakeCurrent(mDisplay,
mSurface,
mSurface,
mDrawContext->getEGLContext())) {
fprintf(stderr, "Error making draw context current\n");
return false;
}
mAttachedColorBuffer->blitFromCurrentReadBuffer();
// restore current context/surface
s_egl.eglMakeCurrent(mDisplay, prevDrawSurf, prevReadSurf, prevContext);
return true;
}
bool WindowSurface::resize(unsigned int p_width, unsigned int p_height)
{
if (mSurface && mWidth == p_width && mHeight == p_height) {
// no need to resize
return true;
}
EGLContext prevContext = s_egl.eglGetCurrentContext();
EGLSurface prevReadSurf = s_egl.eglGetCurrentSurface(EGL_READ);
EGLSurface prevDrawSurf = s_egl.eglGetCurrentSurface(EGL_DRAW);
EGLSurface prevPbuf = mSurface;
bool needRebindContext = mSurface &&
(prevReadSurf == mSurface ||
prevDrawSurf == mSurface);
if (needRebindContext) {
s_egl.eglMakeCurrent(
mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
//
// Destroy previous surface
//
if (mSurface) {
s_egl.eglDestroySurface(mDisplay, mSurface);
mSurface = NULL;
}
//
// Create pbuffer surface.
//
const EGLint pbufAttribs[5] = {
EGL_WIDTH, (EGLint) p_width, EGL_HEIGHT, (EGLint) p_height, EGL_NONE,
};
mSurface = s_egl.eglCreatePbufferSurface(mDisplay,
mConfig,
pbufAttribs);
if (mSurface == EGL_NO_SURFACE) {
fprintf(stderr, "Renderer error: failed to create/resize pbuffer!!\n");
return false;
}
mWidth = p_width;
mHeight = p_height;
if (needRebindContext) {
s_egl.eglMakeCurrent(
mDisplay,
(prevDrawSurf == prevPbuf) ? mSurface : prevDrawSurf,
(prevReadSurf == prevPbuf) ? mSurface : prevReadSurf,
prevContext);
}
return true;
}

View file

@ -0,0 +1,103 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _LIBRENDER_WINDOW_SURFACE_H
#define _LIBRENDER_WINDOW_SURFACE_H
#include "ColorBuffer.h"
#include "RenderContext.h"
#include "emugl/common/smart_ptr.h"
#include <EGL/egl.h>
#include <GLES/gl.h>
// A class used to model a guest-side window surface. The implementation
// uses a host Pbuffer to act as the EGL rendering surface instead.
class WindowSurface {
public:
// Create a new WindowSurface instance.
// |display| is the host EGLDisplay value.
// |config| is the host EGLConfig value.
// |width| and |height| are the initial size of the Pbuffer.
// Return a new WindowSurface instance on success, or NULL on failure.
static WindowSurface* create(EGLDisplay display,
EGLConfig config,
int width,
int height);
// Destructor.
~WindowSurface();
// Retrieve the host EGLSurface of the WindowSurface's Pbuffer.
EGLSurface getEGLSurface() const { return mSurface; }
// Attach a ColorBuffer to this WindowSurface.
// Once attached, calling flushColorBuffer() will copy the Pbuffer's
// pixels to the color buffer.
//
// IMPORTANT: This automatically resizes the Pbuffer's to the ColorBuffer's
// dimensions. Potentially losing pixel values in the process.
void setColorBuffer(ColorBufferPtr p_colorBuffer);
// Copy the Pbuffer's pixels to the attached color buffer.
// Returns true on success, or false on error (e.g. if there is no
// attached color buffer).
bool flushColorBuffer();
// Used by bind() below.
enum BindType {
BIND_READ,
BIND_DRAW,
BIND_READDRAW
};
// TODO(digit): What is this used for exactly? For example, the
// mReadContext is never used by this class. The mDrawContext is only
// used temporarily during flushColorBuffer() operation, and could be
// passed as a parameter to the function instead. Maybe this is only used
// to increment reference counts on the smart pointers.
//
// Bind a context to the WindowSurface (huh? Normally you would bind a
// surface to the context, not the other way around)
//
// |p_ctx| is a RenderContext pointer.
// |p_bindType| is the type of bind. For BIND_READ, this assigns |p_ctx|
// to mReadContext, for BIND_DRAW, it assigns it to mDrawContext, and for
// for BIND_READDRAW, it assigns it to both.
void bind(RenderContextPtr p_ctx, BindType p_bindType);
private:
WindowSurface();
WindowSurface(const WindowSurface& other);
explicit WindowSurface(EGLDisplay display, EGLConfig config);
bool resize(unsigned int p_width, unsigned int p_height);
private:
EGLSurface mSurface;
ColorBufferPtr mAttachedColorBuffer;
RenderContextPtr mReadContext;
RenderContextPtr mDrawContext;
GLuint mWidth;
GLuint mHeight;
EGLConfig mConfig;
EGLDisplay mDisplay;
};
typedef emugl::SmartPtr<WindowSurface> WindowSurfacePtr;
#endif // _LIBRENDER_WINDOW_SURFACE_H

Some files were not shown because too many files have changed in this diff Show more