OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """code generator for GLES2 command buffers.""" | 7 """code generator for GLES2 command buffers.""" |
8 | 8 |
9 import os | 9 import os |
10 import os.path | 10 import os.path |
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 'IsShader': { | 1482 'IsShader': { |
1483 'type': 'Is', | 1483 'type': 'Is', |
1484 'decoder_func': 'DoIsShader', | 1484 'decoder_func': 'DoIsShader', |
1485 'expectation': False, | 1485 'expectation': False, |
1486 }, | 1486 }, |
1487 'IsTexture': { | 1487 'IsTexture': { |
1488 'type': 'Is', | 1488 'type': 'Is', |
1489 'decoder_func': 'DoIsTexture', | 1489 'decoder_func': 'DoIsTexture', |
1490 'expectation': False, | 1490 'expectation': False, |
1491 }, | 1491 }, |
1492 'LinkProgram': {'decoder_func': 'DoLinkProgram'}, | 1492 'LinkProgram': { |
| 1493 'decoder_func': 'DoLinkProgram', |
| 1494 'impl_func': False, |
| 1495 }, |
1493 'MapBufferSubDataCHROMIUM': { | 1496 'MapBufferSubDataCHROMIUM': { |
1494 'gen_cmd': False, | 1497 'gen_cmd': False, |
1495 'extension': True, | 1498 'extension': True, |
1496 'chromium': True, | 1499 'chromium': True, |
1497 }, | 1500 }, |
1498 'MapTexSubImage2DCHROMIUM': { | 1501 'MapTexSubImage2DCHROMIUM': { |
1499 'gen_cmd': False, | 1502 'gen_cmd': False, |
1500 'extension': True, | 1503 'extension': True, |
1501 'chromium': True, | 1504 'chromium': True, |
1502 }, | 1505 }, |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3061 """Overrriden from TypeHandler.""" | 3064 """Overrriden from TypeHandler.""" |
3062 file.Write("%s %s(%s) {\n" % | 3065 file.Write("%s %s(%s) {\n" % |
3063 (func.return_type, func.original_name, | 3066 (func.return_type, func.original_name, |
3064 func.MakeTypedOriginalArgString(""))) | 3067 func.MakeTypedOriginalArgString(""))) |
3065 func.WriteDestinationInitalizationValidation(file) | 3068 func.WriteDestinationInitalizationValidation(file) |
3066 self.WriteClientGLCallLog(func, file) | 3069 self.WriteClientGLCallLog(func, file) |
3067 for arg in func.GetOriginalArgs(): | 3070 for arg in func.GetOriginalArgs(): |
3068 arg.WriteClientSideValidationCode(file, func) | 3071 arg.WriteClientSideValidationCode(file, func) |
3069 file.Write( | 3072 file.Write( |
3070 " GPU_CLIENT_DCHECK(%s != 0);\n" % func.GetOriginalArgs()[-1].name) | 3073 " GPU_CLIENT_DCHECK(%s != 0);\n" % func.GetOriginalArgs()[-1].name) |
3071 file.Write(" program_and_shader_id_handler_->FreeIds(1, &%s);\n" % | 3074 file.Write(" DeleteProgramOrShaderHelper(%s);\n" % |
3072 func.GetOriginalArgs()[-1].name) | 3075 func.GetOriginalArgs()[-1].name) |
3073 file.Write(" helper_->%s(%s);\n" % | 3076 file.Write(" helper_->%s(%s);\n" % |
3074 (func.name, func.MakeCmdArgString(""))) | 3077 (func.name, func.MakeCmdArgString(""))) |
3075 file.Write(" Flush();\n") | 3078 file.Write(" Flush();\n") |
3076 file.Write("}\n") | 3079 file.Write("}\n") |
3077 file.Write("\n") | 3080 file.Write("\n") |
3078 | 3081 |
3079 | 3082 |
3080 class DELnHandler(TypeHandler): | 3083 class DELnHandler(TypeHandler): |
3081 """Handler for glDelete___ type functions.""" | 3084 """Handler for glDelete___ type functions.""" |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4205 def WriteGLES2ImplementationHeader(self, func, file): | 4208 def WriteGLES2ImplementationHeader(self, func, file): |
4206 """Overrriden from TypeHandler.""" | 4209 """Overrriden from TypeHandler.""" |
4207 code_1 = "%(return_type)s %(func_name)s(%(args)s) {\n" | 4210 code_1 = "%(return_type)s %(func_name)s(%(args)s) {\n" |
4208 code_2 = """ GPU_CLIENT_LOG("[" << this << "] gl%(func_name)s" << "(" | 4211 code_2 = """ GPU_CLIENT_LOG("[" << this << "] gl%(func_name)s" << "(" |
4209 << %(arg0)s << ", " | 4212 << %(arg0)s << ", " |
4210 << %(arg1)s << ", " | 4213 << %(arg1)s << ", " |
4211 << static_cast<void*>(%(arg2)s) << ", " | 4214 << static_cast<void*>(%(arg2)s) << ", " |
4212 << static_cast<void*>(%(arg3)s) << ")"); | 4215 << static_cast<void*>(%(arg3)s) << ")"); |
4213 helper_->SetBucketSize(kResultBucketId, 0); | 4216 helper_->SetBucketSize(kResultBucketId, 0); |
4214 helper_->%(func_name)s(%(id_name)s, kResultBucketId); | 4217 helper_->%(func_name)s(%(id_name)s, kResultBucketId); |
4215 if (bufsize > 0) { | 4218 std::string str; |
4216 std::string str; | 4219 GLsizei max_size = 0; |
4217 if (GetBucketAsString(kResultBucketId, &str)) { | 4220 if (GetBucketAsString(kResultBucketId, &str)) { |
4218 GLsizei max_size = | 4221 if (bufsize > 0) { |
| 4222 max_size = |
4219 std::min(static_cast<size_t>(%(bufsize_name)s) - 1, str.size()); | 4223 std::min(static_cast<size_t>(%(bufsize_name)s) - 1, str.size()); |
4220 if (%(length_name)s != NULL) { | |
4221 *%(length_name)s = max_size; | |
4222 } | |
4223 memcpy(%(dest_name)s, str.c_str(), max_size); | 4224 memcpy(%(dest_name)s, str.c_str(), max_size); |
4224 %(dest_name)s[max_size] = '\\0'; | 4225 %(dest_name)s[max_size] = '\\0'; |
4225 GPU_CLIENT_LOG("------\\n" << %(dest_name)s << "\\n------"); | 4226 GPU_CLIENT_LOG("------\\n" << %(dest_name)s << "\\n------"); |
4226 } | 4227 } |
4227 } | 4228 } |
| 4229 if (%(length_name)s != NULL) { |
| 4230 *%(length_name)s = max_size; |
| 4231 } |
4228 } | 4232 } |
4229 """ | 4233 """ |
4230 args = func.GetOriginalArgs() | 4234 args = func.GetOriginalArgs() |
4231 str_args = { | 4235 str_args = { |
4232 'return_type': func.return_type, | 4236 'return_type': func.return_type, |
4233 'func_name': func.original_name, | 4237 'func_name': func.original_name, |
4234 'args': func.MakeTypedOriginalArgString(""), | 4238 'args': func.MakeTypedOriginalArgString(""), |
4235 'id_name': args[0].name, | 4239 'id_name': args[0].name, |
4236 'bufsize_name': args[1].name, | 4240 'bufsize_name': args[1].name, |
4237 'length_name': args[2].name, | 4241 'length_name': args[2].name, |
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5946 | 5950 |
5947 if options.generate_docs: | 5951 if options.generate_docs: |
5948 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") | 5952 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") |
5949 | 5953 |
5950 if gen.errors > 0: | 5954 if gen.errors > 0: |
5951 print "%d errors" % gen.errors | 5955 print "%d errors" % gen.errors |
5952 sys.exit(1) | 5956 sys.exit(1) |
5953 | 5957 |
5954 if __name__ == '__main__': | 5958 if __name__ == '__main__': |
5955 main(sys.argv[1:]) | 5959 main(sys.argv[1:]) |
OLD | NEW |