1bf215546Sopenharmony_ci 2bf215546Sopenharmony_ci# (C) Copyright IBM Corporation 2004, 2005 3bf215546Sopenharmony_ci# All Rights Reserved. 4bf215546Sopenharmony_ci# 5bf215546Sopenharmony_ci# Permission is hereby granted, free of charge, to any person obtaining a 6bf215546Sopenharmony_ci# copy of this software and associated documentation files (the "Software"), 7bf215546Sopenharmony_ci# to deal in the Software without restriction, including without limitation 8bf215546Sopenharmony_ci# on the rights to use, copy, modify, merge, publish, distribute, sub 9bf215546Sopenharmony_ci# license, and/or sell copies of the Software, and to permit persons to whom 10bf215546Sopenharmony_ci# the Software is furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci# 12bf215546Sopenharmony_ci# The above copyright notice and this permission notice (including the next 13bf215546Sopenharmony_ci# paragraph) shall be included in all copies or substantial portions of the 14bf215546Sopenharmony_ci# Software. 15bf215546Sopenharmony_ci# 16bf215546Sopenharmony_ci# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17bf215546Sopenharmony_ci# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci# IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20bf215546Sopenharmony_ci# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21bf215546Sopenharmony_ci# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22bf215546Sopenharmony_ci# IN THE SOFTWARE. 23bf215546Sopenharmony_ci# 24bf215546Sopenharmony_ci# Authors: 25bf215546Sopenharmony_ci# Ian Romanick <idr@us.ibm.com> 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ciimport gl_XML, glX_XML 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ciclass glx_proto_item_factory(glX_XML.glx_item_factory): 31bf215546Sopenharmony_ci """Factory to create GLX protocol oriented objects derived from gl_item.""" 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci def create_type(self, element, context, category): 34bf215546Sopenharmony_ci return glx_proto_type(element, context, category) 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_ciclass glx_proto_type(gl_XML.gl_type): 38bf215546Sopenharmony_ci def __init__(self, element, context, category): 39bf215546Sopenharmony_ci gl_XML.gl_type.__init__(self, element, context, category) 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_ci self.glx_name = element.get( "glx_name" ) 42bf215546Sopenharmony_ci return 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_ciclass glx_print_proto(gl_XML.gl_print_base): 46bf215546Sopenharmony_ci def size_call(self, func, outputs_also = 0): 47bf215546Sopenharmony_ci """Create C code to calculate 'compsize'. 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci Creates code to calculate 'compsize'. If the function does 50bf215546Sopenharmony_ci not need 'compsize' to be calculated, None will be 51bf215546Sopenharmony_ci returned.""" 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci compsize = None 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci for param in func.parameterIterator(): 56bf215546Sopenharmony_ci if outputs_also or not param.is_output: 57bf215546Sopenharmony_ci if param.is_image(): 58bf215546Sopenharmony_ci [dim, w, h, d, junk] = param.get_dimensions() 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_ci compsize = '__glImageSize(%s, %s, %s, %s, %s, %s)' % (w, h, d, param.img_format, param.img_type, param.img_target) 61bf215546Sopenharmony_ci if not param.img_send_null: 62bf215546Sopenharmony_ci compsize = '(%s != NULL) ? %s : 0' % (param.name, compsize) 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci return compsize 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_ci elif len(param.count_parameter_list): 67bf215546Sopenharmony_ci parameters = ",".join( param.count_parameter_list ) 68bf215546Sopenharmony_ci compsize = "__gl%s_size(%s)" % (func.name, parameters) 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_ci return compsize 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_ci return None 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_ci def emit_packet_size_calculation(self, f, bias): 76bf215546Sopenharmony_ci # compsize is only used in the command size calculation if 77bf215546Sopenharmony_ci # the function has a non-output parameter that has a non-empty 78bf215546Sopenharmony_ci # counter_parameter_list. 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci compsize = self.size_call(f) 81bf215546Sopenharmony_ci if compsize: 82bf215546Sopenharmony_ci print(' const GLuint compsize = %s;' % (compsize)) 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ci if bias: 85bf215546Sopenharmony_ci print(' const GLuint cmdlen = %s - %u;' % (f.command_length(), bias)) 86bf215546Sopenharmony_ci else: 87bf215546Sopenharmony_ci print(' const GLuint cmdlen = %s;' % (f.command_length())) 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci #print '' 90bf215546Sopenharmony_ci return compsize 91