Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 6400007: Implement proxy for 3d-related interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: separate ParamTraits<gpu::CommandBuffer::State> into own library Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2006-2009 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
11 import sys 11 import sys
12 import re 12 import re
13 from optparse import OptionParser 13 from optparse import OptionParser
14 14
15 _SIZE_OF_UINT32 = 4 15 _SIZE_OF_UINT32 = 4
16 _SIZE_OF_COMMAND_HEADER = 4 16 _SIZE_OF_COMMAND_HEADER = 4
17 _FIRST_SPECIFIC_COMMAND_ID = 256 17 _FIRST_SPECIFIC_COMMAND_ID = 256
18 18
19 _LICENSE = """// Copyright (c) 2010 The Chromium Authors. All rights reserved. 19 _LICENSE = """// Copyright (c) 2011 The Chromium Authors. All rights reserved.
20 // Use of this source code is governed by a BSD-style license that can be 20 // Use of this source code is governed by a BSD-style license that can be
21 // found in the LICENSE file. 21 // found in the LICENSE file.
22 22
23 """ 23 """
24 24
25 # This string is copied directly out of the gl2.h file from GLES2.0 25 # This string is copied directly out of the gl2.h file from GLES2.0
26 # 26 #
27 # Edits: 27 # Edits:
28 # 28 #
29 # *) Any argument that is a resourceID has been changed to GLid<Type>. 29 # *) Any argument that is a resourceID has been changed to GLid<Type>.
(...skipping 5319 matching lines...) Expand 10 before | Expand all | Expand 10 after
5349 const PPB_OpenGLES2_Dev* PPB_OpenGLES_Impl::GetInterface() { 5349 const PPB_OpenGLES2_Dev* PPB_OpenGLES_Impl::GetInterface() {
5350 return &ppb_opengles2; 5350 return &ppb_opengles2;
5351 } 5351 }
5352 5352
5353 """) 5353 """)
5354 file.Write("} // namespace ppapi\n") 5354 file.Write("} // namespace ppapi\n")
5355 file.Write("} // namespace webkit\n\n") 5355 file.Write("} // namespace webkit\n\n")
5356 5356
5357 file.Close() 5357 file.Close()
5358 5358
5359 def WritePepperGLES2ProxyImplementation(self, filename):
5360 """Writes the Pepper OpenGLES interface implementation."""
5361
5362 file = CWriter(filename)
5363 file.Write(_LICENSE)
5364 file.Write("// This file is auto-generated. DO NOT EDIT!\n\n")
5365
5366 file.Write("#include \"ppapi/proxy/ppb_opengles2_proxy.h\"\n\n")
5367
5368 file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n" )
5369 file.Write("#include \"ppapi/c/pp_errors.h\"\n")
5370 file.Write("#include \"ppapi/c/pp_resource.h\"\n")
5371 file.Write("#include \"ppapi/c/dev/ppb_opengles_dev.h\"\n")
5372 file.Write("#include \"ppapi/proxy/plugin_dispatcher.h\"\n")
5373 file.Write("#include \"ppapi/proxy/plugin_resource.h\"\n")
5374 file.Write("#include \"ppapi/proxy/ppb_context_3d_proxy.h\"\n\n")
5375
5376 file.Write("namespace pp {\n")
5377 file.Write("namespace proxy {\n\n")
5378 file.Write("namespace {\n\n")
5379
5380
5381 for func in self.original_functions:
5382 if not func.IsCoreGLFunction():
5383 continue
5384
5385 original_arg = func.MakeTypedOriginalArgString("")
5386 context_arg = "PP_Resource context_id"
5387 if len(original_arg):
5388 arg = context_arg + ", " + original_arg
5389 else:
5390 arg = context_arg
5391 file.Write("%s %s(%s) {\n" % (func.return_type, func.name, arg))
5392
5393 file.Write(""" Context3D* context = PluginResource::GetAs<Context3D>(cont ext_id);\n""")
5394
5395 return_str = "" if func.return_type == "void" else "return "
5396 file.Write(" %scontext->gles2_impl()->%s(%s);\n" %
5397 (return_str, func.original_name,
5398 func.MakeOriginalArgString("")))
5399 file.Write("}\n\n")
5400
5401 file.Write("const struct PPB_OpenGLES2_Dev ppb_opengles2 = {\n")
5402 file.Write(" &")
5403 file.Write(",\n &".join(
5404 f.name for f in self.original_functions if f.IsCoreGLFunction()))
5405 file.Write("\n")
5406 file.Write("};\n\n")
5407
5408 file.Write("} // namespace\n")
5409
5410 file.Write("""
5411 PPB_OpenGLES2_Proxy::PPB_OpenGLES2_Proxy(Dispatcher* dispatcher,
5412 const void* target_interface)
5413 : InterfaceProxy(dispatcher, target_interface) {
5414 }
5415
5416 PPB_OpenGLES2_Proxy::~PPB_OpenGLES2_Proxy() {
5417 }
5418
5419 const void* PPB_OpenGLES2_Proxy::GetSourceInterface() const {
5420 return &ppb_opengles2;
5421 }
5422
5423 InterfaceID PPB_OpenGLES2_Proxy::GetInterfaceId() const {
5424 return INTERFACE_ID_NONE;
5425 }
5426
5427 bool PPB_OpenGLES2_Proxy::OnMessageReceived(const IPC::Message& msg) {
5428 return false;
5429 }
5430
5431 """)
5432 file.Write("} // namespace proxy\n")
5433 file.Write("} // namespace pp\n")
5434
5435 file.Close()
5436
5359 def WriteGLES2ToPPAPIBridge(self, filename): 5437 def WriteGLES2ToPPAPIBridge(self, filename):
5360 """Connects GLES2 helper library to PPB_OpenGLES2 interface""" 5438 """Connects GLES2 helper library to PPB_OpenGLES2 interface"""
5361 5439
5362 file = CWriter(filename) 5440 file = CWriter(filename)
5363 file.Write(_LICENSE) 5441 file.Write(_LICENSE)
5364 file.Write("// This file is auto-generated. DO NOT EDIT!\n\n") 5442 file.Write("// This file is auto-generated. DO NOT EDIT!\n\n")
5365 5443
5366 file.Write("#include <GLES2/gl2.h>\n") 5444 file.Write("#include <GLES2/gl2.h>\n")
5367 file.Write("#include \"ppapi/lib/gl/gles2/gl2ext_ppapi.h\"\n\n") 5445 file.Write("#include \"ppapi/lib/gl/gles2/gl2ext_ppapi.h\"\n\n")
5368 5446
(...skipping 23 matching lines...) Expand all
5392 "-g", "--generate-implementation-templates", action="store_true", 5470 "-g", "--generate-implementation-templates", action="store_true",
5393 help="generates files that are generally hand edited..") 5471 help="generates files that are generally hand edited..")
5394 parser.add_option( 5472 parser.add_option(
5395 "--generate-command-id-tests", action="store_true", 5473 "--generate-command-id-tests", action="store_true",
5396 help="generate tests for commands ids. Commands MUST not change ID!") 5474 help="generate tests for commands ids. Commands MUST not change ID!")
5397 parser.add_option( 5475 parser.add_option(
5398 "--generate-docs", action="store_true", 5476 "--generate-docs", action="store_true",
5399 help="generate a docs friendly version of the command formats.") 5477 help="generate a docs friendly version of the command formats.")
5400 parser.add_option( 5478 parser.add_option(
5401 "--alternate-mode", type="choice", 5479 "--alternate-mode", type="choice",
5402 choices=("ppapi", "chrome_ppapi"), 5480 choices=("ppapi", "chrome_ppapi", "chrome_ppapi_proxy"),
5403 help="generate files for other projects. \"ppapi\" must be run from the " 5481 help="generate files for other projects. \"ppapi\" must be run from the "
5404 "directory containing the ppapi directory, and will generate ppapi " 5482 "directory containing the ppapi directory, and will generate ppapi "
5405 "bindings. \"chrome_ppapi\" must be run from chrome src directory and " 5483 "bindings. \"chrome_ppapi\" must be run from chrome src directory and "
5406 "will generate chrome plumbing for ppapi.") 5484 "will generate chrome plumbing for ppapi. \"chrome_ppapi_proxy\" must be "
5485 "run from chrome src directory and " "will generate the glue for the"
5486 "chrome IPC ppapi proxy.")
5407 parser.add_option( 5487 parser.add_option(
5408 "-v", "--verbose", action="store_true", 5488 "-v", "--verbose", action="store_true",
5409 help="prints more output.") 5489 help="prints more output.")
5410 5490
5411 (options, args) = parser.parse_args(args=argv) 5491 (options, args) = parser.parse_args(args=argv)
5412 5492
5413 gen = GLGenerator(options.verbose) 5493 gen = GLGenerator(options.verbose)
5414 gen.ParseGLH("common/GLES2/gl2.h") 5494 gen.ParseGLH("common/GLES2/gl2.h")
5415 5495
5416 if options.alternate_mode == "ppapi": 5496 if options.alternate_mode == "ppapi":
5417 gen.WritePepperGLES2Interface("ppapi/c/dev/ppb_opengles_dev.h") 5497 gen.WritePepperGLES2Interface("ppapi/c/dev/ppb_opengles_dev.h")
5418 gen.WriteGLES2ToPPAPIBridge("ppapi/lib/gl/gles2/gles2.c") 5498 gen.WriteGLES2ToPPAPIBridge("ppapi/lib/gl/gles2/gles2.c")
5419 5499
5420 elif options.alternate_mode == "chrome_ppapi": 5500 elif options.alternate_mode == "chrome_ppapi":
5421 gen.WritePepperGLES2Implementation( 5501 gen.WritePepperGLES2Implementation(
5422 "webkit/plugins/ppapi/ppb_opengles_impl.cc") 5502 "webkit/plugins/ppapi/ppb_opengles_impl.cc")
5423 5503
5504 elif options.alternate_mode == "chrome_ppapi_proxy":
5505 gen.WritePepperGLES2ProxyImplementation(
5506 "ppapi/proxy/ppb_opengles2_proxy.cc")
5507
5424 else: 5508 else:
5425 gen.WriteCommandIds("common/gles2_cmd_ids_autogen.h") 5509 gen.WriteCommandIds("common/gles2_cmd_ids_autogen.h")
5426 gen.WriteFormat("common/gles2_cmd_format_autogen.h") 5510 gen.WriteFormat("common/gles2_cmd_format_autogen.h")
5427 gen.WriteFormatTest("common/gles2_cmd_format_test_autogen.h") 5511 gen.WriteFormatTest("common/gles2_cmd_format_test_autogen.h")
5428 gen.WriteGLES2ImplementationHeader("client/gles2_implementation_autogen.h") 5512 gen.WriteGLES2ImplementationHeader("client/gles2_implementation_autogen.h")
5429 gen.WriteGLES2CLibImplementation("client/gles2_c_lib_autogen.h") 5513 gen.WriteGLES2CLibImplementation("client/gles2_c_lib_autogen.h")
5430 gen.WriteCmdHelperHeader("client/gles2_cmd_helper_autogen.h") 5514 gen.WriteCmdHelperHeader("client/gles2_cmd_helper_autogen.h")
5431 gen.WriteServiceImplementation("service/gles2_cmd_decoder_autogen.h") 5515 gen.WriteServiceImplementation("service/gles2_cmd_decoder_autogen.h")
5432 gen.WriteServiceUnitTests("service/gles2_cmd_decoder_unittest_%d_autogen.h") 5516 gen.WriteServiceUnitTests("service/gles2_cmd_decoder_unittest_%d_autogen.h")
5433 gen.WriteServiceUtilsHeader("service/gles2_cmd_validation_autogen.h") 5517 gen.WriteServiceUtilsHeader("service/gles2_cmd_validation_autogen.h")
5434 gen.WriteServiceUtilsImplementation( 5518 gen.WriteServiceUtilsImplementation(
5435 "service/gles2_cmd_validation_implementation_autogen.h") 5519 "service/gles2_cmd_validation_implementation_autogen.h")
5436 5520
5437 if options.generate_command_id_tests: 5521 if options.generate_command_id_tests:
5438 gen.WriteCommandIdTest("common/gles2_cmd_id_test_autogen.h") 5522 gen.WriteCommandIdTest("common/gles2_cmd_id_test_autogen.h")
5439 5523
5440 if options.generate_docs: 5524 if options.generate_docs:
5441 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") 5525 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h")
5442 5526
5443 if gen.errors > 0: 5527 if gen.errors > 0:
5444 print "%d errors" % gen.errors 5528 print "%d errors" % gen.errors
5445 sys.exit(1) 5529 sys.exit(1)
5446 5530
5447 if __name__ == '__main__': 5531 if __name__ == '__main__':
5448 main(sys.argv[1:]) 5532 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « chrome/common/gpu_param_traits.h ('k') | gpu/gpu.gyp » ('j') | ppapi/proxy/plugin_dispatcher.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698