--- /dev/null
+responsible person Michael Schuldt
+E-Mail: Michael.Schuldt@bmw-carit.de
+responsible person Sven von Beuningen
+E-Mail: Sven.vonBeuningen@bmw-carit.de
--- /dev/null
+/*
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright [yyyy] [name of copyright owner]
+ *
+ * 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.
+ */
\ No newline at end of file
--- /dev/null
+############################################################################
+#
+# Copyright 2010 BMW Car IT GmbH
+#
+#
+# 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.
+#
+############################################################################
+
+CXXFLAGS = -Wall -fPIC -O2
+
+ADD_INCLUDE_DIR+=/home/carit/beagleIncludes
+
+ADD_LIB_DIR+= /home/carit/beagleIncludes
+
+LINKFLAGS = -Xlinker -export-dynamic
+
+CXX = /home/carit/toolchain/arm-2009q1/bin/arm-none-linux-gnueabi-g++
\ No newline at end of file
--- /dev/null
+<!--
+***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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.
+*
+****************************************************************************/
+-->
+<!-- Description file for dbus interface of BMW Compositing Service -->
+
+<node name="/de/BMW/CompositingService">
+ <interface name="de.bmw.CompositingService">
+
+ <method name="Debug">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_debug"/>
+ <arg type="b" name="onoff" direction="in" />
+ </method>
+
+ <method name="ListAllLayerIDS">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_list_all_layer_id_s"/>
+ <arg type="au" name="layerids" direction="out" />
+ </method>
+
+ <method name="ListAllSurfaceIDS">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_list_all_surface_id_s"/>
+ <arg type="au" name="surfaceids" direction="out" />
+ </method>
+
+ <method name="ListAllLayerGroupIDS">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_list_all_layer_group_id_s"/>
+ <arg type="au" name="layergroupids" direction="out" />
+ </method>
+
+ <method name="ListAllSurfaceGroupIDS">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_list_all_surface_group_id_s"/>
+ <arg type="au" name="surfacegroupids" direction="out" />
+ </method>
+
+ <method name="ListSurfacesOfSurfacegroup">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_list_surfaces_of_surfacegroup"/>
+ <arg type="u" name="surfacegroupid" direction="in" />
+ <arg type="au" name="surfaceids" direction="out" />
+ </method>
+
+ <method name="ListLayersOfLayergroup">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_list_layers_of_layergroup"/>
+ <arg type="u" name="layergroupid" direction="in" />
+ <arg type="au" name="layerids" direction="out" />
+ </method>
+
+ <method name="ListSurfaceofLayer">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_list_surfaces_of_layer"/>
+ <arg type="u" name="layeridid" direction="in" />
+ <arg type="au" name="surfaceids" direction="out" />
+ </method>
+
+ <method name="getPropertiesOfSurface">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_surface_properties"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="d" name="opacity" direction="out" />
+ <arg type="u" name="SourceX" direction="out" />
+ <arg type="u" name="SourceY" direction="out" />
+ <arg type="u" name="SourceWidth" direction="out" />
+ <arg type="u" name="SourceHeight" direction="out" />
+ <arg type="u" name="destX" direction="out" />
+ <arg type="u" name="destY" direction="out" />
+ <arg type="u" name="destWidth" direction="out" />
+ <arg type="u" name="destHeight" direction="out" />
+ <arg type="y" name="orientation" direction="out" />
+ <arg type="b" name="visibility" direction="out" />
+ </method>
+
+ <method name="getPropertiesOfLayer">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_layer_properties"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="d" name="opacity" direction="out" />
+ <arg type="u" name="SourceX" direction="out" />
+ <arg type="u" name="SourceY" direction="out" />
+ <arg type="u" name="SourceWidth" direction="out" />
+ <arg type="u" name="SourceHeight" direction="out" />
+ <arg type="u" name="destX" direction="out" />
+ <arg type="u" name="destY" direction="out" />
+ <arg type="u" name="destWidth" direction="out" />
+ <arg type="u" name="destHeight" direction="out" />
+ <arg type="y" name="orientation" direction="out" />
+ <arg type="b" name="visibility" direction="out" />
+ </method>
+
+ <!-- organisation -->
+
+ <method name="CreateSurface">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_create_surface"/>
+ <arg type="u" name="surfaceid" direction="out" />
+ <arg type="u" name="handle" direction="in" />
+ <arg type="u" name="pixelformat" direction="in" />
+ <arg type="u" name="OriginalWidth" direction="in" />
+ <arg type="u" name="OriginalHeight" direction="in" />
+ </method>
+ <method name="RemoveSurface">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_remove_surface"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ </method>
+ <method name="CreateLayer">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_create_layer"/>
+ <arg type="u" name="layerid" direction="out" />
+ </method>
+ <method name="RemoveLayer">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_remove_layer"/>
+ <arg type="u" name="layerid" direction="in" />
+ </method>
+ <method name="AddSurfaceToSurfaceGroup">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_add_surface_to_surface_group"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="surfacegroupid" direction="in" />
+ </method>
+ <method name="RemoveSurfaceFromSurfaceGroup">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_remove_surface_from_surface_group"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="surfacegroupid" direction="in" />
+ </method>
+ <method name="AddLayerToLayerGroup">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_add_layer_to_layer_group"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="layergroupid" direction="in" />
+ </method>
+ <method name="RemoveLayerFromLayerGroup">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_remove_layer_from_layer_group"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="layergroupid" direction="in" />
+ </method>
+ <method name="AddSurfaceToLayer">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_add_surface_to_layer"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="layerid" direction="in" />
+ </method>
+ <method name="RemoveSurfaceFromLayer">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_remove_surface_from_layer"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="layerid" direction="in" />
+ </method>
+
+ <method name="CreateSurfaceGroup">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_create_surface_group"/>
+ <arg type="u" name="groupid" direction="out" />
+ </method>
+ <method name="RemoveSurfaceGroup">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_remove_surface_group"/>
+ <arg type="u" name="groupid" direction="in" />
+ </method>
+ <method name="CreateLayerGroup">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_create_layer_group"/>
+ <arg type="u" name="groupid" direction="out" />
+ </method>
+ <method name="RemoveLayerGroup">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_remove_layer_group"/>
+ <arg type="u" name="groupid" direction="in" />
+ </method>
+
+ <!-- Surface Geometry and properties -->
+
+ <method name="SetSurfaceSourceRegion">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_surface_set_source_region"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="left" direction="in" />
+ <arg type="u" name="top" direction="in" />
+ <arg type="u" name="width" direction="in" />
+ <arg type="u" name="height" direction="in" />
+ </method>
+ <method name="SetLayerSourceRegion">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_layer_set_source_region"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="left" direction="in" />
+ <arg type="u" name="top" direction="in" />
+ <arg type="u" name="width" direction="in" />
+ <arg type="u" name="height" direction="in" />
+ </method>
+
+ <method name="SetSurfaceDestinationRegion">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_surface_set_destination_region"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="left" direction="in" />
+ <arg type="u" name="top" direction="in" />
+ <arg type="u" name="width" direction="in" />
+ <arg type="u" name="height" direction="in" />
+ </method>
+ <method name="SetSurfacePosition">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_surface_set_position"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="left" direction="in" />
+ <arg type="u" name="top" direction="in" />
+ </method>
+ <method name="GetSurfacePosition">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_surface_get_position"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="left" direction="out" />
+ <arg type="u" name="top" direction="out" />
+ </method>
+ <method name="SetSurfaceDimension">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_surface_set_dimension"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="width" direction="in" />
+ <arg type="u" name="height" direction="in" />
+ </method>
+ <method name="SetLayerDestinationRegion">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_layer_set_destination_region"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="left" direction="in" />
+ <arg type="u" name="top" direction="in" />
+ <arg type="u" name="width" direction="in" />
+ <arg type="u" name="height" direction="in" />
+ </method>
+ <method name="SetLayerPosition">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_layer_set_position"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="left" direction="in" />
+ <arg type="u" name="top" direction="in" />
+ </method>
+ <method name="GetLayerPosition">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_layer_get_position"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="left" direction="out" />
+ <arg type="u" name="top" direction="out" />
+ </method>
+ <method name="SetLayerDimension">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_layer_set_dimension"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="width" direction="in" />
+ <arg type="u" name="height" direction="in" />
+ </method>
+ <method name="GetLayerDimension">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_layer_get_dimension"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="width" direction="out" />
+ <arg type="u" name="height" direction="out" />
+ </method>
+ <method name="GetSurfaceDimension">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_surface_get_dimension"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="width" direction="out" />
+ <arg type="u" name="height" direction="out" />
+ </method>
+ <method name="SetSurfaceOpacity">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_surface_opacity"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="d" name="opacity" direction="in" />
+ </method>
+ <method name="SetLayerOpacity">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_layer_opacity"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="d" name="opacity" direction="in" />
+ </method>
+ <method name="SetSurfacegroupOpacity">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_surfacegroup_opacity"/>
+ <arg type="u" name="surfacegroupid" direction="in" />
+ <arg type="d" name="opacity" direction="in" />
+ </method>
+ <method name="SetLayergroupOpacity">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_layergroup_opacity"/>
+ <arg type="u" name="layergroupid" direction="in" />
+ <arg type="d" name="opacity" direction="in" />
+ </method>
+ <method name="GetSurfaceOpacity">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_surface_opacity"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="d" name="opacity" direction="out" />
+ </method>
+ <method name="GetLayerOpacity">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_layer_opacity"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="d" name="opacity" direction="out" />
+ </method>
+ <method name="GetSurfacegroupOpacity">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_surfacegroup_opacity"/>
+ <arg type="u" name="surfacegroupid" direction="in" />
+ <arg type="d" name="opacity" direction="out" />
+ </method>
+ <method name="GetLayergroupOpacity">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_layergroup_opacity"/>
+ <arg type="u" name="layergroupid" direction="in" />
+ <arg type="d" name="opacity" direction="out" />
+ </method>
+ <method name="SetSurfaceOrientation">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_surface_orientation"/>
+ <arg type="u" name="surfaceid" direction="in" />
+ <arg type="u" name="orientation" direction="in" />
+ </method>
+ <method name="SetLayerOrientation">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_layer_orientation"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="orientation" direction="in" />
+ </method>
+ <method name="GetSurfacePixelformat">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_surface_pixelformat"/>
+ <arg type="u" name="id" direction="in" />
+ <arg type="u" name="pixelformat" direction="out" />
+ </method>
+ <method name="SetSurfaceVisibility">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_surface_visibility"/>
+ <arg type="u" name="id" direction="in" />
+ <arg type="b" name="visibility" direction="in" />
+ </method>
+ <method name="SetLayerVisibility">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_layer_visibility"/>
+ <arg type="u" name="id" direction="in" />
+ <arg type="b" name="visibility" direction="in" />
+ </method>
+ <method name="GetSurfaceVisibility">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_surface_visibility"/>
+ <arg type="u" name="id" direction="in" />
+ <arg type="b" name="visibility" direction="out" />
+ </method>
+ <method name="GetLayerVisibility">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_layer_visibility"/>
+ <arg type="u" name="id" direction="in" />
+ <arg type="b" name="visibility" direction="out" />
+ </method>
+ <method name="SetSurfacegroupVisibility">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_surfacegroup_visibility"/>
+ <arg type="u" name="id" direction="in" />
+ <arg type="b" name="visibility" direction="in" />
+ </method>
+ <method name="SetLayergroupVisibility">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_layergroup_visibility"/>
+ <arg type="u" name="id" direction="in" />
+ <arg type="b" name="visibility" direction="in" />
+ </method>
+
+ <method name="SetRenderOrderOfLayers">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_renderorder"/>
+ <arg type="au" name="ids" direction="in" />
+ <arg type="u" name="display" direction="in" />
+ </method>
+ <method name="SetSurfaceRenderOrderWithinLayer">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_renderorder_within_layer"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="au" name="surfaceids" direction="in" />
+ </method>
+
+ <method name="GetLayerType">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_layer_type"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="type" direction="out" />
+ </method>
+
+ <method name="GetLayertypeCapabilities">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_layer_type_capabilities"/>
+ <arg type="u" name="layertype" direction="in" />
+ <arg type="u" name="capabilities" direction="out" />
+ </method>
+
+ <method name="GetLayerCapabilities">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_get_layer_capabilities"/>
+ <arg type="u" name="layerid" direction="in" />
+ <arg type="u" name="capabilities" direction="out" />
+ </method>
+
+ <method name="Exit">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_exit"/>
+ </method>
+
+ <method name="CommitChanges">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_commit"/>
+ </method>
+
+ <!-- shader -->
+ <method name="CreateShader">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_create_shader"/>
+ <arg type="s" name="vertname" direction="in" />
+ <arg type="s" name="fragname" direction="in" />
+ <arg type="u" name="shaderid" direction="out" />
+ </method>
+
+ <method name="DestroyShader">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_destroy_shader"/>
+ <arg type="u" name="shaderid" direction="in" />
+ </method>
+
+ <method name="SetShader">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_shader"/>
+ <arg type="u" name="id" direction="in" />
+ <arg type="u" name="shaderid" direction="in" />
+ </method>
+
+ <method name="SetUniforms">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="DBUSCommunicator::compositeService_set_uniforms"/>
+ <arg type="u" name="shaderid" direction="in" />
+ <arg type="as" name="uniforms" direction="in" />
+ </method>
+
+
+ </interface>
+</node>
--- /dev/null
+#!/bin/bash
+############################################################################
+#
+# Copyright 2010 BMW Car IT GmbH
+#
+#
+# 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.
+#
+############################################################################
+
+# call binding tool to generate server stubs and marshallers
+dbus-binding-tool --mode=glib-server --prefix=compositeService --output=./include/compositeServiceBinding.h compositeServiceDescription.xml
+dbus-binding-tool --mode=glib-client --prefix=compositeService --output=./include/compositeServiceClient.h compositeServiceDescription.xml
+# output java binding files to console:
+CreateInterface compositeServiceDescription.xml
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _DBUSCOMMUNICATOR_H_
+#define _DBUSCOMMUNICATOR_H_
+
+#include "BaseCommunicator.h"
+#include "CommandExecutor.h"
+#include "Log.h"
+#include <dbus/dbus.h>
+
+class DBUSCommunicator: public BaseCommunicator{
+public:
+ DBUSCommunicator(CommandExecutor* executor, ILayerList* ll);
+ virtual ~DBUSCommunicator();
+ virtual bool start();
+ virtual void stop();
+ virtual void setdebug(bool onoff);
+
+ void Debug(DBusConnection* conn,DBusMessage* msg );
+ void ListAllLayerIDS(DBusConnection* conn,DBusMessage* msg );
+ void ListAllSurfaceIDS(DBusConnection* conn,DBusMessage* msg );
+ void ListAllLayerGroupIDS(DBusConnection* conn,DBusMessage* msg );
+ void ListAllSurfaceGroupIDS(DBusConnection* conn,DBusMessage* msg );
+ void ListSurfacesOfSurfacegroup(DBusConnection* conn,DBusMessage* msg );
+ void ListLayersOfLayergroup(DBusConnection* conn,DBusMessage* msg );
+ void ListSurfaceofLayer(DBusConnection* conn,DBusMessage* msg );
+ void getPropertiesOfSurface(DBusConnection* conn,DBusMessage* msg );
+ void getPropertiesOfLayer(DBusConnection* conn,DBusMessage* msg );
+ void CreateSurface(DBusConnection* conn,DBusMessage* msg );
+ void RemoveSurface(DBusConnection* conn,DBusMessage* msg );
+ void CreateLayer(DBusConnection* conn,DBusMessage* msg );
+ void RemoveLayer(DBusConnection* conn,DBusMessage* msg );
+ void AddSurfaceToSurfaceGroup(DBusConnection* conn,DBusMessage* msg );
+ void RemoveSurfaceFromSurfaceGroup(DBusConnection* conn,DBusMessage* msg );
+ void AddLayerToLayerGroup(DBusConnection* conn,DBusMessage* msg );
+ void RemoveLayerFromLayerGroup(DBusConnection* conn,DBusMessage* msg );
+ void AddSurfaceToLayer(DBusConnection* conn,DBusMessage* msg );
+ void RemoveSurfaceFromLayer(DBusConnection* conn,DBusMessage* msg );
+ void CreateSurfaceGroup(DBusConnection* conn,DBusMessage* msg );
+ void RemoveSurfaceGroup(DBusConnection* conn,DBusMessage* msg );
+ void CreateLayerGroup(DBusConnection* conn,DBusMessage* msg );
+ void RemoveLayerGroup(DBusConnection* conn,DBusMessage* msg );
+ void SetSurfaceSourceRegion(DBusConnection* conn,DBusMessage* msg );
+ void SetLayerSourceRegion(DBusConnection* conn,DBusMessage* msg );
+ void SetSurfaceDestinationRegion(DBusConnection* conn,DBusMessage* msg );
+ void SetSurfacePosition(DBusConnection* conn,DBusMessage* msg );
+ void GetSurfacePosition(DBusConnection* conn,DBusMessage* msg );
+ void SetSurfaceDimension(DBusConnection* conn,DBusMessage* msg );
+ void SetLayerDestinationRegion(DBusConnection* conn,DBusMessage* msg );
+ void SetLayerPosition(DBusConnection* conn,DBusMessage* msg );
+ void GetLayerPosition(DBusConnection* conn,DBusMessage* msg );
+ void SetLayerDimension(DBusConnection* conn,DBusMessage* msg );
+ void GetLayerDimension(DBusConnection* conn,DBusMessage* msg );
+ void GetSurfaceDimension(DBusConnection* conn,DBusMessage* msg );
+ void SetSurfaceOpacity(DBusConnection* conn,DBusMessage* msg );
+ void SetLayerOpacity(DBusConnection* conn,DBusMessage* msg );
+ void SetSurfacegroupOpacity(DBusConnection* conn,DBusMessage* msg );
+ void SetLayergroupOpacity(DBusConnection* conn,DBusMessage* msg );
+ void GetSurfaceOpacity(DBusConnection* conn,DBusMessage* msg );
+ void GetLayerOpacity(DBusConnection* conn,DBusMessage* msg );
+ void GetSurfacegroupOpacity(DBusConnection* conn,DBusMessage* msg );
+ void GetLayergroupOpacity(DBusConnection* conn,DBusMessage* msg );
+ void SetSurfaceOrientation(DBusConnection* conn,DBusMessage* msg );
+ void SetLayerOrientation(DBusConnection* conn,DBusMessage* msg );
+ void GetSurfacePixelformat(DBusConnection* conn,DBusMessage* msg );
+ void SetSurfaceVisibility(DBusConnection* conn,DBusMessage* msg );
+ void SetLayerVisibility(DBusConnection* conn,DBusMessage* msg );
+ void GetSurfaceVisibility(DBusConnection* conn,DBusMessage* msg );
+ void GetLayerVisibility(DBusConnection* conn,DBusMessage* msg );
+ void SetSurfacegroupVisibility(DBusConnection* conn,DBusMessage* msg );
+ void SetLayergroupVisibility(DBusConnection* conn,DBusMessage* msg );
+ void SetRenderOrderOfLayers(DBusConnection* conn,DBusMessage* msg );
+ void SetSurfaceRenderOrderWithinLayer(DBusConnection* conn,DBusMessage* msg );
+ void GetLayerType(DBusConnection* conn,DBusMessage* msg );
+ void GetLayertypeCapabilities(DBusConnection* conn,DBusMessage* msg );
+ void GetLayerCapabilities(DBusConnection* conn,DBusMessage* msg );
+ void FadeIn(DBusConnection* conn,DBusMessage* msg );
+ void SynchronizedFade(DBusConnection* conn,DBusMessage* msg );
+ void FadeOut(DBusConnection* conn,DBusMessage* msg );
+ void Exit(DBusConnection* conn,DBusMessage* msg );
+ void CommitChanges(DBusConnection* conn,DBusMessage* msg );
+ void CreateShader(DBusConnection* conn,DBusMessage* msg );
+ void DestroyShader(DBusConnection* conn,DBusMessage* msg );
+ void SetShader(DBusConnection* conn,DBusMessage* msg );
+ void SetUniforms(DBusConnection* conn,DBusMessage* msg );
+private:
+ static void* run(void * threadid);
+ pthread_t m_currentThread;
+ static DBUSCommunicator* m_reference;
+ bool m_running;
+};
+
+#endif /* _DBUSCOMMUNICATOR_H_ */
--- /dev/null
+############################################################################
+#
+# Copyright 2010 BMW Car IT GmbH
+#
+#
+# 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.
+#
+############################################################################
+
+ifneq ($(CONFIG),)
+include ../../../LayerManagerPlatform/Make$(CONFIG).defs
+endif
+
+SRC += DBUSCommunicator.cpp
+
+TARGET_NAME = libDBUSCommunicator.so
+LIB_NAME = $(TARGET_NAME).1.0
+
+ADD_INCLUDE_DIR=include \
+ $(PREFIX)/usr/include/dbus-1.0 \
+ $(PREFIX)/usr/lib/dbus-1.0/include \
+ $(PREFIX)/usr/include/layermanager \
+$(PREFIX)/usr/local/include/dbus-1.0 \
+$(PREFIX)/usr/local/lib/dbus-1.0/include
+
+
+ADD_LIB_DIR+=$(PREFIX)/usr/local/lib/dbus-1 \
+ $(PREFIX)/usr/lib/dbus-1 \
+ $(PREFIX)/usr/lib/layermanager
+
+ADD_LIBS+= pthread dbus-1 LayerManagerUtils
+
+OBJS += $(patsubst %.cpp,build/%.o,$(SRC))
+LINK =
+TARGET = build/$(TARGET_NAME)
+INCLUDE= $(patsubst %$,-I%,$(ADD_INCLUDE_DIR))
+LIBS+=$(shell pkg-config --libs $(PKG)) $(patsubst %$,-L%,$(ADD_LIB_DIR)) $(patsubst %$,-l%,$(ADD_LIBS))
+
+all: $(TARGET)
+
+build/%.o: src/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) -Wall -fPIC -O2 $(INCLUDE) -c -o $@ $<
+
+$(TARGET): $(OBJS)
+ $(CXX) -Wall -fPIC -O2 -shared -W1,-soname, -Xlinker -export-dynamic -o $(TARGET) $(OBJS) $(LIBS)
+
+install:
+ mkdir -p $(PREFIX)/usr/lib/layermanager/communicator
+ install -m 755 $(TARGET) $(PREFIX)/usr/lib/layermanager/communicator
+
+clean:
+ rm -f $(OBJS) $(TARGET)
+ rm -rf build
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 <dbus/dbus.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+
+#include "DBUSCommunicator.h"
+#include "Log.h"
+
+#define CONNMAN_SERVICE "de.bmw.CompositingService"
+#define CONNMAN_PATH "/de/bmw/CompositingService"
+
+typedef void (DBUSCommunicator::*CallBackMethod) (DBusConnection *connection, DBusMessage *message);
+
+typedef struct {
+ const char *name;
+ const char *signature;
+ const char *reply;
+ CallBackMethod function;
+} MethodTable;
+
+static MethodTable manager_methods[] = {
+ { "Debug", "b", "", &DBUSCommunicator::Debug },
+ { "ListAllLayerIDS", "", "au", &DBUSCommunicator::ListAllLayerIDS},
+ { "ListAllSurfaceIDS", "", "au", &DBUSCommunicator::ListAllSurfaceIDS},
+ { "ListAllLayerGroupIDS", "", "au", &DBUSCommunicator::ListAllLayerGroupIDS},
+ { "ListAllSurfaceGroupIDS", "", "au", &DBUSCommunicator::ListAllSurfaceGroupIDS},
+ { "ListSurfacesOfSurfacegroup", "u", "au", &DBUSCommunicator::ListSurfacesOfSurfacegroup},
+ { "ListLayersOfLayergroup", "u", "au", &DBUSCommunicator::ListLayersOfLayergroup},
+ { "ListSurfaceofLayer", "u", "au", &DBUSCommunicator::ListSurfaceofLayer},
+ { "getPropertiesOfSurface", "u", "duuuuuuuuyb", &DBUSCommunicator::getPropertiesOfSurface},
+ { "getPropertiesOfLayer", "u", "duuuuuuuuyb", &DBUSCommunicator::getPropertiesOfLayer },
+ { "CreateSurface", "uuuu", "u", &DBUSCommunicator::CreateSurface},
+ { "RemoveSurface", "u", "", &DBUSCommunicator::RemoveSurface },
+ { "CreateLayer", "", "u", &DBUSCommunicator::CreateLayer },
+ { "RemoveLayer", "u", "", &DBUSCommunicator::RemoveLayer },
+ { "AddSurfaceToSurfaceGroup", "uu", "", &DBUSCommunicator::AddSurfaceToSurfaceGroup },
+ { "RemoveSurfaceFromSurfaceGroup", "uu", "", &DBUSCommunicator::RemoveSurfaceFromSurfaceGroup },
+ { "AddLayerToLayerGroup", "uu", "", &DBUSCommunicator::AddLayerToLayerGroup},
+ { "RemoveLayerFromLayerGroup", "uu", "", &DBUSCommunicator::RemoveLayerFromLayerGroup },
+ { "AddSurfaceToLayer", "uu", "", &DBUSCommunicator::AddSurfaceToLayer },
+ { "RemoveSurfaceFromLayer", "uu", "", &DBUSCommunicator::RemoveSurfaceFromLayer},
+ { "CreateSurfaceGroup", "", "u", &DBUSCommunicator::CreateSurfaceGroup },
+ { "RemoveSurfaceGroup", "u", "", &DBUSCommunicator::RemoveSurfaceGroup},
+ { "CreateLayerGroup", "", "u", &DBUSCommunicator::CreateLayerGroup },
+ { "RemoveLayerGroup", "u", "", &DBUSCommunicator::RemoveLayerGroup },
+ { "SetSurfaceSourceRegion", "uuuuu", "", &DBUSCommunicator::SetSurfaceSourceRegion },
+ { "SetLayerSourceRegion", "uuuuu", "", &DBUSCommunicator::SetLayerSourceRegion},
+ { "SetSurfaceDestinationRegion", "uuuuu", "", &DBUSCommunicator::SetSurfaceDestinationRegion},
+ { "SetSurfacePosition", "uuu", "", &DBUSCommunicator::SetSurfacePosition },
+ { "GetSurfacePosition", "u", "uu", &DBUSCommunicator::GetSurfacePosition },
+ { "SetSurfaceDimension", "uuu", "", &DBUSCommunicator::SetSurfaceDimension},
+ { "SetLayerDestinationRegion", "uuuuu", "", &DBUSCommunicator::SetLayerDestinationRegion},
+ { "SetLayerPosition", "uuu", "", &DBUSCommunicator::SetLayerPosition},
+ { "GetLayerPosition", "u", "uu", &DBUSCommunicator::GetLayerPosition},
+ { "SetLayerDimension", "uuu", "", &DBUSCommunicator::SetLayerDimension},
+ { "GetLayerDimension", "u", "uu", &DBUSCommunicator::GetLayerDimension},
+ { "GetSurfaceDimension", "u", "uu", &DBUSCommunicator::GetSurfaceDimension},
+ { "SetSurfaceOpacity", "ud", "", &DBUSCommunicator::SetSurfaceOpacity},
+ { "SetLayerOpacity", "ud", "", &DBUSCommunicator::SetLayerOpacity },
+ { "SetSurfacegroupOpacity", "ud", "", &DBUSCommunicator::SetSurfacegroupOpacity },
+ { "SetLayergroupOpacity", "ud", "", &DBUSCommunicator::SetLayergroupOpacity },
+ { "GetSurfaceOpacity", "u", "d", &DBUSCommunicator::GetSurfaceOpacity },
+ { "GetLayerOpacity", "u", "d", &DBUSCommunicator::GetLayerOpacity },
+ { "GetSurfacegroupOpacity", "u", "d", &DBUSCommunicator::GetSurfacegroupOpacity },
+ { "GetLayergroupOpacity", "u", "d", &DBUSCommunicator::GetLayergroupOpacity },
+ { "SetSurfaceOrientation", "uu", "", &DBUSCommunicator::SetSurfaceOrientation },
+ { "SetLayerOrientation", "uu", "", &DBUSCommunicator::SetLayerOrientation },
+ { "GetSurfacePixelformat", "u", "u", &DBUSCommunicator::GetSurfacePixelformat },
+ { "SetSurfaceVisibility", "ub", "", &DBUSCommunicator::SetSurfaceVisibility },
+ { "SetLayerVisibility", "ub", "", &DBUSCommunicator::SetLayerVisibility },
+ { "GetSurfaceVisibility", "u", "b", &DBUSCommunicator::GetSurfaceVisibility },
+ { "GetLayerVisibility", "u", "b", &DBUSCommunicator::GetLayerVisibility },
+ { "SetSurfacegroupVisibility", "ub", "", &DBUSCommunicator::SetSurfacegroupVisibility },
+ { "SetLayergroupVisibility", "ub", "", &DBUSCommunicator::SetLayergroupVisibility },
+ { "SetRenderOrderOfLayers", "auu", "", &DBUSCommunicator::SetRenderOrderOfLayers },
+ { "SetSurfaceRenderOrderWithinLayer", "uau", "", &DBUSCommunicator::SetSurfaceRenderOrderWithinLayer },
+ { "GetLayerType", "u", "u",&DBUSCommunicator::GetLayerType },
+ { "GetLayertypeCapabilities", "u", "u", &DBUSCommunicator::GetLayertypeCapabilities },
+ { "GetLayerCapabilities", "u", "u", &DBUSCommunicator::GetLayerCapabilities },
+ { "Exit", "", "", &DBUSCommunicator::Exit },
+ { "CommitChanges", "", "", &DBUSCommunicator::CommitChanges },
+ { "CreateShader", "ss", "u", &DBUSCommunicator::CreateShader },
+ { "DestroyShader", "u", "", &DBUSCommunicator::DestroyShader},
+ { "SetShader", "uu", "", &DBUSCommunicator::SetShader },
+ { "SetUniforms", "uas", "", &DBUSCommunicator::SetUniforms },
+ { "","","",NULL}
+ };
+
+#include <string>
+
+DBusMessageIter iter;
+DBusMessage* currentMsg;
+DBusMessage* reply;
+dbus_uint32_t serial = 0;
+DBusConnection* conn;
+
+char* getStringFromMessage(){
+ char* param;
+
+ if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&iter)){
+ LOG_ERROR("DBUSCommunicator", "Argument is not string!");
+ }else{
+ dbus_message_iter_get_basic(&iter, ¶m);
+ }
+ return param;
+}
+
+bool getBoolFromMessage(){
+ dbus_bool_t boolparam;
+
+ if (DBUS_TYPE_BOOLEAN != dbus_message_iter_get_arg_type(&iter)){
+ LOG_ERROR("DBUSCommunicator", "Argument is not bool!");
+ }else{
+ dbus_message_iter_get_basic(&iter, &boolparam);
+ }
+ bool b;
+ if (boolparam==0)
+ b = false;
+ else
+ b = true;
+ return b;
+}
+
+char getByteFromMessage(){
+ char param;
+
+ if (DBUS_TYPE_BYTE != dbus_message_iter_get_arg_type(&iter)){
+ LOG_ERROR("DBUSCommunicator", "Argument is not byte!");
+ }else{
+ dbus_message_iter_get_basic(&iter, ¶m);
+ }
+ return param;
+}
+
+uint getUIntFromMessage(){
+ uint param;
+
+ if (DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&iter)){
+ LOG_ERROR("DBUSCommunicator", "Argument is not uint32!");
+ }else{
+ dbus_message_iter_get_basic(&iter, ¶m);
+ }
+ return param;
+}
+
+
+
+double getDoubleFromMessage(){
+ double param;
+
+ if (DBUS_TYPE_DOUBLE != dbus_message_iter_get_arg_type(&iter)){
+ LOG_ERROR("DBUSCommunicator","Argument is not double!");
+ }else{
+ dbus_message_iter_get_basic(&iter, ¶m);
+ }
+ return param;
+}
+
+
+void appendBool(bool toAppend){
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &toAppend)) {
+ LOG_ERROR("DBUSCommunicator", "Out Of Memory!");
+ exit(1);
+ }
+}
+
+void appendUint(uint toAppend){
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &toAppend)) {
+ LOG_ERROR("DBUSCommunicator", "Out Of Memory!");
+ exit(1);
+ }
+}
+
+void appendDouble(double toAppend){
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_DOUBLE, &toAppend)) {
+ LOG_ERROR("DBUSCommunicator", "Out Of Memory!");
+ exit(1);
+ }
+}
+
+void appendbyte(char toAppend){
+ if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_BYTE, &toAppend)) {
+ LOG_ERROR("DBUSCommunicator", "Out Of Memory!");
+ exit(1);
+ }
+}
+
+void initReceive(DBusMessage* msg){
+ currentMsg = msg;
+ if (!dbus_message_iter_init(currentMsg, &iter))
+ LOG_ERROR("DBUSCommunicator", "Message has no arguments!");
+}
+
+void initReply(){
+ // create a reply from the message
+ reply = dbus_message_new_method_return(currentMsg);
+ dbus_message_iter_init_append(reply, &iter);
+}
+
+void closeReply(){
+ // send the reply && flush the connection
+ if (!dbus_connection_send(conn, reply, &serial)) {
+ LOG_ERROR("DBUSCommunicator", "Out Of Memory!");
+ exit(1);
+ }
+ dbus_connection_flush(conn);
+
+ // free the reply
+ dbus_message_unref(reply);
+}
+
+
+
+void addIntrospectHeader(std::string& str){
+ str.append("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" \n \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\"> \n");
+}
+
+void addIntrospectNode(std::string& str, std::string nodename){
+ str.append("<node name=\"" + nodename + "\"> \n");
+}
+
+void addIntrospectinterface(std::string& str, std::string interfacename){
+ str.append("<interface name=\"" + interfacename + "\"> \n");
+}
+
+void addIntrospectMethod(std::string& str, std::string methodname){
+ str.append("<method name=\"" + methodname + "\"> \n");
+}
+
+void addIntrospectArg(std::string& str, std::string argname,std::string direction,std::string type){
+ str.append("<arg name=\"" + argname + "\" direction=\"" + direction + "\" type=\"" + type + "\"/> \n");
+}
+
+void closeIntrospectMethod(std::string& str){
+ str.append("</method> \n");
+}
+
+void closeIntrospectInterface(std::string& str){
+ str.append("</interface> \n");
+}
+
+void closeIntrospectNode(std::string& str){
+ str.append("</node> \n");
+}
+
+std::string generateIntrospectionString(MethodTable* table){
+LOG_DEBUG("DBUSCommunicator", "Generation introspection data");
+ std::string introspect;
+ addIntrospectHeader(introspect);
+ addIntrospectNode(introspect, "de.bmw.CompositingService");
+ addIntrospectinterface(introspect, "org.freedesktop.DBus.Introspectable");
+ addIntrospectMethod(introspect,"Introspect");
+ addIntrospectArg(introspect,"data","out","s");
+ closeIntrospectMethod(introspect);
+ closeIntrospectInterface(introspect);
+
+ addIntrospectinterface(introspect, "de.bmw.CompositingService");
+
+ int i=0;
+ while(strcmp(manager_methods[i].name,"")!=0){
+ MethodTable entry = table[i];
+ addIntrospectMethod(introspect,std::string(entry.name));
+ std::string signatureIN = std::string(entry.signature);
+ for (int c=0;c<signatureIN.length();c++){
+ switch(signatureIN.at(c)){
+ case 'a': addIntrospectArg(introspect,"","in","a" + signatureIN.at(c+1));c++; break;
+ default: addIntrospectArg(introspect,"","in","i"); break;
+ }
+ }
+
+ std::string reply = std::string(entry.reply);
+ for (int c=0;c<reply.length();c++){
+ switch(reply.at(c)){
+ case 'a':addIntrospectArg(introspect,"","out","a" + reply.at(c+1)); c++; break;
+ default:addIntrospectArg(introspect,"","out","i"); break;
+ }
+ }
+
+ closeIntrospectMethod(introspect);
+ i++;
+ }
+
+ closeIntrospectInterface(introspect);
+
+ closeIntrospectNode(introspect);
+ LOG_DEBUG("DBUSCommunicator", "returning introspection data");
+ return introspect;
+}
+
+DBUSCommunicator* DBUSCommunicator::m_reference = NULL;
+
+DBUSCommunicator::DBUSCommunicator(CommandExecutor* executor, ILayerList* ll) : BaseCommunicator(executor,ll){
+}
+
+DBUSCommunicator::~DBUSCommunicator(){
+
+}
+
+void DBUSCommunicator::setdebug(bool onoff){
+
+}
+
+bool DBUSCommunicator::start(){
+ LOG_INFO("DBUSCommunicator", "Starting up dbus connector");
+ DBusError err;
+ int ret;
+ // initialise the error
+ dbus_error_init(&err);
+
+ // connect to the bus and check for errors
+ LOG_INFO("DBUSCommunicator","get DBUS Session");
+ conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
+ if (dbus_error_is_set(&err)) {
+ LOG_ERROR("DBUSCommunicator","Connection error");
+ dbus_error_free(&err);
+ }
+ if (NULL == conn) {
+ LOG_ERROR("DBUSCommunicator","Connection is null");
+ exit(1);
+ }
+ LOG_INFO("DBUSCommunicator","request dbus name");
+ ret = dbus_bus_request_name(conn, "de.bmw.CompositingService", DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
+ if (dbus_error_is_set(&err)) {
+ LOG_ERROR("DBUSCommunicator", "Name Error "<< err.message);
+ dbus_error_free(&err);
+ }
+ if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
+ LOG_ERROR("DBUSCommunicator", "Not Primary Owner "<< ret);
+ exit(1);
+ }
+ LOG_INFO("DBUSCommunicator","create thread");
+ this->m_running = true;
+ pthread_create(&m_currentThread, NULL, DBUSCommunicator::run, this);
+ LOG_INFO("DBUSCommunicator", "Started dbus connector");
+ return true;
+}
+
+void DBUSCommunicator::stop(){
+ LOG_INFO("DBUSCommunicator","stopping");
+ this->m_running = false;
+ pthread_join(m_currentThread,NULL);
+ DBusError err;
+ dbus_error_init(&err);
+ bool errorset = dbus_error_is_set(&err);
+ if (errorset)
+ LOG_ERROR("DBUSCommunicator","there was an dbus error");
+ LOG_INFO("ask about owner name",0);
+ dbus_bus_name_has_owner(conn,"de.bmw.CompositingService",&err);
+ errorset = dbus_error_is_set(&err);
+ if (errorset)
+ LOG_ERROR("DBUSCommunicator","there was an dbus error");
+ dbus_error_init(&err);
+ dbus_bus_release_name(conn, "de.bmw.CompositingService",&err);
+ LOG_INFO("DBUSCommunicator", "Stopped dbus connector");
+}
+
+void introspectCallback(DBusConnection* conn,DBusMessage* msg )
+{
+ DBusMessage* reply;
+ DBusMessageIter args;
+ dbus_uint32_t serial = 0;
+ char* param;
+
+ // create a reply from the message
+ reply = dbus_message_new_method_return(msg);
+
+ std::string introspect = generateIntrospectionString(manager_methods);
+
+
+ const char* string = introspect.c_str();
+ // add the arguments to the reply
+ dbus_message_iter_init_append(reply, &args);
+ if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &string)) {
+ LOG_ERROR("DBUSCommunicator", "Out Of Memory!");
+ exit(1);
+ }
+
+ // send the reply && flush the connection
+ if (!dbus_connection_send(conn, reply, &serial)) {
+ LOG_ERROR("DBUSCommunicator", "Out Of Memory!");
+ exit(1);
+ }
+ dbus_connection_flush(conn);
+
+ // free the reply
+ dbus_message_unref(reply);
+}
+
+void DBUSCommunicator::Debug(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ bool param = getBoolFromMessage();
+
+ m_reference->m_executor->execute(new DebugCommand(param));
+
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::ListAllLayerIDS(DBusConnection* conn,DBusMessage* msg )
+{
+ currentMsg = msg;
+ int* array = NULL;
+ int length = 0;
+ m_reference->m_layerlist->getLayerIDs(&length,&array);
+ initReply();
+ DBusMessageIter arrayIter;
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "u", &arrayIter);
+ for ( int i = 0; i< length;i++)
+ dbus_message_iter_append_basic(&arrayIter,DBUS_TYPE_UINT32,&array[i]);
+ dbus_message_iter_close_container(&iter,&arrayIter);
+ closeReply();
+}
+
+void DBUSCommunicator::ListAllSurfaceIDS(DBusConnection* conn,DBusMessage* msg )
+{
+ currentMsg = msg;
+ int* array = NULL;
+ int length = 0;
+ m_reference->m_layerlist->getSurfaceIDs(&length,&array);
+ initReply();
+ DBusMessageIter arrayIter;
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "u", &arrayIter);
+ for ( int i = 0; i< length;i++)
+ dbus_message_iter_append_basic(&arrayIter,DBUS_TYPE_UINT32,&array[i]);
+ dbus_message_iter_close_container(&iter,&arrayIter);
+ closeReply();
+}
+
+void DBUSCommunicator::ListAllLayerGroupIDS(DBusConnection* conn,DBusMessage* msg )
+{
+ currentMsg = msg;
+ int* array = NULL;
+ int length = 0;
+ m_reference->m_layerlist->getLayerGroupIDs(&length,&array);
+ initReply();
+ DBusMessageIter arrayIter;
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "u", &arrayIter);
+ for ( int i = 0; i< length;i++)
+ dbus_message_iter_append_basic(&arrayIter,DBUS_TYPE_UINT32,&array[i]);
+ dbus_message_iter_close_container(&iter,&arrayIter);
+ closeReply();
+}
+
+void DBUSCommunicator::ListAllSurfaceGroupIDS(DBusConnection* conn,DBusMessage* msg )
+{
+ currentMsg = msg;
+ int* array = NULL;
+ int length = 0;
+ m_reference->m_layerlist->getSurfaceGroupIDs(&length,&array);
+ initReply();
+ DBusMessageIter arrayIter;
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "u", &arrayIter);
+ for ( int i = 0; i< length;i++)
+ dbus_message_iter_append_basic(&arrayIter,DBUS_TYPE_UINT32,&array[i]);
+ dbus_message_iter_close_container(&iter,&arrayIter);
+ closeReply();
+}
+
+void DBUSCommunicator::ListSurfacesOfSurfacegroup(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ SurfaceGroup* sg = m_reference->m_layerlist->getSurfaceGroup(id);
+ std::list<Surface*> surfaces = sg->getList();
+ initReply();
+ DBusMessageIter arrayIter;
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "u", &arrayIter);
+ for ( std::list<Surface*>::const_iterator it=surfaces.begin();it!=surfaces.end();it++){
+ Surface* s = *it;
+ int id = s->getID();
+ dbus_message_iter_append_basic(&arrayIter,DBUS_TYPE_UINT32,&id);
+ }
+ dbus_message_iter_close_container(&iter,&arrayIter);
+ closeReply();
+}
+
+void DBUSCommunicator::ListLayersOfLayergroup(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+
+ LayerGroup* sg = m_reference->m_layerlist->getLayerGroup(id);
+ std::list<Layer*> layers = sg->getList();
+ initReply();
+ DBusMessageIter arrayIter;
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "u", &arrayIter);
+ for ( std::list<Layer*>::const_iterator it=layers.begin();it!=layers.end();it++){
+ Layer* l = *it;
+ int id = l->getID();
+ dbus_message_iter_append_basic(&arrayIter,DBUS_TYPE_UINT32,&id);
+ }
+ dbus_message_iter_close_container(&iter,&arrayIter);
+ closeReply();
+}
+
+void DBUSCommunicator::ListSurfaceofLayer(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+
+ Layer* layer = m_reference->m_layerlist->getLayer(id);
+ std::list<Surface*> surfaces = layer->getAllSurfaces();
+ initReply();
+ DBusMessageIter arrayIter;
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "u", &arrayIter);
+ for ( std::list<Surface*>::const_iterator it=surfaces.begin();it!=surfaces.end();it++){
+ Surface* s = *it;
+ int id = s->getID();
+ dbus_message_iter_append_basic(&arrayIter,DBUS_TYPE_UINT32,&id);
+ }
+ dbus_message_iter_close_container(&iter,&arrayIter);
+ closeReply();
+}
+
+void DBUSCommunicator::getPropertiesOfSurface(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+
+ Surface* surface = m_reference->m_layerlist->getSurface(id);
+
+ initReply();
+ appendDouble(surface->getOpacity());
+ Rectangle dest = surface->getDestinationRegion();
+ Rectangle src = surface->getDestinationRegion();
+ appendUint(src.x);
+ appendUint(src.y);
+ appendUint(src.width);
+ appendUint(src.height);
+ appendUint(dest.x);
+ appendUint(dest.y);
+ appendUint(dest.width);
+ appendUint(dest.height);
+ OrientationType orientation = surface->getOrientation();
+ appendbyte((char)orientation);
+ appendBool(surface->getVisibility());
+ closeReply();
+}
+
+void DBUSCommunicator::getPropertiesOfLayer(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+
+ Layer* layer = m_reference->m_layerlist->getLayer(id);
+
+ initReply();
+ appendDouble(layer->getOpacity());
+ Rectangle dest = layer->getDestinationRegion();
+ Rectangle src = layer->getDestinationRegion();
+ appendUint(src.x);
+ appendUint(src.y);
+ appendUint(src.width);
+ appendUint(src.height);
+ appendUint(dest.x);
+ appendUint(dest.y);
+ appendUint(dest.width);
+ appendUint(dest.height);
+ OrientationType orientation = layer->getOrientation();
+ appendbyte((char)orientation);
+ appendBool(layer->getVisibility());
+ closeReply();
+}
+
+void DBUSCommunicator::CreateSurface(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint handle = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint pixelformat = getUIntFromMessage();
+ PixelFormat pf = (PixelFormat)pixelformat;
+
+ dbus_message_iter_next(&iter);
+ uint width = getUIntFromMessage();
+
+ dbus_message_iter_next(&iter);
+ uint height = getUIntFromMessage();
+ uint id;
+ m_reference->m_executor->execute(new CreateCommand(handle,TypeSurface,pf, width, height,&id));
+ initReply();
+ appendUint(id);
+ closeReply();
+}
+
+void DBUSCommunicator::RemoveSurface(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint param = getUIntFromMessage();
+ m_reference->m_executor->execute(new RemoveCommand(param,TypeSurface));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::CreateLayer(DBusConnection* conn,DBusMessage* msg )
+{
+ currentMsg = msg;
+ uint id;
+ m_reference->m_executor->execute(new CreateCommand(-1,TypeLayer,PIXELFORMAT_R8,0,0,&id));
+ initReply();
+ appendUint(id);
+ closeReply();
+}
+
+void DBUSCommunicator::RemoveLayer(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint param = getUIntFromMessage();
+ m_reference->m_executor->execute(new RemoveCommand(param,TypeLayer));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::AddSurfaceToSurfaceGroup(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint surfaceid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint surfacegroupid = getUIntFromMessage();
+ m_reference->m_executor->execute(new SurfacegroupAddSurfaceCommand(surfacegroupid,surfaceid));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::RemoveSurfaceFromSurfaceGroup(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint surfaceid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint surfacegroupid = getUIntFromMessage();
+ m_reference->m_executor->execute(new SurfacegroupRemoveSurfaceCommand(surfacegroupid,surfaceid));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::AddLayerToLayerGroup(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint layerid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint layergroupid = getUIntFromMessage();
+ m_reference->m_executor->execute(new LayergroupAddLayerCommand(layergroupid,layerid));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::RemoveLayerFromLayerGroup(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint layerid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint layergroupid = getUIntFromMessage();
+ m_reference->m_executor->execute(new LayergroupRemoveLayerCommand(layergroupid,layerid));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::AddSurfaceToLayer(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint surfaceid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint layer = getUIntFromMessage();
+ m_reference->m_executor->execute(new LayerAddSurfaceCommand(layer,surfaceid));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::RemoveSurfaceFromLayer(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint surfaceid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint layerid = getUIntFromMessage();
+ m_reference->m_executor->execute(new LayerRemoveSurfaceCommand(layerid,surfaceid));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::CreateSurfaceGroup(DBusConnection* conn,DBusMessage* msg )
+{
+ currentMsg = msg;
+ uint newID;
+ m_reference->m_executor->execute(new CreateCommand(-1,TypeSurfaceGroup,PIXELFORMAT_R8,0,0,&newID));
+ initReply();
+ appendUint(newID);
+ closeReply();
+}
+
+
+void DBUSCommunicator::RemoveSurfaceGroup(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint param = getUIntFromMessage();
+ m_reference->m_executor->execute(new RemoveCommand(param,TypeSurfaceGroup));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::CreateLayerGroup(DBusConnection* conn,DBusMessage* msg )
+{
+ currentMsg = msg;
+ uint newID;
+ m_reference->m_executor->execute(new CreateCommand(-1,TypeLayerGroup,PIXELFORMAT_R8,0,0,&newID));
+ initReply();
+ appendUint(newID);
+ closeReply();
+}
+
+void DBUSCommunicator::RemoveLayerGroup(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint param = getUIntFromMessage();
+ m_reference->m_executor->execute(new RemoveCommand(param,TypeLayerGroup));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetSurfaceSourceRegion(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint x = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint y = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint width = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint height = getUIntFromMessage();
+ m_reference->m_executor->execute(new SetSourceRectangleCommand(id,TypeSurface,x,y,width,height));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetLayerSourceRegion(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint x = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint y = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint width = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint height = getUIntFromMessage();
+ m_reference->m_executor->execute(new SetSourceRectangleCommand(id,TypeLayer,x,y,width,height));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetSurfaceDestinationRegion(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint x = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint y = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint width = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint height = getUIntFromMessage();
+ m_reference->m_executor->execute(new SetDestinationRectangleCommand(id,TypeSurface,x,y,width,height));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetSurfacePosition(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint x = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint y = getUIntFromMessage();
+ m_reference->m_executor->execute(new SetPositionCommand(id,TypeSurface,x,y));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::GetSurfacePosition(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ uint x;
+ uint y;
+ m_reference->m_executor->execute(new GetPositionCommand(id,TypeSurface,&x,&y));
+ initReply();
+ appendUint(x);
+ appendUint(y);
+ closeReply();
+}
+
+void DBUSCommunicator::SetSurfaceDimension(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint width = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint height = getUIntFromMessage();
+ m_reference->m_executor->execute(new SetDimensionCommand(id,TypeSurface,width,height));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetLayerDestinationRegion(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint x = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint y = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint width = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint height = getUIntFromMessage();
+ m_reference->m_executor->execute(new SetDestinationRectangleCommand(id,TypeLayer,x,y,width,height));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetLayerPosition(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint x = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint y = getUIntFromMessage();
+ m_reference->m_executor->execute(new SetPositionCommand(id,TypeLayer,x,y));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::GetLayerPosition(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ uint x;
+ uint y;
+ m_reference->m_executor->execute(new GetPositionCommand(id,TypeLayer,&x,&y));
+ initReply();
+ appendUint(x);
+ appendUint(y);
+ closeReply();
+}
+
+void DBUSCommunicator::SetLayerDimension(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint width = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint height = getUIntFromMessage();
+ m_reference->m_executor->execute(new SetDimensionCommand(id,TypeLayer,width,height));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::GetLayerDimension(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ uint width;
+ uint height;
+ m_reference->m_executor->execute(new GetDimensionCommand(id,TypeLayer,&width,&height));
+ initReply();
+ appendUint(width);
+ appendUint(height);
+ closeReply();
+}
+
+void DBUSCommunicator::GetSurfaceDimension(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ uint width;
+ uint height;
+ m_reference->m_executor->execute(new GetDimensionCommand(id,TypeSurface,&width,&height));
+ initReply();
+ appendUint(width);
+ appendUint(height);
+ closeReply();
+}
+
+void DBUSCommunicator::SetSurfaceOpacity(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ double param = getDoubleFromMessage();
+ m_reference->m_executor->execute(new SetOpacityCommand(id,TypeSurface,param));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetLayerOpacity(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ double param = getDoubleFromMessage();
+ m_reference->m_executor->execute(new SetOpacityCommand(id,TypeLayer,param));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetSurfacegroupOpacity(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ double param = getDoubleFromMessage();
+ m_reference->m_executor->execute(new SetOpacityCommand(id,TypeSurfaceGroup,param));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetLayergroupOpacity(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ double param = getDoubleFromMessage();
+ m_reference->m_executor->execute(new SetOpacityCommand(id,TypeLayerGroup,param));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::GetSurfaceOpacity(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ double param;
+ m_reference->m_executor->execute(new GetOpacityCommand(id,TypeSurface,¶m));
+ initReply();
+ appendDouble(param);
+ closeReply();
+}
+
+void DBUSCommunicator::GetLayerOpacity(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ double param;
+ m_reference->m_executor->execute(new GetOpacityCommand(id,TypeLayer,¶m));
+ initReply();
+ appendDouble(param);
+ closeReply();
+}
+
+void DBUSCommunicator::GetSurfacegroupOpacity(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ double param;
+ m_reference->m_executor->execute(new GetOpacityCommand(id,TypeSurfaceGroup,¶m));
+ initReply();
+ appendDouble(param);
+ closeReply();
+}
+
+void DBUSCommunicator::GetLayergroupOpacity(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ double param;
+ m_reference->m_executor->execute(new GetOpacityCommand(id,TypeLayerGroup,¶m));
+ initReply();
+ appendDouble(param);
+ closeReply();
+}
+
+void DBUSCommunicator::SetSurfaceOrientation(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint param = getUIntFromMessage();
+ OrientationType o = (OrientationType) param;
+ m_reference->m_executor->execute(new SetOrientationCommand(id,TypeSurface,o));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetLayerOrientation(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint param = getUIntFromMessage();
+ OrientationType o = (OrientationType) param;
+ m_reference->m_executor->execute(new SetOrientationCommand(id,TypeLayer,o));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::GetSurfacePixelformat(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ PixelFormat param;
+ m_reference->m_executor->execute(new GetPixelformatCommand(id,TypeSurface,¶m));
+ initReply();
+ appendbyte(param);
+ closeReply();
+}
+
+void DBUSCommunicator::SetSurfaceVisibility(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ const uint surfaceid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ bool newVis= getBoolFromMessage();
+ m_reference->m_executor->execute(new SetVisibilityCommand(surfaceid,TypeSurface,newVis));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetLayerVisibility(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint layerid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ bool myparam = getBoolFromMessage();
+ m_reference->m_executor->execute(new SetVisibilityCommand(layerid,TypeLayer,myparam));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::GetSurfaceVisibility(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ bool param;
+ m_reference->m_executor->execute(new GetVisibilityCommand(id,TypeSurface,¶m));
+ initReply();
+ appendBool(param);
+ closeReply();
+}
+
+void DBUSCommunicator::GetLayerVisibility(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ bool param;
+ m_reference->m_executor->execute(new GetVisibilityCommand(id,TypeLayer,¶m));
+ initReply();
+ appendBool(param);
+ closeReply();
+}
+
+void DBUSCommunicator::SetSurfacegroupVisibility(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint groupid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ bool myparam = getBoolFromMessage();
+ m_reference->m_executor->execute(new SetVisibilityCommand(groupid,TypeSurfaceGroup,myparam));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetLayergroupVisibility(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint groupid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ bool myparam = getBoolFromMessage();
+ m_reference->m_executor->execute(new SetVisibilityCommand(groupid,TypeLayerGroup,myparam));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetRenderOrderOfLayers(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ if (DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&iter))
+ LOG_ERROR("DBUSCommunicator","Argument is not an array!");
+ DBusMessageIter arrayIter;
+ dbus_message_iter_recurse(&iter,&arrayIter);
+ int* arr;
+ int length;
+ dbus_message_iter_get_fixed_array(&arrayIter,&arr,&length);
+
+ m_reference->m_executor->execute(new SetLayerOrderCommand(arr,length));
+
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetSurfaceRenderOrderWithinLayer(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint layerid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+
+ if (DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&iter))
+ LOG_ERROR("DBUSCommunicator", "Argument is not an array!");
+ DBusMessageIter arrayIter;
+ dbus_message_iter_recurse(&iter,&arrayIter);
+ int* arr;
+ int length;
+ dbus_message_iter_get_fixed_array(&arrayIter,&arr,&length);
+
+ m_reference->m_executor->execute(new SetOrderWithinLayerCommand(layerid,arr,length));
+
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::GetLayerType(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ Layer* l = m_reference->m_layerlist->getLayer(id);
+ initReply();
+ appendUint(l->getLayerType());
+ closeReply();
+}
+
+void DBUSCommunicator::GetLayertypeCapabilities(DBusConnection* conn,DBusMessage* msg )
+{
+
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ LayerType type = (LayerType)id;
+ uint capabilities = m_reference->m_executor->getLayerTypeCapabilities(type);
+ initReply();
+ appendUint(capabilities);
+ closeReply();
+}
+
+void DBUSCommunicator::GetLayerCapabilities(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ Layer* l = m_reference->m_layerlist->getLayer(id);
+ initReply();
+ appendUint(l->getCapabilities());
+ closeReply();
+}
+
+void DBUSCommunicator::FadeIn(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SynchronizedFade(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::FadeOut(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::Exit(DBusConnection* conn,DBusMessage* msg )
+{
+ currentMsg = msg;
+ m_reference->m_executor->execute(new ExitCommand());
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::CommitChanges(DBusConnection* conn,DBusMessage* msg )
+{
+ currentMsg = msg;
+ m_reference->m_executor->execute(new CommitCommand());
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::CreateShader(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ char* vertname = getStringFromMessage();
+ dbus_message_iter_next(&iter);
+ char* fragname = getStringFromMessage();
+ uint id;
+ m_reference->m_executor->execute(new CreateShaderCommand(vertname,fragname,&id));
+ initReply();
+ appendUint(id);
+ closeReply();
+}
+
+void DBUSCommunicator::DestroyShader(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint shaderid = getUIntFromMessage();
+ m_reference->m_executor->execute(new DestroyShaderCommand(shaderid));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetShader(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint objectid = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ uint shaderid = getUIntFromMessage();
+ m_reference->m_executor->execute(new SetShaderCommand(objectid,shaderid));
+ initReply();
+ closeReply();
+}
+
+void DBUSCommunicator::SetUniforms(DBusConnection* conn,DBusMessage* msg )
+{
+ initReceive(msg);
+ uint id = getUIntFromMessage();
+ dbus_message_iter_next(&iter);
+ if (DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&iter))
+ LOG_ERROR("DBUSCommunicator", "Argument is not an array!");
+ std::vector<std::string> uniforms;
+ DBusMessageIter arrayIter;
+
+ dbus_message_iter_recurse(&iter,&arrayIter);
+ bool hasNext = true;
+ while(hasNext){
+ if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&arrayIter))
+ LOG_ERROR("DBUSCommunicator", "Argument is not an string!");
+ char* param;
+ dbus_message_iter_get_basic(&arrayIter,¶m);
+ uniforms.push_back(std::string(param));
+ if (dbus_message_iter_has_next(&arrayIter))
+ dbus_message_iter_next(&arrayIter);
+ else
+ hasNext = false;
+ }
+
+ m_reference->m_executor->execute(new SetUniformsCommand(id,uniforms));
+ initReply();
+ closeReply();
+}
+
+void* DBUSCommunicator::run(void * arg){
+ LOG_INFO("DBUSCommunicator","Running..");
+// pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL);
+// pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ m_reference = (DBUSCommunicator*)arg;
+ while(m_reference->m_running){
+// pthread_testcancel();
+ dbus_connection_read_write(conn, 50);
+ DBusMessage* msg = dbus_connection_pop_message(conn);
+ if (NULL!=msg){
+ const char *n = dbus_message_get_member (msg);
+
+ bool found = false;
+ int i=0;
+ while(!found && strcmp(manager_methods[i].name,"")!=0){
+ if (n && strcmp(manager_methods[i].name,n) == 0){
+ MethodTable entry = manager_methods[i];
+ LOG_DEBUG("DBUSC","called methodname:" << entry.name);
+ CallBackMethod m = entry.function;
+ (m_reference->*m)(conn,msg);
+ found = true;
+ }
+ i++;
+ }
+ if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")){
+ LOG_DEBUG("DBUSCommunicator", "Introspection called");
+ introspectCallback(conn, msg);
+ found = true;
+ }
+ if (!found){
+ DBusMessage* reply = dbus_message_new_method_return(msg);
+ uint serial = 0;
+ // send the reply && flush the connection
+ if (!dbus_connection_send(conn, reply, &serial)) {
+ LOG_ERROR("DBUSCommunicator", "Out Of Memory!");
+ exit(1);
+ }
+ dbus_connection_flush(conn);
+
+ // free the reply
+ dbus_message_unref(reply);
+ }
+
+ }
+ }
+
+ LOG_DEBUG("DBUSCommunicator","ending thread");
+ return 0;
+}
+
+extern "C" DBUSCommunicator* createDBUSCommunicator(CommandExecutor* executor, LayerList* ll) {
+ return new DBUSCommunicator(executor,ll);
+}
+
+extern "C" void destroyDBUSCommunicator(DBUSCommunicator* p) {
+ delete p;
+}
+
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _BASERENDERER_H_
+#define _BASERENDERER_H_
+
+#include "LayerType.h"
+#include "LayerList.h"
+#include "IRenderer.h"
+#include "WindowSystems/BaseWindowSystem.h"
+
+class BaseRenderer : public IRenderer{
+protected:
+ BaseRenderer(LayerList* layerlist);
+ ~BaseRenderer();
+
+ bool start(int, int, const char*);
+ void stop(){};
+ void setdebug(bool onoff){debugMode = onoff;};
+ uint getLayerTypeCapabilities(LayerType layerType);
+
+protected:
+ BaseWindowSystem* m_windowSystem;
+ LayerList* m_layerlist;
+
+private:
+ static bool debugMode;
+};
+
+#endif /* _BASERENDERER_H_*/
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _RENDERUTIL_H_
+#define _RENDERUTIL_H_
+
+#include "GLES2/gl2.h"
+#include "Log.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <iostream>
+
+// Loads a file containing shader code
+static char* RenderUtilLoadShaderFile(const char *szFilename)
+{
+ if(!szFilename)
+ {
+ return(NULL);
+ }
+
+ FILE *pFile;
+ pFile = fopen(szFilename, "rb");
+ if(!pFile)
+ {
+ LOG_ERROR("RenderUtilLoadShaderFile","Unable to open ShaderFile " << szFilename);
+ return(NULL);
+ }
+
+ fseek(pFile, 0, SEEK_END);
+ long size = ftell(pFile);
+ fseek(pFile, 0, SEEK_SET);
+
+ char *pBuffer = new char[size+1];
+ if(!pBuffer)
+ {
+ LOG_ERROR("RenderUtilLoadShaderFile","Unable to allocate Memory for ShaderFile " << szFilename);
+ fclose(pFile);
+ return(NULL);
+ }
+
+ if(1 != fread(pBuffer, size, 1, pFile))
+ {
+ LOG_ERROR("RenderUtilLoadShaderFile","Unable to allocate Memory for ShaderFile " << szFilename);
+ fclose(pFile);
+ delete [] pBuffer;
+ return(NULL);
+ }
+
+ pBuffer[size] = 0;
+ fclose(pFile);
+ LOG_DEBUG("RenderUtilShaderDebug","loaded file with bytes: " << size);
+ return(pBuffer);
+}
+
+
+
+// If shader compilation fails, prints the associated logs
+static void RenderUtilShaderDebug(GLuint obj, GLenum status, const char* op)
+{
+ char errorMessage[1024];
+ int success;
+ // log output.
+ int len;
+ char *str = NULL;
+ if (status == GL_COMPILE_STATUS) {
+ glGetShaderiv(obj, GL_INFO_LOG_LENGTH, &len);
+ if (len > 0) {
+ str = new char[len];
+ glGetShaderInfoLog(obj, len, NULL, str);
+ }
+ } else { // LINK
+ glGetProgramiv(obj, GL_INFO_LOG_LENGTH, &len);
+ if (len > 0) {
+ str = new char[len];
+ glGetProgramInfoLog(obj, len, NULL, str);
+ }
+ }
+ if (str != NULL && *str != '\0') {
+ strncpy(errorMessage, "--- ",1024);
+ strncat(errorMessage,op, 1000);
+ strncat(errorMessage, " log ---", 8);
+ LOG_DEBUG("RenderUtilShaderDebug",errorMessage);
+ LOG_DEBUG("RenderUtilShaderDebug",str);
+ }
+ if (str) { delete[] str; }
+
+ // check the compile / link status.
+ if (status == GL_COMPILE_STATUS) {
+ glGetShaderiv(obj, status, &success);
+ if (!success) {
+ glGetShaderiv(obj, GL_SHADER_SOURCE_LENGTH, &len);
+ if (len > 0) {
+ str = new char[len];
+ glGetShaderSource(obj, len, NULL, str);
+ if (str != NULL && *str != '\0') {
+ strncpy(errorMessage, "--- ",1024);
+ strncat(errorMessage,op, 1000);
+ strncat(errorMessage, " log ---", 8);
+ LOG_DEBUG("RenderUtilShaderDebug",errorMessage);
+ LOG_DEBUG("RenderUtilShaderDebug",str);
+ }
+ delete[] str;
+ }
+ }
+ } else { // LINK
+ glGetProgramiv(obj, status, &success);
+ }
+
+ if (!success)
+ {
+ strncpy(errorMessage, "--- ",1024);
+ strncat(errorMessage,op, 1000);
+ strncat(errorMessage, " failed ---", 7);
+ LOG_DEBUG("RenderUtilShaderDebug",errorMessage);
+ }
+}
+
+// Take precompiled shader binaries and builds a shader program
+static GLuint RenderUtilLoadShaderBinaries(
+ const char* vertBin, GLuint vertBinSize,
+ const char* fragBin, GLuint fragBinSize,
+ GLuint binaryFormat,
+ GLboolean debugging)
+{
+// Binary shaders not supportable for non-ES OpenGL
+#ifdef GL_ES_VERSION_2_0
+
+ GLuint prog;
+ GLuint vertShader;
+ GLuint fragShader;
+
+ // Create the program
+ prog = glCreateProgram();
+
+ // Create the GL shader objects
+ vertShader = glCreateShader(GL_VERTEX_SHADER);
+ fragShader = glCreateShader(GL_FRAGMENT_SHADER);
+
+ // Load the binary data into the shader objects
+ glShaderBinary(1, &vertShader,
+ binaryFormat, vertBin, vertBinSize);
+ glShaderBinary(1, &fragShader,
+ binaryFormat, fragBin, fragBinSize);
+
+ // Attach the shaders to the program
+ glAttachShader(prog, vertShader);
+ glAttachShader(prog, fragShader);
+
+#if 0
+ // Delete the shaders
+ glDeleteShader(vertShader);
+ glDeleteShader(fragShader);
+#endif
+
+ // Link the shader program
+ glLinkProgram(prog);
+ if (debugging)
+ RenderUtilShaderDebug(prog, GL_LINK_STATUS, "Program Link");
+
+ return prog;
+#else // GL_ES_VERSION_2_0
+ return 0;
+#endif // GL_ES_VERSION_2_0
+}
+
+// Takes shader source files, compiles them, and builds a shader program
+static GLuint RenderUtilLoadShaderSources(
+ const char* vertFile,
+ const char* fragFile,
+ GLboolean debugging)
+{
+ LOG_DEBUG("RenderUtilShaderDebug","loading shaders sources");
+ LOG_DEBUG("RenderUtilShaderDebug","loading vertex shader: " << vertFile);
+ LOG_DEBUG("RenderUtilShaderDebug","loading fragment shader: " << fragFile);
+ GLuint prog = 0;
+ char* vertSource;
+ char* fragSource;
+ GLint vertSourceLen;
+ GLint fragSourceLen;
+ GLuint vertShader;
+ GLuint fragShader;
+ GLint compiled;
+ GLint linked;
+
+ // Load the shader files
+ vertSource =RenderUtilLoadShaderFile(vertFile);
+ fragSource = RenderUtilLoadShaderFile(fragFile);
+ LOG_DEBUG("RenderUtilShaderDebug","loaded shaders source files");
+ if (!vertSource || !fragSource) goto done;
+ vertSourceLen = (GLint)strlen(vertSource);
+ fragSourceLen = (GLint)strlen(fragSource);
+
+ // Create the program
+ prog = glCreateProgram();
+if (prog==0)
+ LOG_DEBUG("RenderUtilShaderDebug","could not create prog, prog is 0");
+
+ // Create the GL shader objects
+ vertShader = glCreateShader(GL_VERTEX_SHADER);
+ fragShader = glCreateShader(GL_FRAGMENT_SHADER);
+
+ // Load shader sources into GL and compile
+ glShaderSource(vertShader, 1, (const char**)&vertSource, &vertSourceLen);
+ glCompileShader(vertShader);
+ if (debugging)
+ RenderUtilShaderDebug(vertShader, GL_COMPILE_STATUS, "Vert Compile");
+
+ glGetShaderiv(vertShader, GL_COMPILE_STATUS, &compiled);
+ if (compiled)
+ {
+ glShaderSource(fragShader, 1, (const char**)&fragSource, &fragSourceLen);
+ glCompileShader(fragShader);
+ if (debugging)
+ RenderUtilShaderDebug(fragShader, GL_COMPILE_STATUS, "Frag Compile");
+ glGetShaderiv(fragShader, GL_COMPILE_STATUS, &compiled);
+ if (compiled)
+ {
+ // Attach the shaders to the program
+ glAttachShader(prog, vertShader);
+ glAttachShader(prog, fragShader);
+
+ // Delete the shaders
+ glDeleteShader(vertShader);
+ glDeleteShader(fragShader);
+
+ // Link and validate the shader program
+ glLinkProgram(prog);
+
+ if (debugging)
+ RenderUtilShaderDebug(prog, GL_LINK_STATUS, "Program Link");
+ glValidateProgram(prog);
+ if (debugging)
+ RenderUtilShaderDebug(prog, GL_VALIDATE_STATUS, "Program Validate");
+
+ glGetProgramiv(prog, GL_LINK_STATUS, &linked);
+ if (!linked)
+ LOG_DEBUG("RenderUtilShaderDebug","could not link shader");
+ }else{
+ LOG_DEBUG("RenderUtilShaderDebug","could not compile fragment shader");
+}
+
+ }else{
+ LOG_DEBUG("RenderUtilShaderDebug","could not compile vertex shader");
+}
+
+ if (!compiled || !linked)
+ {
+ glDeleteProgram(prog);
+ prog = 0;
+ }
+
+ done:
+
+ delete[] fragSource;
+ delete[] vertSource;
+ return prog;
+}
+
+#endif /* _RENDERUTIL_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "LayerCapabilities.h"
+#include "BaseRenderer.h"
+bool BaseRenderer::debugMode = true;
+
+BaseRenderer::BaseRenderer(LayerList* layerlist) : m_layerlist(layerlist)
+{
+ LOG_DEBUG("BaseRenderer", "Creating Renderer");
+};
+BaseRenderer::~BaseRenderer()
+{
+};
+
+uint BaseRenderer::getLayerTypeCapabilities(LayerType layerType){
+ uint result = 0;
+ switch(layerType)
+ {
+ case Software_2D:
+ {
+ result = LayerPosition & LayerScalable & LayerOrientable;
+ }
+ break;
+ case Software_2_5D:
+ {
+ result = LayerPosition & LayerScalable & LayerOrientable & Layer3D;
+ }
+ break;
+ default :
+ {
+ result = 0;
+ }
+ }
+ return result;
+}
+
+bool BaseRenderer::start(int displayWidth, int displayHeight, const char* DisplayName){
+ bool windowSystemStatus = m_windowSystem->start(displayWidth,displayHeight,DisplayName);
+ return windowSystemStatus;
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _BASEGRAPHICSYSTEM_H_
+#define _BASEGRAPHICSYSTEM_H_
+
+#include "TextureBinders/ITextureBinder.h"
+#include "PlatformSurface.h"
+#include "Surface.h"
+#include "Layer.h"
+
+class BaseGraphicSystem {
+public:
+ virtual bool init(void* display, void* WindowID,int WindowHeight, int WindowWidth)=0;
+ virtual void drawSurface(Layer*,Surface*)=0;
+ virtual void clearBackground()=0;
+ virtual void swapBuffers()=0;
+
+ ITextureBinder* m_binder;
+
+};
+
+#endif /* _BASEGRAPHICSYSTEM_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _GLESGRAPHICSYSTEM_H_
+#define _GLESGRAPHICSYSTEM_H_
+
+#include "GraphicSystems/BaseGraphicSystem.h"
+#include "ShaderProgramFactory.h"
+#include "EGL/egl.h"
+#include "Log.h"
+#include "Shader.h"
+
+class GLESGraphicsystem : public BaseGraphicSystem {
+public:
+ GLESGraphicsystem(PfnShaderProgramCreator shaderProgram, ITextureBinder* binder);
+
+ bool init(void* display, void* WindowID,int WindowHeight, int WindowWidth);
+ void clearBackground();
+ void swapBuffers();
+ void drawSurface(Layer* currentLayer, Surface* surface);
+ bool initOpenGLES(EGLint displayWidth, EGLint displayHeight);
+ void resize(EGLint displayWidth, EGLint displayHeight);
+
+ PfnShaderProgramCreator m_shaderCreatorFunc;
+ EGLConfig m_eglConfig;
+ EGLContext m_eglContext;
+ EGLSurface m_eglSurface;
+ EGLDisplay m_eglDisplay;
+ uint m_vbo;
+ EGLint m_displayWidth;
+ EGLint m_displayHeight;
+ EGLBoolean m_blendingStatus;
+ Shader* defaultShader;
+};
+
+#endif /* _GLESGRAPHICSYSTEM_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _BEAGLEPLATFORMSURFACE_H_
+#define _BEAGLEPLATFORMSURFACE_H_
+
+#include "Surface.h"
+#include "GLES2/gl2.h"
+#include "EGL/egl.h"
+#include "EGL/eglext.h"
+#include "PlatformSurface.h"
+
+typedef struct _NATIVE_PIXMAP_STRUCT
+{
+ long ePixelFormat;
+ long eRotation;
+ long lWidth;
+ long lHeight;
+ long lStride;
+ long lSizeInBytes;
+ long pvAddress;
+ long lAddress;
+}NATIVE_PIXMAP_STRUCT;
+
+class BeaglePlatformSurface : public PlatformSurface {
+public:
+ BeaglePlatformSurface (Surface* surface) : PlatformSurface(surface), eglImage(0){};
+ ~BeaglePlatformSurface(){};
+
+ EGLImageKHR eglImage;
+ NATIVE_PIXMAP_STRUCT* pixmap;
+ GLuint texture;
+};
+
+#endif /* _BEAGLEPLATFORMSURFACE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _EGLXPLATFORMSURFACE_H_
+#define _EGLXPLATFORMSURFACE_H_
+
+#include "Surface.h"
+#include "GLES2/gl2.h"
+#include "EGL/egl.h"
+#include "EGL/eglext.h"
+#include "XPlatformSurface.h"
+
+class EglXPlatformSurface : public XPlatformSurface {
+public:
+ EglXPlatformSurface (Surface* surface) : XPlatformSurface(surface), eglImage(0){};
+ ~EglXPlatformSurface(){};
+
+ EGLImageKHR eglImage;
+};
+
+#endif /* _EGLXPLATFORMSURFACE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _XPLATFORMSURFACE_H_
+#define _XPLATFORMSURFACE_H_
+
+#include "PlatformSurface.h"
+#include "Surface.h"
+#include "X11/X.h"
+
+class XPlatformSurface : public PlatformSurface {
+public:
+ XPlatformSurface (Surface* surface) : PlatformSurface(surface), isMapped(false){};
+ ~XPlatformSurface(){};
+
+ Pixmap pixmap;
+ bool isMapped;
+ uint texture;
+};
+
+#endif /* _XPLATFORMSURFACE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _BEAGLEEGLIMAGE_H_
+#define _BEAGLEEGLIMAGE_H_
+
+#include "TextureBinders/ITextureBinder.h"
+#include <EGL/egl.h>
+#include "EGL/eglext.h"
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <cmem.h>
+#include "PlatformSurfaces/BeaglePlatformSurface.h"
+
+class BeagleEglImage : public ITextureBinder {
+public:
+ BeagleEglImage(){
+ LOG_INFO("BeagleEglImage", "Query EGL Extensions ...");
+ CMEM_init();
+ m_pfGLEglImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)
+ eglGetProcAddress("glEGLImageTargetTexture2DOES");
+ m_pfEglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)
+ eglGetProcAddress("eglCreateImageKHR");
+ m_pfEglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)
+ eglGetProcAddress("eglDestroyImageKHR");
+
+ if (!m_pfEglCreateImageKHR || !m_pfEglDestroyImageKHR || !m_pfGLEglImageTargetTexture2DOES)
+ {
+ LOG_ERROR("BeagleEglImage", "Query EGL Extensions failed");
+ }
+
+ m_eglDisplay = eglGetDisplay(0);
+ }
+ void bindSurfaceTexture(Surface*s){
+ // LOG_INFO("BeagleEglImage", "bindSurfaceTexture");
+ BeaglePlatformSurface* nativeSurface = (BeaglePlatformSurface*)s->platform;
+ glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
+ if (nativeSurface->eglImage != NULL){
+ // LOG_INFO("BeagleEglImage", "bindSurfaceTexture");
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ eglWaitNative(EGL_CORE_NATIVE_ENGINE);
+ m_pfGLEglImageTargetTexture2DOES(GL_TEXTURE_2D, nativeSurface->eglImage);
+ }
+ }
+
+ void unbindSurfaceTexture(Surface*s){
+
+ }
+
+ PlatformSurface* createPlatformSurface(Surface* s){
+ return new BeaglePlatformSurface(s);
+ }
+
+ void createClientBuffer(Surface* surface){
+ LOG_INFO("BeagleEglImage", "createClientBuffer");
+ BeaglePlatformSurface* nativeSurface = (BeaglePlatformSurface*)surface->platform;
+ NATIVE_PIXMAP_STRUCT* pNativePixmap = (NATIVE_PIXMAP_STRUCT*)malloc(sizeof(NATIVE_PIXMAP_STRUCT));
+ pNativePixmap->ePixelFormat = 2;
+ pNativePixmap->eRotation = 0;
+ pNativePixmap->lWidth = 256;//surface->OriginalSourceWidth;//480;
+ pNativePixmap->lHeight = 256;//surface->OriginalSourceHeight;//640;
+ pNativePixmap->lStride = pNativePixmap->lWidth* 32/8; //bitwidth/8
+ pNativePixmap->lSizeInBytes = pNativePixmap->lHeight * pNativePixmap->lStride;
+ pNativePixmap->lAddress = (long)CMEM_registerAlloc(surface->nativeHandle);
+ if(!pNativePixmap->lAddress)
+ {
+ LOG_ERROR("BeagleEglImage","CMEM_alloc returned NULL\n");
+ exit(-1);
+ }
+ //Get the physical page corresponding to the above cmem buffer
+ pNativePixmap->pvAddress = surface->nativeHandle; //;CMEM_getPhys((void*)pNativePixmap->lAddress);
+ LOG_DEBUG("BeagleEglImage","Physical address = "<< pNativePixmap->pvAddress);
+ LOG_DEBUG("BeagleEglImage","Logical address = "<< pNativePixmap->lAddress);
+
+ nativeSurface->eglImage = m_pfEglCreateImageKHR(
+ m_eglDisplay,
+ EGL_NO_CONTEXT, //eglContext,
+ EGL_NATIVE_PIXMAP_KHR, //EGL_GL_TEXTURE_2D_KHR,
+ pNativePixmap, //(void*)textureId0,//
+ NULL //miplevel 0 is fine, thank you
+ );
+
+ if (nativeSurface->eglImage == 0)
+ {
+ LOG_DEBUG("BeagleEglImage", "could not allocate EGL Image for window");
+ } else {
+ glGenTextures(1,&nativeSurface->texture);
+ }
+ }
+
+ void destroyClientBuffer(Surface* surface){
+ }
+private:
+ PFNEGLCREATEIMAGEKHRPROC m_pfEglCreateImageKHR;
+ PFNEGLDESTROYIMAGEKHRPROC m_pfEglDestroyImageKHR;
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_pfGLEglImageTargetTexture2DOES;
+ EGLDisplay m_eglDisplay;
+};
+
+#endif /* _BEAGLEEGLIMAGE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _ITEXTUREBINDER_H_
+#define _ITEXTUREBINDER_H_
+
+#include "Surface.h"
+
+class ITextureBinder {
+public:
+ virtual void bindSurfaceTexture(Surface*s)=0;
+ virtual void unbindSurfaceTexture(Surface*s)=0;
+ virtual void createClientBuffer(Surface*s)=0;
+ virtual void destroyClientBuffer(Surface*s)=0;
+ virtual PlatformSurface* createPlatformSurface(Surface* s)=0;
+};
+
+#endif /* _ITEXTUREBINDER_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _X11COPY_H_
+#define _X11COPY_H_
+
+#include "TextureBinders/ITextureBinder.h"
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include "PlatformSurfaces/XPlatformSurface.h"
+#include <X11/extensions/Xcomposite.h>
+
+class X11Copy : public ITextureBinder {
+public:
+ X11Copy(Display* display);
+ void virtual bindSurfaceTexture(Surface* surface)=0;
+ void unbindSurfaceTexture(Surface*s);
+ void virtual createClientBuffer(Surface*s) =0;
+ void destroyClientBuffer(Surface*s);
+ virtual PlatformSurface* createPlatformSurface(Surface* s);
+
+protected:
+ Display* dpy;
+};
+
+#endif /* _X11COPY_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _X11COPYGLES_H_
+#define _X11COPYGLES_H_
+
+#include "TextureBinders/X11Copy.h"
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include "PlatformSurfaces/XPlatformSurface.h"
+#include <X11/extensions/Xcomposite.h>
+
+class X11CopyGLES : public X11Copy {
+public:
+ X11CopyGLES(Display* display) : X11Copy(display){};
+ void bindSurfaceTexture(Surface* surface);
+ void createClientBuffer(Surface*s);
+
+};
+
+#endif /* _X11COPYGLES_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _X11EGLIMAGE_H_
+#define _X11EGLIMAGE_H_
+
+#include "TextureBinders/ITextureBinder.h"
+#include "X11/extensions/Xcomposite.h"
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+class X11EglImage : public ITextureBinder {
+public:
+ X11EglImage(Display* x11display);
+ void bindSurfaceTexture(Surface*s);
+ void unbindSurfaceTexture(Surface*s);
+ void createClientBuffer(Surface* surface);
+ void destroyClientBuffer(Surface* surface);
+ virtual PlatformSurface* createPlatformSurface(Surface* s);
+
+private:
+ PFNEGLCREATEIMAGEKHRPROC m_pfEglCreateImageKHR;
+ PFNEGLDESTROYIMAGEKHRPROC m_pfEglDestroyImageKHR;
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC m_pfGLEglImageTargetTexture2DOES;
+ EGLDisplay m_eglDisplay;
+ Display* m_x11display;
+};
+
+#endif /* _X11EGLIMAGE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _BASEWINDOWSYSTEM_H_
+#define _BASEWINDOWSYSTEM_H_
+
+#include "GraphicSystems/BaseGraphicSystem.h"
+#include "LayerList.h"
+
+class BaseWindowSystem {
+public:
+ BaseWindowSystem(LayerList* layerlist, BaseGraphicSystem* graphicSystem) : graphicSystem(graphicSystem), layerlist(layerlist){};
+ virtual bool start(int, int, const char*)=0;
+ virtual void stop()=0;
+
+protected:
+ BaseGraphicSystem* graphicSystem;
+ LayerList* layerlist;
+};
+
+#endif /* _BASEWINDOWSYSTEM_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _NULLWINDOWSYSTEM_H_
+#define _NULLWINDOWSYSTEM_H_
+
+#include "WindowSystems/BaseWindowSystem.h"
+#include "Surface.h"
+#include "Log.h"
+
+class NullWindowSystem : public BaseWindowSystem {
+public:
+ NullWindowSystem(LayerList* layerlist, BaseGraphicSystem* graphicSystem) : BaseWindowSystem(layerlist, graphicSystem){
+ LOG_DEBUG("NullWindowSystem", "creating BeagleWindowSystem");
+ };
+ bool start(int, int, const char*);
+ void stop(){};
+
+private:
+ static void* EventLoop(void * ptr);
+
+protected:
+ static int windowWidth;
+ static int windowHeight;
+ static bool m_success;
+ static bool m_initialized;
+
+private:
+ void Redraw();
+ void printDebug(int posx,int posy);
+ static bool debugMode;
+ static int resolutionWidth;
+ static int resolutionHeight;
+};
+
+#endif /* _NULLWINDOWSYSTEM_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _X11WINDOWSYSTEM_H_
+#define _X11WINDOWSYSTEM_H_
+
+#include "WindowSystems/BaseWindowSystem.h"
+#include "X11/Xlib.h"
+#include "Surface.h"
+#include "PlatformSurfaces/XPlatformSurface.h"
+#include <X11/Xutil.h>
+#include "Log.h"
+
+typedef XVisualInfo* (*GetVisualInfoFunction)(Display *dpy);
+
+class X11WindowSystem : public BaseWindowSystem {
+public:
+ X11WindowSystem(LayerList* layerlist, BaseGraphicSystem* graphicSystem,GetVisualInfoFunction func=X11WindowSystem::getDefaultVisual );
+ bool start(int, int, const char*);
+ void stop(){};
+
+ static XVisualInfo *
+ getDefaultVisual(Display *dpy);
+private:
+ static void* EventLoop(void * ptr);
+ static int error (Display *dpy, XErrorEvent *ev);
+ GetVisualInfoFunction getVisualFunc;
+
+protected:
+ Display* x11Display;
+ bool initXServer();
+ //void setDisplayMode();
+ int windowWidth;
+ int windowHeight;
+ // Window background;
+ Window CompositorWindow;
+ XVisualInfo* windowVis;
+ static bool m_success;
+ static bool m_initialized;
+
+private:
+ void Redraw();
+ void OpenDisplayConnection();
+ void checkForCompositeExtension();
+ void createSurfaceForWindow(Window w);
+ void configureSurfaceWindow(Window w);
+ Surface* getSurfaceForWindow(Window w);
+ void destroy_surface(Window w);
+ void updateSurface(Surface* s, Window w, XPlatformSurface* x11surf);
+ void MapWindow(Window w);
+ void UnMapWindow(Window w);
+ void NewWindow(Surface* s, Window w);
+ void DestroyWindow(Window w);
+ bool isWindowValid(Window w);
+ bool CreatePixmapsForAllWindows();
+ bool CreateCompositorWindow();
+ void UnredirectSpecialWIndows(Window w);
+ void printDebug(int posx,int posy);
+ bool debugMode;
+ int resolutionWidth;
+ int resolutionHeight;
+ static int composite_opcode;
+ int composite_event, composite_error;
+ int composite_major, composite_minor;
+ static const char CompositorWindowTitle[];
+};
+
+#endif /* _X11WINDOWSYSTEM_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "GraphicSystems/GLESGraphicSystem.h"
+
+#include "string.h"
+#include "EGL/egl.h"
+#include "GLES2/gl2.h"
+
+static const float vertices[8*12] = {
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 1.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 0.0,
+
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 1.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 0.0,
+
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 1.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 0.0,
+
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 0.0,
+ 1.0, 0.0,
+
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 1.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 0.0,
+
+ 1.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 0.0,
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 1.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 0.0,
+
+ 0.0, 1.0,
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 0.0, 1.0
+
+};
+
+GLESGraphicsystem::GLESGraphicsystem(PfnShaderProgramCreator shaderProgram, ITextureBinder* binder ) : m_shaderCreatorFunc(shaderProgram){
+ LOG_DEBUG("GLESGraphicsystem", "creating GLESGraphicsystem");
+ m_binder = binder;
+};
+
+bool GLESGraphicsystem::init(void* displayPtr, void* WIndowIDPtr,int WindowHeight, int WindowWidth){
+ EGLNativeDisplayType display = *(EGLNativeDisplayType*)displayPtr;
+ LOG_DEBUG("GLESGraphicsystem", "Using EGLNativeDisplay:" << display);
+ EGLNativeWindowType WIndowID = *(EGLNativeWindowType*)WIndowIDPtr;
+ LOG_DEBUG("GLESGraphicsystem", "Using EGLNativeWindow:" << WIndowID);
+
+ EGLint iMajorVersion, iMinorVersion;
+ LOG_DEBUG("GLESGraphicsystem", "Getting EGL Display");
+ m_eglDisplay = eglGetDisplay(display);
+
+ LOG_DEBUG("GLESGraphicsystem", "Initialising EGL");
+ if (!eglInitialize(m_eglDisplay, &iMajorVersion, &iMinorVersion))
+ return false;
+
+ LOG_DEBUG("GLESGraphicsystem", "Binding GLES API");
+ eglBindAPI(EGL_OPENGL_ES_API);
+
+ EGLint pi32ConfigAttribs[]={
+ EGL_SURFACE_TYPE,EGL_WINDOW_BIT | EGL_PIXMAP_BIT,
+ EGL_RENDERABLE_TYPE,EGL_OPENGL_ES2_BIT,
+ EGL_ALPHA_SIZE,8,
+ EGL_NONE
+ };
+
+ LOG_DEBUG("GLESGraphicsystem", "EGLChooseConfig");
+ int iConfigs;
+ if (!eglChooseConfig(m_eglDisplay, pi32ConfigAttribs, &m_eglConfig, 1, &iConfigs) || (iConfigs != 1))
+ {
+ LOG_DEBUG("GLESGraphicsystem", "Error: eglChooseConfig() failed.");
+ return false;
+ }
+ EGLint id =0;
+ eglGetConfigAttrib(m_eglDisplay, m_eglConfig, EGL_CONFIG_ID, &id);
+
+ LOG_DEBUG("GLESGraphicsystem", "Config chosen:" << id);
+ LOG_DEBUG("GLESGraphicsystem", "Create Window surface");
+
+ m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, WIndowID, NULL);
+ if (!m_eglSurface){
+ LOG_DEBUG("GLESGraphicsystem", "create unsucessfull");
+ }else{
+ LOG_DEBUG("GLESGraphicsystem", "create successfull");
+ }
+ EGLint contextAttrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
+ m_eglContext = eglCreateContext(m_eglDisplay,
+ m_eglConfig,
+ NULL,
+ contextAttrs);
+ if (!m_eglContext)
+ {
+ LOG_ERROR("GLESGraphicsystem","EGL couldn't create context\n");
+ return false;
+ }
+ LOG_INFO("GLESGraphicsystem", "EGL make current ...");
+ // Make the context and surface current for rendering
+ EGLBoolean eglStatus = false;
+ eglStatus = eglMakeCurrent(m_eglDisplay,
+ m_eglSurface, m_eglSurface,
+ m_eglContext);
+ LOG_INFO("GLESGraphicsystem", "made current");
+
+
+ if (!initOpenGLES(WindowWidth,WindowHeight) )
+ {
+ return false;
+ }
+ return true;
+}
+
+void GLESGraphicsystem::clearBackground()
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+}
+void GLESGraphicsystem::swapBuffers()
+{
+ eglSwapBuffers(m_eglDisplay,m_eglSurface);
+}
+
+void GLESGraphicsystem::drawSurface(Layer* currentLayer,Surface* surface)
+{
+ ShaderProgram::CommonUniforms uniforms;
+ Shader* layerShader = currentLayer->getShader();
+ if (!layerShader)
+ {
+ // use default shader if no custom shader is assigned to this layer
+ layerShader = defaultShader;
+ }
+ Shader* shader = (surface)->getShader();
+ if (!shader)
+ {
+ // use layer shader if no custom shader is assigned to this surface
+ shader = layerShader;
+ }
+ Rectangle dest = (surface)->getDestinationRegion();
+ Rectangle src = (surface)->getSourceRegion();
+ float surfaceXOfScreen = (float) dest.x / m_displayWidth;
+ float surfaceYOfScreen = (float) dest.y / m_displayHeight;
+ float surfaceWidthOfScreen = (float) dest.width / m_displayWidth;
+ float surfaceHeightOfScreen = (float) dest.height / m_displayHeight;
+
+ float sourceViewportWidthPercent = (float)src.width/(surface)->OriginalSourceWidth;
+ float sourceViewportHeightpercent = (float)src.height/(surface)->OriginalSourceHeight;
+ float sourceViewportXPercent = (float)src.x/(surface)->OriginalSourceWidth;
+ float sourceViewportYPercent = (float)src.y/(surface)->OriginalSourceHeight;
+
+ // LOG_INFO("GLESGraphicsystem", "Binding Buffer");
+ glBindBuffer(GL_ARRAY_BUFFER,m_vbo);
+
+ // LOG_INFO("GLESGraphicsystem", "Binding Buffer done");
+ shader->use();
+
+ // LOG_INFO("GLESGraphicsystem", "Update Uniforms");
+ // update all common uniforms
+ uniforms.x = surfaceXOfScreen;
+ uniforms.y = surfaceYOfScreen;
+ uniforms.width = surfaceWidthOfScreen;
+ uniforms.height = surfaceHeightOfScreen;
+ uniforms.opacity = (surface)->getOpacity() * currentLayer->getOpacity();
+ uniforms.texRange[0] = sourceViewportWidthPercent;
+ uniforms.texRange[1] = sourceViewportHeightpercent;
+ uniforms.texOffset[0] = sourceViewportXPercent;
+ uniforms.texOffset[1] = -sourceViewportYPercent;
+ uniforms.texUnit = 0;
+
+ // LOG_INFO("GLESGraphicsystem", "Load Common Uniforms");
+ shader->loadCommonUniforms(uniforms);
+
+ // LOG_INFO("GLESGraphicsystem", "Load Custom Uniforms");
+ // update all custom defined uniforms
+ shader->loadUniforms();
+ /* Bind texture and set section */
+ glActiveTexture(GL_TEXTURE0);
+ m_binder->bindSurfaceTexture(surface);
+
+ // rotated positions are saved sequentially in vbo
+ // offset in multiples of 12 decide rotation
+ int orientation = (surface)->getOrientation() + (currentLayer)->getOrientation();
+ orientation %= 4;
+ int index = orientation * 12;
+// LOG_INFO("GLESGraphicsystem", "Drawing surface");
+ // Draw two triangles
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+ // get the next surface
+ glBindBuffer(GL_ARRAY_BUFFER,NULL);
+// LOG_INFO("GLESGraphicsystem", "Drawing surface done");
+// LOG_INFO("GLESGraphicsystem", "Drawing surface done now checking for error");
+ GLenum status = glGetError();
+}
+
+bool GLESGraphicsystem::initOpenGLES(EGLint displayWidth,EGLint displayHeight)
+{
+ LOG_DEBUG("GLESGraphicsystem", "initEGL");
+ bool result = true;
+ ShaderProgramFactory::setCreatorFunc(m_shaderCreatorFunc);
+ defaultShader = Shader::createShader("default", "default");
+ if (!defaultShader)
+ {
+ LOG_ERROR("GLESGraphicsystem", "Failed to create and link default shader program");
+ delete defaultShader;
+ result = false;
+ }
+ else
+ {
+ LOG_INFO("GLESGraphicsystem", "Default Shader successfully applied");
+ glGenBuffers(1,&m_vbo);
+ glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
+ glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)(sizeof(float) *12));
+ glEnableVertexAttribArray(1);
+
+ glEnable (GL_BLEND);
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ m_blendingStatus = true;
+ glClearColor(1.0, 0.0, 0.0, 1.0);
+ resize(displayWidth,displayHeight);
+ }
+ return result;
+}
+void GLESGraphicsystem::resize(EGLint displayWidth,EGLint displayHeight)
+{
+ m_displayWidth = displayWidth;
+ m_displayHeight = displayHeight;
+ glViewport(0, 0, m_displayWidth, m_displayHeight);
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "TextureBinders/X11Copy.h"
+#include "Surface.h"
+#include "X11/Xlib.h"
+#include "Log.h"
+
+X11Copy::X11Copy(Display* display) : dpy(display) {};
+
+PlatformSurface* X11Copy::createPlatformSurface(Surface*s){
+LOG_DEBUG("X11Copy", "give back new platformsurface");
+ return new XPlatformSurface(s);
+}
+
+void X11Copy::unbindSurfaceTexture(Surface*s){}
+
+void X11Copy::destroyClientBuffer(Surface*s){}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "TextureBinders/X11CopyGLES.h"
+#include "Surface.h"
+#include "X11/Xlib.h"
+#include "Log.h"
+
+#include "GLES2/gl2.h"
+
+void X11CopyGLES::bindSurfaceTexture(Surface* surface){
+ XPlatformSurface* nativeSurface = (XPlatformSurface*)surface->platform;
+ Pixmap p = 0;
+ p= XCompositeNameWindowPixmap (dpy, surface->nativeHandle);
+ if (p==0)
+ LOG_ERROR("X11CopyGLES", "didnt create pixmap!");
+ nativeSurface->pixmap = p;
+ XImage * xim = XGetImage(dpy, nativeSurface->pixmap, 0, 0, surface->OriginalSourceWidth, surface->OriginalSourceHeight, AllPlanes, ZPixmap);
+ glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->OriginalSourceWidth,surface->OriginalSourceHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, xim->data);
+ XDestroyImage(xim);
+}
+
+void X11CopyGLES::createClientBuffer(Surface*s){
+ XPlatformSurface* nativeSurface = (XPlatformSurface*)s->platform;
+ glGenTextures(1,&nativeSurface->texture);
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "TextureBinders/X11EglImage.h"
+#include "X11/extensions/Xcomposite.h"
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES2/gl2ext.h>
+#include "PlatformSurfaces/EglXPlatformSurface.h"
+#include "Log.h"
+
+ X11EglImage::X11EglImage(Display* x11display) : m_x11display(x11display){
+ LOG_INFO("X11EglImage", "Query EGL Extensions ...");
+
+ m_pfGLEglImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)
+ eglGetProcAddress("glEGLImageTargetTexture2DOES");
+ m_pfEglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)
+ eglGetProcAddress("eglCreateImageKHR");
+ m_pfEglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)
+ eglGetProcAddress("eglDestroyImageKHR");
+
+ if (!m_pfEglCreateImageKHR || !m_pfEglDestroyImageKHR || !m_pfGLEglImageTargetTexture2DOES)
+ {
+ LOG_ERROR("X11EglImage", "Query EGL Extensions failed");
+ }
+
+ m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)m_x11display);
+ }
+ void X11EglImage::bindSurfaceTexture(Surface*s){
+ EglXPlatformSurface* nativeSurface = (EglXPlatformSurface*)s->platform;
+ glBindTexture(GL_TEXTURE_2D, nativeSurface->texture);
+ if (nativeSurface->eglImage != NULL){
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ m_pfGLEglImageTargetTexture2DOES(GL_TEXTURE_2D, nativeSurface->eglImage);
+ }
+ }
+
+ void X11EglImage::unbindSurfaceTexture(Surface*s){
+
+ }
+
+ void X11EglImage::createClientBuffer(Surface* surface){
+ LOG_DEBUG("X11EglImage", "creating client buffer");
+ EglXPlatformSurface* nativeSurface = (EglXPlatformSurface*)surface->platform;
+ Pixmap windowPixmap = 0;
+ windowPixmap= XCompositeNameWindowPixmap (m_x11display, surface->nativeHandle);
+ if (windowPixmap==0)
+ LOG_ERROR("X11EglImage", "didnt create pixmap!");
+
+ EGLImageKHR eglImage = 0;
+ LOG_DEBUG("X11EglImage", "creating EGL Image from client buffer");
+ if (nativeSurface->eglImage != NULL)
+ {
+ m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
+ glDeleteTextures(1,&nativeSurface->texture);
+ }
+ eglImage = m_pfEglCreateImageKHR(m_eglDisplay,
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ (EGLClientBuffer)windowPixmap,
+ NULL);
+ if (eglImage == 0)
+ {
+ LOG_DEBUG("X11EglImage", "could not allocate EGL Image for window");
+ } else {
+ nativeSurface->eglImage = eglImage;
+ glGenTextures(1,&nativeSurface->texture);
+ }
+ }
+
+ PlatformSurface* X11EglImage::createPlatformSurface(Surface* s){
+ return new EglXPlatformSurface(s);
+ }
+
+ void X11EglImage::destroyClientBuffer(Surface* surface){
+ EglXPlatformSurface* nativeSurface = (EglXPlatformSurface*)surface->platform;
+ if (nativeSurface->eglImage != NULL )
+ {
+ m_pfEglDestroyImageKHR(m_eglDisplay, nativeSurface->eglImage);
+ }
+ glDeleteTextures(1,&nativeSurface->texture);
+ }
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "WindowSystems/NullWindowSystem.h"
+#include "Log.h"
+#include "Layer.h"
+#include <time.h>
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <iomanip>
+
+
+int NullWindowSystem::windowWidth= 1280;
+
+
+int NullWindowSystem::windowHeight= 480;
+
+
+int NullWindowSystem::resolutionWidth= 1280;
+
+
+int NullWindowSystem::resolutionHeight= 480;
+
+
+bool NullWindowSystem::m_initialized= false;
+
+
+bool NullWindowSystem::m_success= false;
+
+
+bool NullWindowSystem::debugMode= false;
+
+
+void NullWindowSystem::printDebug(int posx,int posy){
+ // print stuff about layerlist
+ std::stringstream debugmessage;
+ debugmessage << "Layer: ID | X | Y | W | H | Al. \n";
+ // loop the layers
+ std::list<Layer*> list = layerlist->getCurrentRenderOrder();
+ for(std::list<Layer*>::const_iterator currentLayer = list.begin();
+ currentLayer != list.end(); currentLayer++)
+ {
+ Rectangle dest = (*currentLayer)->getDestinationRegion();
+ debugmessage << " " << std::setw(4) << (*currentLayer)->getID() << " " << std::setw(3) << dest.x << " " << std::setw(3) << dest.y << " " << std::setw(3) << dest.width << " " << std::setw(3) << dest.height << " " << std::setw(3) << (*currentLayer)->opacity << "\n";
+
+ debugmessage << " Surface: ID |Al.| SVP: X | Y | W | H DVP: X | Y | W | H \n";
+ // loop the surfaces of within each layer
+ for(std::list<Surface*>::iterator current = (*currentLayer)->surfaces.begin();
+ current != (*currentLayer)->surfaces.end(); current++)
+ {
+ Rectangle src = (*current)->getSourceRegion();
+ Rectangle dest = (*current)->getDestinationRegion();
+ debugmessage << " " << std::setw(4) << (*current)->getID() << " " << std::setprecision(3) << (*current)->opacity<< " " << std::setw(3) << src.x << " " << std::setw(3) << src.y << " " << std::setw(3) << src.width << " " << std::setw(3) << src.height << " " << std::setw(3) << dest.x << " " << std::setw(3) << dest.y << " " << std::setw(3) << dest.width << " " << std::setw(3) << dest.height << "\n";
+ }
+ }
+ LOG_INFO("NullWindowSystem",debugmessage.str());
+}
+
+float TimeCounter, LastFrameTimeCounter, DT, prevTime = 0.0, FPS;
+struct timeval tv, tv0;
+int Frame = 1, FramesPerFPS;
+
+void UpdateTimeCounter() {
+ LastFrameTimeCounter = TimeCounter;
+ gettimeofday(&tv, NULL);
+ TimeCounter = (float)(tv.tv_sec-tv0.tv_sec) + 0.000001*((float)(tv.tv_usec-tv0.tv_usec));
+ DT = TimeCounter - LastFrameTimeCounter; }
+
+void CalculateFPS() {
+ Frame ++;
+
+ if((Frame%FramesPerFPS) == 0) {
+ FPS = ((float)(FramesPerFPS)) / (TimeCounter-prevTime);
+ prevTime = TimeCounter; } }
+
+
+void NullWindowSystem::Redraw()
+{
+// LOG_INFO("NullWindowSystem","redraw");
+ // draw all the layers
+ graphicSystem->clearBackground();
+ std::list<Layer*> layers = layerlist->getCurrentRenderOrder();
+ for(std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++){
+ Layer* currentLayer = (Layer*)*current;
+ if ((*currentLayer).visibility && (*currentLayer).opacity>0.0f){
+ // glPushMatrix();
+ // glRotated(-90*currentLayer->getOrientation(),0,0,1.0);
+ // draw all the surfaces of the layer
+ std::list<Surface*> surfaces = currentLayer->surfaces;
+ for(std::list<Surface*>::const_iterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++){
+ if ((*currentS)->visibility && (*currentS)->opacity>0.0f){
+ Surface* currentSurface = (Surface*)*currentS;
+ PlatformSurface* nativeSurface = (PlatformSurface*)currentSurface->platform;
+ if (NULL==nativeSurface)
+ {
+ LOG_INFO("NullWindowSystem","creating native surface for new window");
+ // this surface does not have a native platform surface attached yet!
+ currentSurface->platform = graphicSystem->m_binder->createPlatformSurface(currentSurface);
+ currentSurface->OriginalSourceWidth=256;
+ currentSurface->OriginalSourceHeight=256;
+ graphicSystem->m_binder->createClientBuffer(currentSurface);
+ LOG_INFO("NullWindowSystem","created native surface for new window");
+ }
+ graphicSystem->drawSurface(currentLayer,currentSurface);
+
+ }
+ }
+ }
+ }
+
+ if (debugMode)
+ {
+ printDebug(200,windowHeight-40);
+ }
+ UpdateTimeCounter();
+ CalculateFPS();
+ char floatStringBuffer[256];
+ sprintf(floatStringBuffer, "FPS: %f", FPS);
+ if ((Frame % 1000 ) == 0)
+ {
+ LOG_INFO("NullWindowSystem",floatStringBuffer);
+ }
+
+ graphicSystem->swapBuffers();
+
+}
+
+
+
+void* NullWindowSystem::EventLoop(void * ptr)
+{
+ LOG_DEBUG("NullWindowSystem", "Enter thread");
+ NullWindowSystem *windowsys = (NullWindowSystem *) ptr;
+
+ // init own stuff
+ m_success = false;
+
+ // then init graphiclib
+ int display = 0;
+ void* window = NULL;
+ m_success = windowsys->graphicSystem->init(&display,&window,windowHeight,windowWidth);
+
+ m_initialized = true;
+ // start
+// // get instance of Renderer for this thread
+ Layer* defaultLayer;
+// X11WindowSystem *renderer = (X11WindowSystem *) ptr;
+// if (renderer != NULL)
+// {
+// }
+// // initialize the renderer (OpenGL etc)
+// renderer->init();
+// // run the main event loop while rendering
+ bool running = windowsys->m_success;
+ gettimeofday(&tv0, NULL);
+ FramesPerFPS = 30;
+ if (debugMode)
+ {
+ defaultLayer = windowsys->layerlist->createLayer();
+ defaultLayer->setOpacity(1.0);
+ defaultLayer->setDestinationRegion(Rectangle(0,0,windowsys->resolutionWidth,windowsys->resolutionHeight));
+ defaultLayer->setSourceRegion(Rectangle(0,0,windowsys->resolutionWidth,windowsys->resolutionHeight));
+ windowsys->layerlist->getCurrentRenderOrder().push_back(defaultLayer);
+ }
+ LOG_DEBUG("NullWindowSystem", "Enter render loop");
+ while (running)
+ {
+ windowsys->Redraw();
+ }
+ LOG_INFO("NullWindowSystem", "Renderer thread finished");
+ return NULL;
+}
+
+
+bool NullWindowSystem::start(int displayWidth, int displayHeight, const char* DisplayName){
+ LOG_INFO("NullWindowSystem", "Starting / Creating thread");
+ pthread_t renderThread;
+ NullWindowSystem *renderer = this;
+ resolutionWidth = displayWidth;
+ resolutionHeight = displayHeight;
+ int status = pthread_create( &renderThread, NULL, NullWindowSystem::EventLoop, (void*) renderer);
+ if (0 != status )
+ {
+ return false;
+ }
+ while ( m_initialized == false )
+ {
+ sleep(1);
+ LOG_INFO("NullWindowSystem","Waiting start complete " << m_initialized);
+ }
+ LOG_INFO("NullWindowSystem","Start complete " << m_initialized << " success " << m_success);
+ return m_success;
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "WindowSystems/X11WindowSystem.h"
+#include "Log.h"
+#include "Layer.h"
+#include <time.h>
+#include <sys/time.h>
+#include <X11/extensions/Xcomposite.h>
+#include <X11/extensions/xf86vmode.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <iomanip>
+
+int X11WindowSystem::composite_opcode;
+const char X11WindowSystem::CompositorWindowTitle[] = "LayerManager";
+bool X11WindowSystem::m_success = false;
+bool X11WindowSystem::m_initialized = false;
+
+X11WindowSystem::X11WindowSystem(LayerList* layerlist, BaseGraphicSystem* graphicSystem,GetVisualInfoFunction func) : BaseWindowSystem(layerlist, graphicSystem), getVisualFunc(func), windowWidth(1280), windowHeight(480),resolutionWidth(1280),resolutionHeight(480),debugMode(false){
+ LOG_DEBUG("X11WindowSystem", "creating X11WindowSystem");
+
+ };
+
+XVisualInfo* X11WindowSystem::getDefaultVisual(Display *dpy)
+ {
+ XVisualInfo* windowVis = new XVisualInfo();
+ windowVis->depth = DefaultDepth(dpy, 0);;
+ XMatchVisualInfo( dpy, 0, windowVis->depth, TrueColor, windowVis);
+ if (!windowVis)
+ {
+ LOG_ERROR("X11WindowSystem", "Error: Unable to acquire visual\n");
+ }
+ return windowVis;
+ };
+
+void X11WindowSystem::OpenDisplayConnection(){
+ x11Display = XOpenDisplay(NULL);
+ if (!x11Display)
+ {
+ LOG_ERROR("X11WindowSystem", "Couldn't open default display!");
+ }
+}
+
+void X11WindowSystem::checkForCompositeExtension(){
+ if (!XQueryExtension (x11Display, COMPOSITE_NAME, &composite_opcode,
+ &composite_event, &composite_error))
+ {
+ LOG_ERROR("X11WindowSystem", "No composite extension");
+ }
+ XCompositeQueryVersion (x11Display, &composite_major, &composite_minor);
+ LOG_DEBUG("X11WindowSystem", "Found composite extension: composite opcode: " << composite_opcode);
+ LOG_DEBUG("X11WindowSystem", "composite_major: " << composite_major);
+ LOG_DEBUG("X11WindowSystem", "composite_minor: " << composite_minor);
+}
+
+void X11WindowSystem::printDebug(int posx,int posy){
+ // print stuff about layerlist
+ std::stringstream debugmessage;
+ debugmessage << "Layer: ID | X | Y | W | H | Al. \n";
+ // loop the layers
+ std::list<Layer*> list = layerlist->getCurrentRenderOrder();
+ for(std::list<Layer*>::const_iterator currentLayer = list.begin();
+ currentLayer != list.end(); currentLayer++)
+ {
+ Rectangle dest = (*currentLayer)->getDestinationRegion();
+ debugmessage << " " << std::setw(4) << (*currentLayer)->getID() << " " << std::setw(3) << dest.x << " " << std::setw(3) << dest.y << " " << std::setw(3) << dest.width << " " << std::setw(3) << dest.height << " " << std::setw(3) << (*currentLayer)->opacity << "\n";
+
+ debugmessage << " Surface: ID |Al.| SVP: X | Y | W | H DVP: X | Y | W | H \n";
+ // loop the surfaces of within each layer
+ for(std::list<Surface*>::iterator current = (*currentLayer)->surfaces.begin();
+ current != (*currentLayer)->surfaces.end(); current++)
+ {
+ Rectangle src = (*current)->getSourceRegion();
+ Rectangle dest = (*current)->getDestinationRegion();
+ debugmessage << " " << std::setw(4) << (*current)->getID() << " " << std::setprecision(3) << (*current)->opacity<< " " << std::setw(3) << src.x << " " << std::setw(3) << src.y << " " << std::setw(3) << src.width << " " << std::setw(3) << src.height << " " << std::setw(3) << dest.x << " " << std::setw(3) << dest.y << " " << std::setw(3) << dest.width << " " << std::setw(3) << dest.height << "\n";
+ }
+ }
+ LOG_INFO("X11WindowSystem",debugmessage.str());
+}
+
+Window * getListOfAllTopLevelWindows (Display *disp, unsigned int *len) {
+ LOG_DEBUG("X11WindowSystem", "Getting list of all windows");
+ Window *children;
+ Window root_return, parent_return;
+ Window root = XDefaultRootWindow(disp);
+ XQueryTree (disp, root, &root_return, &parent_return, &children, len);
+ return children;
+}
+
+bool X11WindowSystem::isWindowValid(Window w){
+ // skip our own two windows
+ if (w != CompositorWindow)
+ return true;
+ else
+ return false;
+}
+
+Surface* X11WindowSystem::getSurfaceForWindow(Window w){
+ LOG_DEBUG("X11WindowSystem", "finding surface for window " << w);
+ // go though all surfaces
+ const std::map<int,Surface*> surfaces = layerlist->getAllSurfaces();
+ for(std::map<int, Surface*>::const_iterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++){
+ Surface* currentSurface = (*currentS).second;
+ XPlatformSurface* x11surf = NULL;
+ if (NULL != currentSurface->platform){
+ x11surf = (XPlatformSurface*)currentSurface->platform;
+ if (currentSurface->nativeHandle == w){
+ LOG_DEBUG("X11WindowSystem", "surface " << currentSurface->getID() << " corresponds to window" << w);
+ return currentSurface;
+ }
+ }
+ }
+ LOG_DEBUG("X11WindowSystem", "could not find surface for window " << w);
+ return NULL;
+}
+
+
+void X11WindowSystem::configureSurfaceWindow(Window w){
+ int status = 0;
+ if (isWindowValid(w)){
+ LOG_DEBUG("X11WindowSystem", "Updating window " << w);
+ UnMapWindow(w);
+ MapWindow(w);
+ LOG_INFO("X11WindowSystem","after map 1");
+ XWindowAttributes att;
+ status = XGetWindowAttributes (x11Display, w, &att);
+ int winWidth = att.width;
+ int winHeight = att.height;
+
+ Surface*s = getSurfaceForWindow(w);
+ if (s==NULL){
+ LOG_ERROR("X11WindowSystem", "surface emtpy");
+ return;
+ }
+ if (s->platform==NULL){
+ LOG_ERROR("X11WindowSystem", "platform surface empty");
+ return;
+ }
+
+ LOG_DEBUG("X11WindowSystem", "Updating surface " << s->getID());
+
+ s->OriginalSourceHeight =winHeight;
+ s->OriginalSourceWidth = winWidth;
+ s->setDestinationRegion(Rectangle(0,0,winWidth,winHeight));
+ s->setSourceRegion(Rectangle(0,0,winWidth,winHeight));
+
+ LOG_DEBUG("X11WindowSystem", "Done Updating window " << w);
+ }
+}
+
+void X11WindowSystem::MapWindow(Window window){
+ int status = 0;
+ if (isWindowValid(window))
+ {
+ XWindowAttributes att;
+ status = XGetWindowAttributes (x11Display, window, &att);
+ if (att.map_state == IsViewable && att.override_redirect==0){
+ LOG_DEBUG("X11WindowSystem", "Mapping window " << window);
+ Surface* surface = getSurfaceForWindow(window);
+ if (surface==NULL){
+ LOG_ERROR("X11WindowSystem", "surface emtpy");
+ return;
+ }
+ if (surface->platform==NULL){
+ LOG_ERROR("X11WindowSystem", "platform surface empty");
+ return;
+ }
+
+ XPlatformSurface* x11surf = (XPlatformSurface*)surface->platform;
+ if (x11surf->isMapped){
+ LOG_ERROR("X11WindowSystem", "already mapped!");
+ return;
+ }
+ x11surf->isMapped = true;
+
+
+ LOG_DEBUG("X11WindowSystem", "getting pixmap for window");
+ LOG_DEBUG("X11WindowSystem", "window width: " << att.width);
+ LOG_DEBUG("X11WindowSystem", "window height: " << att.height);
+ LOG_DEBUG("X11WindowSystem", "map state: " << att.map_state);
+ LOG_DEBUG("X11WindowSystem", "window x: " << att.x);
+ LOG_DEBUG("X11WindowSystem", "window backing: " << att.backing_pixel);
+ LOG_DEBUG("X11WindowSystem", "window save under: " << att.save_under);
+ LOG_DEBUG("X11WindowSystem", "window orride: " << att.override_redirect);
+ LOG_DEBUG("X11WindowSystem", "parent/root: " << att.root);
+ LOG_DEBUG("X11WindowSystem", "root window: " << DefaultRootWindow(x11Display));
+
+ int winWidth = att.width;
+ int winHeight = att.height;
+
+ surface->OriginalSourceHeight = winHeight;
+ surface->OriginalSourceWidth = winWidth;
+ surface->setDestinationRegion(Rectangle(0,0,winWidth,winHeight));
+ surface->setSourceRegion(Rectangle(0,0,winWidth,winHeight));
+
+ graphicSystem->m_binder->createClientBuffer(surface);
+ XSync(x11Display, 0);
+
+ surface->visibility = true;
+ surface->setOpacity(1.0);
+ LOG_DEBUG("X11WindowSystem", "Mapping Surface " << surface->getID());
+ LOG_DEBUG("X11WindowSystem", "Done mapping");
+ }
+ }
+ LOG_INFO("EglXCompositeRenderer","mapping end");
+}
+
+void X11WindowSystem::UnMapWindow(Window window){
+ if (isWindowValid(window)){
+ LOG_DEBUG("X11WindowSystem", "Unmapping window " << window);
+ Surface* surface = getSurfaceForWindow(window);
+ if (surface==NULL){
+ LOG_ERROR("X11WindowSystem", "surface emtpy");
+ return;
+ }
+ // set invisible first, so it wont be used for rendering anymore
+ surface->visibility = false;
+ if (surface->platform==NULL){
+ LOG_ERROR("X11WindowSystem", "platform surface empty");
+ return;
+ }
+ XPlatformSurface* x11surf = (XPlatformSurface*)surface->platform;
+ LOG_DEBUG("X11WindowSystem", "Unmapping surface " << surface->getID());
+ x11surf->isMapped = false;
+
+
+ LOG_DEBUG("X11WindowSystem", "Destroying ClientBuffer");
+ graphicSystem->m_binder->destroyClientBuffer(surface);
+ XSync(x11Display, 0);
+
+ LOG_DEBUG("X11WindowSystem", "Removing X Pixmap");
+
+ XSync(x11Display, 0);
+ }
+ LOG_DEBUG("X11WindowSystem", "Unmap finished");
+}
+
+void X11WindowSystem::NewWindow(Surface* surface, Window window)
+{
+ if (isWindowValid(window)){
+ LOG_DEBUG("X11WindowSystem", "Creating Surface for new window " << window);
+ // get the windows attributes
+ XWindowAttributes att;
+ int status = XGetWindowAttributes (x11Display, window, &att);
+ LOG_DEBUG("X11WindowSystem", "Got window attrbutes");
+ char* name;
+ status = XFetchName(x11Display, window, &name);
+ LOG_DEBUG("X11WindowSystem", "Got window name");
+ if (status >= Success)
+ {
+ LOG_DEBUG("X11WindowSystem", "Found window: " << window << " " << name);
+ char GuiTitle[] = "Layermanager Remote GUI\0";
+ if (name != NULL && strcmp(name,GuiTitle)==0){
+ LOG_DEBUG("X11WindowSystem", "Found gui window: repositioning it");
+ XCompositeUnredirectWindow(x11Display,window,CompositeRedirectManual);
+//XLowerWindow(x11Display,window);
+ XMoveWindow(x11Display, window, 50, 500);
+ XMapRaised(x11Display, window);
+ }
+ }else {
+ LOG_DEBUG("X11WindowSystem", "Error fetching window name");
+ }
+ XFree(name);
+XLowerWindow(x11Display,window);
+//XMoveWindow(x11Display,window,-1000,-1000);
+ // Surface* s = layerlist->createSurface();
+
+ surface->nativeHandle = window;
+ XPlatformSurface * platformSurface = (XPlatformSurface*)graphicSystem->m_binder->createPlatformSurface(surface);
+ platformSurface->isMapped = false;
+
+ LOG_DEBUG("X11WindowSystem", "Created native Surface for X11 Window id " << window);
+
+ surface->nativeHandle = window;
+ surface->platform = platformSurface;
+ surface->visibility = false;
+
+ int winWidth = att.width;
+ int winHeight = att.height;
+
+ surface->OriginalSourceHeight =winHeight;
+ surface->OriginalSourceWidth = winWidth;
+ surface->setDestinationRegion(Rectangle(0,0,winWidth,winHeight));
+ surface->setSourceRegion(Rectangle(0,0,winWidth,winHeight));
+ LOG_DEBUG("X11WindowSystem", "orig width " << surface->OriginalSourceWidth);
+ LOG_DEBUG("X11WindowSystem", "orig heigth " << surface->OriginalSourceHeight);
+ }else{
+ LOG_DEBUG("X11WindowSystem", "skipping window");
+ }
+ LOG_DEBUG("X11WindowSystem", "created the new surface");
+}
+
+void X11WindowSystem::DestroyWindow(Window window){
+ if (isWindowValid(window)){
+ LOG_DEBUG("X11WindowSystem", "Destroying Surface for window " << window);
+ Surface* surface = getSurfaceForWindow(window);
+ if (surface==NULL){
+ LOG_ERROR("X11WindowSystem", "surface empty");
+ return;
+ }
+ graphicSystem->m_binder->destroyClientBuffer(surface);
+ UnMapWindow(window);
+ layerlist->removeSurface(surface);
+ LOG_DEBUG("X11WindowSystem", "Removed Surface " << surface->getID());
+ }
+}
+
+bool
+X11WindowSystem::CreatePixmapsForAllWindows()
+{
+ bool result = true;
+ LOG_DEBUG("X11WindowSystem", "redirecting all windows");
+ Window root = RootWindow(x11Display, 0);
+ XGrabServer (x11Display);
+ unsigned int numberOfWindows = 0;
+ Window *children = getListOfAllTopLevelWindows(x11Display,&numberOfWindows);
+
+ LOG_DEBUG("X11WindowSystem", "Found " << numberOfWindows << " windows");
+ XCompositeRedirectSubwindows(x11Display,root,CompositeRedirectManual);
+
+/* for (unsigned int i=0;i< (numberOfWindows-1);i++)
+ {
+ Window w = (Window) children[i];
+ NewWindow(w);
+ MapWindow(w);
+ } */
+ XFree(children);
+ XUngrabServer (x11Display);
+ XSync(x11Display, 0);
+
+ return result;
+}
+
+
+
+
+bool X11WindowSystem::CreateCompositorWindow()
+{
+ LOG_DEBUG("X11WindowSystem", "Get root window");
+ bool result = true;
+ Window root = XDefaultRootWindow(x11Display);
+
+ LOG_DEBUG("X11WindowSystem", "Get default screen");
+ // draw a black background the full size of the resolution
+ long x11Screen = XDefaultScreen( x11Display );
+
+ LOG_DEBUG("X11WindowSystem", "Creating Compositor Window");
+ // create the actual content window
+// CompositorWindow = XCreateSimpleWindow( x11Display, root, 0, 0, windowWidth, windowHeight,
+// 0, BlackPixel(x11Display, x11Screen), WhitePixel(x11Display, x11Screen));
+ XSetWindowAttributes attr;
+ // draw a black background the full size of the resolution
+ attr.override_redirect = True;
+ attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask;
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ windowVis = getVisualFunc(x11Display);
+ attr.colormap = XCreateColormap(x11Display, root, windowVis->visual, AllocNone);
+
+ attr.override_redirect = True;
+
+ // Window overlaywindow = XCompositeGetOverlayWindow(x11Display,root);
+
+ CompositorWindow = XCreateWindow(x11Display, root, 0, 0, windowWidth, windowHeight,
+ 0, windowVis->depth, InputOutput,
+ windowVis->visual, CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &attr);
+
+
+ if (!CompositorWindow)
+ {
+ LOG_ERROR("X11WindowSystem", "Could not create window");
+ return false;
+ }
+ LOG_DEBUG("X11WindowSystem", "Created the Compositor Window");
+ XSelectInput (x11Display, root,
+ SubstructureNotifyMask|
+ ExposureMask|
+ StructureNotifyMask|
+ PropertyChangeMask);
+
+ LOG_DEBUG("X11WindowSystem", "Created the window");
+ XSizeHints sizehints;
+ sizehints.width = windowWidth;
+ sizehints.height = windowHeight;
+ sizehints.flags = USSize;
+ XSetNormalHints(x11Display, CompositorWindow, &sizehints);
+ XSetStandardProperties(x11Display, CompositorWindow, CompositorWindowTitle, CompositorWindowTitle,
+ None, (char **)NULL, 0, &sizehints);
+ XMapRaised(x11Display, CompositorWindow);
+ return result;
+}
+
+float TimeCounter, LastFrameTimeCounter, DT, prevTime = 0.0, FPS;
+struct timeval tv, tv0;
+int Frame = 1, FramesPerFPS;
+
+void UpdateTimeCounter() {
+ LastFrameTimeCounter = TimeCounter;
+ gettimeofday(&tv, NULL);
+ TimeCounter = (float)(tv.tv_sec-tv0.tv_sec) + 0.000001*((float)(tv.tv_usec-tv0.tv_usec));
+ DT = TimeCounter - LastFrameTimeCounter; }
+
+void CalculateFPS() {
+ Frame ++;
+
+ if((Frame%FramesPerFPS) == 0) {
+ FPS = ((float)(FramesPerFPS)) / (TimeCounter-prevTime);
+ prevTime = TimeCounter; } }
+
+void
+X11WindowSystem::Redraw()
+{
+ // draw all the layers
+ graphicSystem->clearBackground();
+ std::list<Layer*> layers = layerlist->getCurrentRenderOrder();
+ for(std::list<Layer*>::const_iterator current = layers.begin(); current != layers.end(); current++){
+ Layer* currentLayer = (Layer*)*current;
+ if ((*currentLayer).visibility && (*currentLayer).opacity>0.0f){
+ // glRotated(-90*currentLayer->getOrientation(),0,0,1.0);
+ // draw all the surfaces of the layer
+ std::list<Surface*> surfaces = currentLayer->surfaces;
+ for(std::list<Surface*>::const_iterator currentS = surfaces.begin(); currentS != surfaces.end(); currentS++){
+ if ((*currentS)->visibility && (*currentS)->opacity>0.0f){
+ Surface* currentSurface = (Surface*)*currentS;
+ XPlatformSurface* nativeSurface = (XPlatformSurface*)currentSurface->platform;
+ if (NULL==nativeSurface)
+ {
+ LOG_INFO("X11WindowSystem","creating native surface for new window");
+ // this surface does not have a native platform surface attached yet!
+ NewWindow(currentSurface,currentSurface->nativeHandle);
+ MapWindow(currentSurface->nativeHandle);
+ }
+ graphicSystem->drawSurface(currentLayer,currentSurface);
+
+ }
+ }
+ }
+ }
+
+ if (debugMode)
+ {
+ printDebug(200,windowHeight-40);
+ }
+ UpdateTimeCounter();
+ CalculateFPS();
+ char floatStringBuffer[256];
+ sprintf(floatStringBuffer, "FPS: %f", FPS);
+ if ((Frame % 1000 ) == 0)
+ {
+ LOG_INFO("X11WindowSystem",floatStringBuffer);
+ }
+ graphicSystem->swapBuffers();
+}
+
+int
+X11WindowSystem::error (Display *dpy, XErrorEvent *ev)
+{
+ const char *name = NULL;
+ static char buffer[256];
+
+ if (ev->request_code == composite_opcode &&
+ ev->minor_code == X_CompositeRedirectWindow)
+ {
+ LOG_ERROR("X11WindowSystem", "Another composite manager is already running!");
+ }
+
+ if (name == NULL)
+ {
+ buffer[0] = '\0';
+ XGetErrorText (dpy, ev->error_code, buffer, sizeof (buffer));
+ name = buffer;
+ }
+ name = (strlen (name) > 0) ? name : "unknown";
+ LOG_ERROR("X11WindowSystem", "X Error: " << (int)ev->error_code << " " << name << " request : " << (int)ev->request_code << " minor: " << (int)ev->minor_code << " serial: " << (int)ev->serial);
+ return 0;
+}
+
+//void X11WindowSystem::setDisplayMode(){
+// XF86VidModeModeInfo **modes;
+// int modeNum;
+// int bestMode = -1;
+// LOG_DEBUG("X11WindowSystem", "trying for fullscreen mode " << resolutionWidth << " " << resolutionHeight);
+// XF86VidModeGetAllModeLines(x11Display, 0, &modeNum, &modes);
+// LOG_DEBUG("X11WindowSystem", "found " << modeNum << " modes");
+// /* look for mode with requested resolution */
+// for (int i = 0; i < modeNum; i++)
+// if ((modes[i]->hdisplay == resolutionWidth) && (modes[i]->vdisplay == resolutionHeight))
+// bestMode = i;
+// if (bestMode==-1){
+// int bestHeight = 0;
+// for (int i = 0; i < modeNum; i++)
+// if (modes[i]->hdisplay == resolutionWidth && modes[i]->vdisplay >= bestHeight){
+// bestMode = i;
+// bestHeight = modes[i]->vdisplay;
+// }
+// }
+// if (bestMode>=0){
+// LOG_DEBUG("X11WindowSystem", "changing mode to "<< modes[bestMode]->hdisplay << " " << modes[bestMode]->vdisplay );
+// XF86VidModeSwitchToMode(x11Display, 0, modes[bestMode]);
+// XF86VidModeSetViewPort(x11Display, 0, 0, 0);
+//
+// }else{
+// LOG_ERROR("X11WindowSystem", "could not find appropriate mode!");
+// // take last mode, its probably the highest resolution
+// resolutionWidth = modes[modeNum-1]->hdisplay;
+// resolutionHeight = modes[modeNum-1]->vdisplay;
+// windowWidth = resolutionWidth;
+// if (windowHeight>resolutionHeight)
+// windowHeight = resolutionHeight;
+// XF86VidModeSwitchToMode(x11Display, 0, modes[modeNum-1]);
+// XF86VidModeSetViewPort(x11Display, 0, 0, 0);
+// }
+// LOG_DEBUG("X11WindowSystem", "Set the mode");
+// LOG_DEBUG("X11WindowSystem", "mode: " << resolutionWidth << "x" << resolutionHeight);
+// LOG_DEBUG("X11WindowSystem", "renderwindow: " << windowWidth << "x" << windowHeight);
+//}
+
+bool X11WindowSystem::initXServer()
+{
+ LOG_DEBUG("X11WindowSystem", "Initialising XServer connection");
+ bool result = true;
+
+ //setDisplayMode();
+ if ( !CreateCompositorWindow() )
+ {
+ LOG_ERROR("X11WindowSystem", "Compositor Window creation failed " );
+ return false;
+ }
+
+ LOG_DEBUG("X11WindowSystem", "Compositor Window ID: " << CompositorWindow);
+
+ // LOG_DEBUG("X11WindowSystem", "Allocate Pixmaps for all the offscreen windows");
+ CreatePixmapsForAllWindows();
+ // LOG_DEBUG("X11WindowSystem", "Allocated Pixmaps");
+
+ //unredirect our window
+#ifdef FULLSCREEN
+ XCompositeUnredirectWindow(x11Display,background,CompositeRedirectManual);
+#endif
+ XCompositeUnredirectWindow(x11Display,CompositorWindow,CompositeRedirectManual);
+
+ //unredirect special windows if present
+ XGrabServer (x11Display);
+ unsigned int numberOfWindows = 0;
+ Window *children = getListOfAllTopLevelWindows(x11Display,&numberOfWindows);
+ LOG_DEBUG("X11WindowSystem", "unredirecting special windows");
+ for (unsigned int i=0;i<numberOfWindows;i++){
+ Window w = (Window) children[i];
+ char* name;
+ int status = XFetchName(x11Display, w, &name);
+ if (status >= Success)
+ {
+ char GuiTitle[] = "Layermanager Remote GUI\0";
+ char DFEETTITLE[] = "D-Feet D-Bus debugger\0";
+ if (name != NULL && (strcmp(name,GuiTitle)==0 || strcmp(name,DFEETTITLE)==0 ) ){
+ LOG_DEBUG("X11WindowSystem", "Found gui window: repositioning it");
+ XCompositeUnredirectWindow(x11Display,w,CompositeRedirectManual);
+ XCompositeUnredirectSubwindows(x11Display,w,CompositeRedirectAutomatic);
+ XMoveWindow(x11Display, w, 50, 500);
+ XMapRaised(x11Display, w);
+ }
+ }
+ }
+ XFree(children);
+ XUngrabServer (x11Display);
+ XSync(x11Display, 0);
+
+ LOG_DEBUG("X11WindowSystem", "Initialised XServer connection");
+ return result;
+}
+
+void* X11WindowSystem::EventLoop(void * ptr)
+{
+ LOG_DEBUG("X11WindowSystem", "Enter thread");
+ X11WindowSystem *windowsys = (X11WindowSystem *) ptr;
+
+ // init own stuff
+ m_success = false;
+
+ windowsys->OpenDisplayConnection();
+ windowsys->checkForCompositeExtension();
+ windowsys->initXServer();
+
+ // then init graphiclib
+ m_success = windowsys->graphicSystem->init(&windowsys->x11Display,&windowsys->CompositorWindow,windowsys->windowHeight,windowsys->windowWidth);
+ m_initialized = true;
+
+ Layer* defaultLayer;
+
+ // run the main event loop while rendering
+ bool running = windowsys->m_success;
+ gettimeofday(&tv0, NULL);
+ FramesPerFPS = 30;
+ if (windowsys->debugMode)
+ {
+ defaultLayer = windowsys->layerlist->createLayer();
+ defaultLayer->setOpacity(1.0);
+ defaultLayer->setDestinationRegion(Rectangle(0,0,windowsys->resolutionWidth,windowsys->resolutionHeight));
+ defaultLayer->setSourceRegion(Rectangle(0,0,windowsys->resolutionWidth,windowsys->resolutionHeight));
+ windowsys->layerlist->getCurrentRenderOrder().push_back(defaultLayer);
+ }
+ LOG_DEBUG("X11WindowSystem", "Enter render loop");
+ while (running)
+ {
+ if ( XPending(windowsys->x11Display) > 0) {
+ XEvent event;
+ XNextEvent(windowsys->x11Display, &event);
+ switch (event.type) {
+ case CreateNotify:
+ {
+ if (windowsys->debugMode)
+ {
+ LOG_DEBUG("X11WindowSystem", "CreateNotify Event");
+ Surface* s = windowsys->layerlist->createSurface();
+ s->setOpacity(1.0);
+ windowsys->NewWindow(s, event.xcreatewindow.window);
+ defaultLayer->addSurface(s);
+ }
+ break;
+ }
+ case ConfigureNotify:
+ LOG_DEBUG("X11WindowSystem", "Configure notify Event");
+ windowsys->configureSurfaceWindow( event.xconfigure.window);
+ break;
+
+ case DestroyNotify:
+ LOG_DEBUG("X11WindowSystem", "Destroy Event");
+ windowsys->DestroyWindow(event.xdestroywindow.window);
+ break;
+ case Expose:
+ LOG_DEBUG("X11WindowSystem", "Expose Event");
+ windowsys->Redraw();
+ break;
+ case ButtonPress:
+ LOG_DEBUG("X11WindowSystem", "Button press Event");
+ //running = False;
+ break;
+ case MapNotify:
+ LOG_DEBUG("X11WindowSystem", "Map Event");
+ windowsys->MapWindow(event.xmap.window);
+ break;
+ case UnmapNotify:
+ LOG_DEBUG("X11WindowSystem", "Unmap Event");
+ windowsys->UnMapWindow(event.xunmap.window);
+ break;
+ case ReparentNotify:
+ LOG_DEBUG("X11WindowSystem", "Reparent Event");
+ // if (event.xreparent.parent == root)
+ // renderer->NewWindow(event.xreparent.window);
+ // else
+ // renderer->DestroyWindow(event.xreparent.window);
+ break;
+
+ default:
+ ; /*no-op*/
+ }
+ }
+ windowsys->Redraw();
+ }
+ LOG_INFO("X11WindowSystem", "Renderer thread finished");
+ return NULL;
+}
+
+
+bool X11WindowSystem::start(int displayWidth, int displayHeight, const char* DisplayName){
+ LOG_INFO("X11WindowSystem", "Starting / Creating thread");
+ pthread_t renderThread;
+ X11WindowSystem *renderer = this;
+ resolutionWidth = displayWidth;
+ resolutionHeight = displayHeight;
+ int status = pthread_create( &renderThread, NULL, X11WindowSystem::EventLoop, (void*) renderer);
+ if (0 != status )
+ {
+ return false;
+ }
+ while ( m_initialized == false )
+ {
+ sleep(1);
+ LOG_INFO("X11WindowSystem","Waiting start complete " << m_initialized);
+ }
+ LOG_INFO("X11WindowSystem","Start complete " << m_initialized << " success " << m_success);
+ return m_success;
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 BEAGLERENDERER_H_
+#define BEAGLERENDERER_H_
+
+#include "BaseRenderer.h"
+#include "TextureBinders/BeagleEglImage.h"
+#include "GraphicSystems/GLESGraphicSystem.h"
+#include "WindowSystems/NullWindowSystem.h"
+#include "ShaderProgramBeagle.h"
+
+class BeagleRenderer : public BaseRenderer
+{
+public:
+ BeagleRenderer(LayerList* layerlist) : BaseRenderer(layerlist)
+ {
+ LOG_DEBUG("BeagleRenderer", "Creating Renderer");
+ ITextureBinder* binder = new BeagleEglImage();
+ BaseGraphicSystem* graphicSystem = new GLESGraphicsystem( ShaderProgramBeagle::createProgram, binder);
+ m_windowSystem = new NullWindowSystem(layerlist, graphicSystem);
+ };
+};
+
+extern "C" BaseRenderer* createBeagleRenderer(LayerList* layerlist) {
+ return new BeagleRenderer(layerlist);
+}
+
+extern "C" void destroyBeagleRenderer(BeagleRenderer* p) {
+ delete p;
+}
+
+#endif /* BEAGLERENDERER_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 BEAGLESHADERPROGRAM_H_
+#define BEAGLESHADERPROGRAM_H_
+
+#include <ShaderProgram.h>
+#include <GLES2/gl2.h>
+
+
+/// pointer to shader program creator function
+typedef ShaderProgram* (*PfnShaderProgramCreator)(const std::string&, const std::string&);
+
+/**
+ * Factory for creating platform specific shader programs.
+ */
+class ShaderProgramBeagle : public ShaderProgram
+{
+public:
+ /**
+ * Create a new shader program.
+ *
+ * @param vertName File name of vertex shader.
+ * @param fragName File name of fragment shader.
+ * @return new Program instance, NULL if program could not be created.
+ */
+ static ShaderProgram* createProgram(const std::string& vertName, const std::string& fragName);
+
+ /**
+ * Destructor
+ */
+ virtual ~ShaderProgramBeagle(void);
+
+ /**
+ * Start using the shader program for rendering.
+ */
+ virtual void use(void) const;
+
+ virtual int getUniformLocation(const char* name) const
+ {
+ return glGetUniformLocation(_progHandle, name);
+ }
+
+ virtual void uniform1iv(int location, int count, const int* v) const
+ {
+ glUniform1iv(location, count, v);
+ }
+
+ virtual void uniform1fv(int location, int count, const float* v) const
+ {
+ glUniform1fv(location, count, v);
+ }
+
+ virtual void uniform2fv(int location, int count, const float* v) const
+ {
+ glUniform2fv(location, count, v);
+ }
+
+ virtual void uniform3fv(int location, int count, const float* v) const
+ {
+ glUniform3fv(location, count, v);
+ }
+
+ virtual void uniform4fv(int location, int count, const float* v) const
+ {
+ glUniform4fv(location, count, v);
+ }
+
+ virtual void uniformMatrix2fv(int location, int count, bool transpose, const float* v) const
+ {
+ glUniformMatrix2fv(location, count, transpose, v);
+ }
+
+ virtual void uniformMatrix3fv(int location, int count, bool transpose, const float* v) const
+ {
+ glUniformMatrix3fv(location, count, transpose, v);
+ }
+
+ virtual void uniformMatrix4fv(int location, int count, bool transpose, const float* v) const
+ {
+ glUniformMatrix4fv(location, count, transpose, v);
+ }
+
+protected:
+ /**
+ * Protected constructor.
+ * New instances of this class are supposed to be created by ShaderProgramBeagle::createProgram.
+ *
+ * @param vertName File name of vertex shader.
+ * @param fragName File name of fragment shader.
+ */
+ ShaderProgramBeagle(const std::string& vertName, const std::string& fragName, GLuint handle);
+
+private:
+ /// OpenGL ES program handle
+ GLuint _progHandle;
+};
+
+#endif /* BEAGLESHADERPROGRAM_H_ */
--- /dev/null
+############################################################################
+#
+# Copyright 2010 BMW Car IT GmbH
+#
+#
+# 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.
+#
+############################################################################
+ifneq ($(CONFIG),)
+include ../../../../LayerManagerPlatform/Make$(CONFIG).defs
+endif
+
+SRC = BeagleRenderer.cpp \
+ GLESGraphicSystem.cpp \
+ NullWindowSystem.cpp \
+ BaseRenderer.cpp \
+ ShaderProgramBeagle.cpp
+
+TARGET_NAME = libBeagleRenderer.so
+
+ADD_INCLUDE_DIR+=include \
+ ../../Base/include \
+ ../../Graphic/include \
+ $(PREFIX)/usr/include/layermanager
+
+ADD_LIB_DIR+= $(PREFIX)/usr/lib/layermanager
+
+ADD_LIBS+= EGL Xcomposite pthread GLESv2 LayerManagerUtils Xxf86vm
+
+OBJS = $(patsubst %.cpp,build/%.o,$(SRC))
+TARGET = build/$(TARGET_NAME)
+INCLUDE= $(patsubst %$,-I%,$(ADD_INCLUDE_DIR))
+LIBS+=$(shell pkg-config --libs $(PKG)) $(patsubst %$,-L%,$(ADD_LIB_DIR)) $(patsubst %$,-l%,$(ADD_LIBS))
+LIBS+= cmem.a470uC
+
+all: $(TARGET)
+
+build/%.o: src/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+build/%.o: ../../Base/src/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+build/%.o: ../../Graphic/src/GraphicSystems/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+build/%.o: ../../Graphic/src/WindowSystems/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+build/%.o: ../../Graphic/src/TextureBinders/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+$(TARGET): $(SHADERS) $(OBJS)
+ $(CXX) $(CXXFLAGS) -shared -W1,-soname,$(TARGET) -o $(TARGET) $(OBJS) $(LIBS)
+
+install:
+ mkdir -p $(PREFIX)/usr/lib/layermanager/renderer
+ install -m 755 $(TARGET) $(PREFIX)/usr/lib/layermanager/renderer
+
+clean:
+ rm -f $(OBJS) $(TARGET)
+ rm -rf build
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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.
+*
+****************************************************************************/
+// alpha value of the surfaces
+uniform mediump float uAlphaVal;
+// textureunit which is accessed
+uniform mediump sampler2D uTexUnit;
+
+// texture coordinates sended by the vertex shader
+varying mediump vec2 vTexout;
+
+void main()
+{
+ // correct Texture Coords;
+ mediump vec4 color = texture2D(uTexUnit, vTexout ) * vec4(1.0,1.0,1.0,uAlphaVal);
+ gl_FragColor = color;
+// gl_FragColor.a = 1.0;
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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.
+*
+****************************************************************************/
+
+// Vertex position. Will be in range 0 to 1
+attribute highp vec2 aPosition;
+attribute highp vec2 aTexCoords;
+
+// normalized window position
+// (0, 0 is upper left, 1, 1 is lower right)
+uniform mediump float uX;
+uniform mediump float uY;
+
+// normalized window size
+// 1.0 will cover the entire viewport
+uniform mediump float uWidth;
+uniform mediump float uHeight;
+
+// texrange describes the width and height of texture area which should be rendered
+uniform mediump vec2 uTexRange;
+// texrange describes the x and y position of the texture area which should be rendered
+uniform mediump vec2 uTexOffset;
+
+// texture coordinates
+varying mediump vec2 vTexout;
+
+void main()
+{
+ // Get the size correct. Multiply by 2 because -1 to +1 is mapped to
+ // the viewport
+ gl_Position.xy = 2.0 * aPosition.xy * vec2( uWidth, uHeight); // rechte seite des fensters: volle breite sonst 0
+gl_Position.xy += vec2(uX * 2.0 - 1.0+0.5, 1.0 - ((uY + uHeight)* 2.0));
+ gl_Position.zw = vec2(0.0, 1.0);
+ vTexout = vec2(uTexOffset.x + uTexRange.x * aTexCoords.x,1.0-(uTexOffset.y + aTexCoords.y*uTexRange.y+(1.0-uTexRange.y)));
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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.
+*
+****************************************************************************/
+
+// this define causes a second window to be created behind the actual compositor
+// this window is black and covers the rest of the screen, it has no other funcionality
+
+#include "BeagleRenderer.h"
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 <ShaderProgramBeagle.h>
+#include <RenderUtil.h>
+#include <Log.h>
+
+
+ShaderProgram* ShaderProgramBeagle::createProgram(const std::string& vertName, const std::string& fragName)
+{
+ GLuint progHandle;
+ ShaderProgramBeagle* program = 0;
+
+ if (vertName=="default" && fragName=="default")
+ {
+ progHandle = RenderUtilLoadShaderSources("renderer_vert.glslv", "renderer_frag.glslf", GL_TRUE);
+ }
+ else
+ {
+ // load shader sources from file, compile and link them:
+ progHandle = RenderUtilLoadShaderSources(vertName.c_str(), fragName.c_str(), GL_TRUE);
+ }
+
+ if (progHandle!=0)
+ {
+ // bind attrib locations for vertex positions and texture coordinates
+ glBindAttribLocation(progHandle, 0, "aPosition");
+ glBindAttribLocation(progHandle, 1, "aTexCoords");
+
+ // re-link the program as we have changed the attrib bindings
+ glLinkProgram(progHandle);
+
+ program = new ShaderProgramBeagle(vertName, fragName, progHandle);
+ }
+ else
+ {
+ LOG_ERROR("ShaderProgramBeagle", "Failed to create and link shader program");
+ }
+
+ return program;
+}
+
+ShaderProgramBeagle::ShaderProgramBeagle(const std::string& vertName, const std::string& fragName, GLuint handle)
+ : ShaderProgram(vertName, fragName)
+ , _progHandle(handle)
+{
+ // Update the uniform locations.
+ // Don't move this call to the base class constructor as we need
+ // to set the OpenGL program handle first.
+ updateCommonUniformLocations();
+}
+
+ShaderProgramBeagle::~ShaderProgramBeagle(void)
+{
+ if (_progHandle)
+ {
+ glDeleteProgram(_progHandle);
+ }
+}
+
+void ShaderProgramBeagle::use(void) const
+{
+ glUseProgram(_progHandle);
+}
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SHADERPROGRAMGLES_H_
+#define _SHADERPROGRAMGLES_H_
+
+#include <ShaderProgram.h>
+#include <GLES2/gl2.h>
+
+/// pointer to shader program creator function
+//typedef ShaderProgram* (*PfnShaderProgramCreator)(const std::string&, const std::string&);
+
+/**
+ * Factory for creating platform specific shader programs.
+ */
+class ShaderProgramGLES : public ShaderProgram
+{
+public:
+ /**
+ * Create a new shader program.
+ *
+ * @param vertName File name of vertex shader.
+ * @param fragName File name of fragment shader.
+ * @return new Program instance, NULL if program could not be created.
+ */
+ static ShaderProgram* createProgram(const std::string& vertName, const std::string& fragName);
+
+ /**
+ * Destructor
+ */
+ virtual ~ShaderProgramGLES(void);
+
+ /**
+ * Start using the shader program for rendering.
+ */
+ virtual void use(void) const;
+
+ virtual int getUniformLocation(const char* name) const
+ {
+ return glGetUniformLocation(_progHandle, name);
+ }
+
+ virtual void uniform1iv(int location, int count, const int* v) const
+ {
+ glUniform1iv(location, count, v);
+ }
+
+ virtual void uniform1fv(int location, int count, const float* v) const
+ {
+ glUniform1fv(location, count, v);
+ }
+
+ virtual void uniform2fv(int location, int count, const float* v) const
+ {
+ glUniform2fv(location, count, v);
+ }
+
+ virtual void uniform3fv(int location, int count, const float* v) const
+ {
+ glUniform3fv(location, count, v);
+ }
+
+ virtual void uniform4fv(int location, int count, const float* v) const
+ {
+ glUniform4fv(location, count, v);
+ }
+
+ virtual void uniformMatrix2fv(int location, int count, bool transpose, const float* v) const
+ {
+ glUniformMatrix2fv(location, count, transpose, v);
+ }
+
+ virtual void uniformMatrix3fv(int location, int count, bool transpose, const float* v) const
+ {
+ glUniformMatrix3fv(location, count, transpose, v);
+ }
+
+ virtual void uniformMatrix4fv(int location, int count, bool transpose, const float* v) const
+ {
+ glUniformMatrix4fv(location, count, transpose, v);
+ }
+
+protected:
+ /**
+ * Protected constructor.
+ * New instances of this class are supposed to be created by ShaderProgramGLES::createProgram.
+ *
+ * @param vertName File name of vertex shader.
+ * @param fragName File name of fragment shader.
+ */
+ ShaderProgramGLES(const std::string& vertName, const std::string& fragName, GLuint handle);
+
+private:
+ /// OpenGL ES program handle
+ GLuint _progHandle;
+};
+
+#endif /* _SHADERPROGRAMFACTORY_H */
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _X11GLESRENDERER_H_
+#define _X11GLESRENDERER_H_
+
+#include "BaseRenderer.h"
+#include "LayerList.h"
+
+class X11GLESRenderer : public BaseRenderer
+{
+public:
+ X11GLESRenderer(LayerList* layerlist);
+
+};
+
+#endif /* _X11GLESRENDERER_H_*/
--- /dev/null
+############################################################################
+#
+# Copyright 2010 BMW Car IT GmbH
+#
+#
+# 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.
+#
+############################################################################
+
+ifneq ($(CONFIG),)
+include ../../../../LayerManagerPlatform/Make$(CONFIG).defs
+endif
+
+SRC = X11GLESRenderer.cpp \
+ GLESGraphicSystem.cpp \
+ BaseRenderer.cpp \
+ X11WindowSystem.cpp \
+ ShaderProgramGLES.cpp \
+ X11Copy.cpp \
+ X11CopyGLES.cpp \
+ X11EglImage.cpp
+
+TARGET_NAME = libX11GLESRenderer.so
+
+ADD_INCLUDE_DIR+=include \
+ ../../Base/include \
+ ../../Graphic/include \
+ $(PREFIX)/usr/include/layermanager
+
+ADD_LIB_DIR+= $(PREFIX)/usr/lib/layermanager
+
+ADD_LIBS+= EGL GLESv2 pthread Xcomposite LayerManagerUtils
+
+OBJS = $(patsubst %.cpp,build/%.o,$(SRC))
+TARGET = build/$(TARGET_NAME)
+INCLUDE= $(patsubst %$,-I%,$(ADD_INCLUDE_DIR))
+LIBS+=$(shell pkg-config --libs $(PKG)) $(patsubst %$,-L%,$(ADD_LIB_DIR)) $(patsubst %$,-l%,$(ADD_LIBS))
+
+all: $(TARGET)
+
+build/%.o: src/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+build/%.o: ../../Base/src/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+build/%.o: ../../Graphic/src/GraphicSystems/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+build/%.o: ../../Graphic/src/WindowSystems/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+build/%.o: ../../Graphic/src/TextureBinders/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+
+$(TARGET): $(OBJS)
+ $(CXX) $(CXXFLAGS) -shared -W1,-soname,$(TARGET) -o $(TARGET) $(OBJS) $(LIBS)
+
+install:
+ mkdir -p $(PREFIX)/usr/lib/layermanager/renderer
+ install -m 755 $(TARGET) $(PREFIX)/usr/lib/layermanager/renderer
+
+clean:
+ rm -f $(OBJS) $(TARGET)
+ rm -rf build
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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.
+*
+****************************************************************************/
+// alpha value of the surfaces
+uniform float uAlphaVal;
+// textureunit which is accessed
+uniform mediump sampler2D uTexUnit;
+
+// texture coordinates sended by the vertex shader
+varying mediump vec2 vTexout;
+
+void main()
+{
+ // correct Texture Coords;
+ vec4 mediump color = texture2D(uTexUnit, vTexout ) * vec4(1.0,1.0,1.0,uAlphaVal);
+ gl_FragColor = color;
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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.
+*
+****************************************************************************/
+
+// Vertex position. Will be in range 0 to 1
+attribute highp vec2 aPosition;
+attribute highp vec2 aTexCoords;
+
+// normalized window position
+// (0, 0 is upper left, 1, 1 is lower right)
+uniform mediump float uX;
+uniform mediump float uY;
+
+// normalized window size
+// 1.0 will cover the entire viewport
+uniform mediump float uWidth;
+uniform mediump float uHeight;
+
+// texrange describes the width and height of texture area which should be rendered
+uniform mediump vec2 uTexRange;
+// texrange describes the x and y position of the texture area which should be rendered
+uniform mediump vec2 uTexOffset;
+
+// texture coordinates
+varying mediump vec2 vTexout;
+
+void main()
+{
+ // Get the size correct. Multiply by 2 because -1 to +1 is mapped to
+ // the viewport
+ gl_Position.xy = 2.0 * aPosition.xy * vec2( uWidth, uHeight); // rechte seite des fensters: volle breite sonst 0
+ gl_Position.xy += vec2(uX * 2.0 - 1.0, 1.0 - ((uY + uHeight)* 2.0)); // linke seite des fensters
+ gl_Position.zw = vec2(0.0, 1.0);
+ vTexout = vec2(uTexOffset.x + uTexRange.x * aTexCoords.x,1.0-(uTexOffset.y + aTexCoords.y*uTexRange.y+(1.0-uTexRange.y)));
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "ShaderProgramGLES.h"
+#include <GLES2/gl2ext.h>
+#include <RenderUtil.h>
+#include <Log.h>
+
+static const char defaultVertShaderBinary[] = {
+#include "renderer_vert.cghex"
+};
+static const char defaultFragShaderBinary[] = {
+#include "renderer_frag.cghex"
+};
+
+ShaderProgram* ShaderProgramGLES::createProgram(const std::string& vertName, const std::string& fragName)
+{
+ GLuint progHandle;
+ ShaderProgramGLES* program = 0;
+
+ if (vertName=="default" && fragName=="default")
+ {
+ // load default shader from binary data
+ progHandle = RenderUtilLoadShaderSources("renderer_vert.glslv", "renderer_frag.glslf", GL_TRUE);
+ }
+ else
+ {
+ // load shader sources from file, compile and link them:
+ progHandle = RenderUtilLoadShaderSources(vertName.c_str(), fragName.c_str(), GL_FALSE);
+ }
+
+ if (progHandle!=0)
+ {
+ // bind attrib locations for vertex positions and texture coordinates
+ glBindAttribLocation(progHandle, 0, "aPosition");
+ glBindAttribLocation(progHandle, 1, "aTexCoords");
+
+ // re-link the program as we have changed the attrib bindings
+ glLinkProgram(progHandle);
+
+ program = new ShaderProgramGLES(vertName, fragName, progHandle);
+ }
+ else
+ {
+ LOG_ERROR("ShaderProgramGLES", "Failed to create and link shader program");
+ }
+
+ return program;
+}
+
+ShaderProgramGLES::ShaderProgramGLES(const std::string& vertName, const std::string& fragName, GLuint handle)
+ : ShaderProgram(vertName, fragName)
+ , _progHandle(handle)
+{
+ // Update the uniform locations.
+ // Don't move this call to the base class constructor as we need
+ // to set the OpenGL program handle first.
+ updateCommonUniformLocations();
+}
+
+ShaderProgramGLES::~ShaderProgramGLES(void)
+{
+ if (_progHandle)
+ {
+ glDeleteProgram(_progHandle);
+ }
+}
+
+void ShaderProgramGLES::use(void) const
+{
+ glUseProgram(_progHandle);
+}
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "X11GLESRenderer.h"
+#include "ShaderProgramGLES.h"
+#include "GraphicSystems/GLESGraphicSystem.h"
+#include "WindowSystems/X11WindowSystem.h"
+#include "X11/Xlib.h"
+#include "TextureBinders/X11CopyGLES.h"
+#include "TextureBinders/X11EglImage.h"
+
+X11GLESRenderer::X11GLESRenderer(LayerList* layerlist) : BaseRenderer(layerlist)
+{
+ LOG_DEBUG("X11GLESRenderer", "Creating Renderer");
+
+ // if no binder has been set yet
+ Display* display = XOpenDisplay(0);
+ EGLDisplay m_eglDisplay = eglGetDisplay(display);
+ ITextureBinder* binder=NULL;
+ const char* query = eglQueryString(m_eglDisplay, EGL_EXTENSIONS);
+ LOG_DEBUG("X11GLESRenderer", "EGL_EXTENSIONS: " << query);
+ #ifdef EGL_NATIVE_PIXMAP_KHR
+ binder = new X11EglImage((Display*)display);
+ #else
+ binder = new X11CopyGLES((Display*)display);
+ #endif
+
+ BaseGraphicSystem* graphicSystem = new GLESGraphicsystem( ShaderProgramGLES::createProgram, binder);
+ m_windowSystem = new X11WindowSystem(layerlist, graphicSystem);
+};
+
+extern "C" BaseRenderer* createX11GLESRenderer(LayerList* layerlist){
+ return new X11GLESRenderer(layerlist);
+}
+
+extern "C" void destroyX11GLESRenderer(X11GLESRenderer* p){
+ delete p;
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _BASECOMMUNICATOR_H_
+#define _BASECOMMUNICATOR_H_
+
+class BaseCommunicator;
+
+#include <string>
+
+class CommandExecutor;
+class ILayerList;
+
+/**
+ * Abstract base for all communicator plugins. Subclasses construct command objects
+ * objects from invidual values and give these to the executor object for processing.
+ */
+class BaseCommunicator {
+public:
+
+ /**
+ * Constructor
+ * @param executor Pointer to an object to send commands to
+ * @param layerlist Pointer to the layerlist currently in use
+ */
+ BaseCommunicator(CommandExecutor * executor, ILayerList* layerlist) : m_executor(executor), m_layerlist(layerlist){};
+ virtual ~BaseCommunicator(){};
+
+ /**
+ * Start communication process, ie start specific listening process of communication method
+ */
+ virtual bool start()=0;
+
+ /**
+ * Stop communication. Stop sending command objects.
+ */
+ virtual void stop()=0;
+
+ /**
+ * Switch debug mode of this component on or off
+ * @param onoff Turn on debug mode (true) or off (false)
+ */
+ virtual void setdebug(bool onoff)=0;
+
+protected:
+ // the object to send received commands to
+ CommandExecutor* m_executor;
+ ILayerList* m_layerlist;
+};
+
+#endif /* _BASECOMMUNICATOR_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _COMMANDEXECUTOR_H_
+#define _COMMANDEXECUTOR_H_
+
+#include "commands/Command.h"
+#include "commands/CommitCommand.h"
+#include "commands/CreateCommand.h"
+#include "commands/GetDimensionCommand.h"
+#include "commands/GetOpacityCommand.h"
+#include "commands/GetPixelformatCommand.h"
+#include "commands/GetVisibilityCommand.h"
+#include "commands/LayerAddSurfaceCommand.h"
+#include "commands/LayerRemoveSurface.h"
+#include "commands/RemoveCommand.h"
+#include "commands/GetOrientationCommand.h"
+#include "commands/LayergroupAddLayerCommand.h"
+#include "commands/LayergroupRemoveLayerCommand.h"
+#include "commands/SetDestinationRectangleCommand.h"
+#include "commands/SetOpacityCommand.h"
+#include "commands/SetSourceRectangleCommand.h"
+#include "commands/SetOrientationCommand.h"
+#include "commands/SurfacegroupAddSurfaceCommand.h"
+#include "commands/SurfacegroupRemoveSurfaceCommand.h"
+#include "commands/SetVisibilityCommand.h"
+#include "commands/DebugCommand.h"
+#include "commands/ExitCommand.h"
+#include "commands/SetLayerOrderCommand.h"
+#include "commands/SetOrderWithinLayerCommand.h"
+#include "commands/SetDimensionCommand.h"
+#include "commands/SetPositionCommand.h"
+#include "commands/GetPositionCommand.h"
+#include "commands/CreateShaderCommand.h"
+#include "commands/DestroyShaderCommand.h"
+#include "commands/SetShaderCommand.h"
+#include "commands/SetUniformsCommand.h"
+
+/**
+ * Objects who implement this interface can be used to have command objects executed. Communication
+ * classes must only know this interface of a class to be able to pass along command objects.
+ *
+ * Implementation detail: This interface is used to reduce dependency of communicators on the main layermanagement component
+ */
+class CommandExecutor{
+public:
+ /**
+ * Have a command processed.
+ * @param commandToBeExecuted The command to be processed
+ */
+ virtual void execute(Command* commandToBeExecuted)=0;
+
+ virtual uint getLayerTypeCapabilities(LayerType layertype)=0;
+
+};
+
+#endif /* _COMMANDEXECUTOR_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _GRAPHICALGROUP_H_
+#define _GRAPHICALGROUP_H_
+
+#include "LogicalGraphicsObject.h"
+#include <list>
+
+/**
+ * Containerclass grouping objects. Grouping makes it possible to call Commands on multiple targets(the group) at once.
+ * @param T defines the element class. (Layergroup has Layer* as element type for instance)
+ * @param FIRST_ID a group is parameterized by the first ID given to the group (counting upwards)
+ */
+template <class T, ObjectType thetype>
+class GraphicalGroup : public GraphicalObject{
+public:
+
+ GraphicalGroup() : GraphicalObject(thetype,1,true){
+ list = std::list<T*>();
+ };
+
+ /**
+ * Set visibility on every element of the group
+ */
+ virtual void setVisibility(bool visible){
+ this->visibility = visible;
+ for(typename std::list<T*>::iterator it = list.begin(); it != list.end(); it++)
+ (*it)->setVisibility(visible);
+ };
+
+ /**
+ * Set opacity on every element of the group
+ */
+ virtual void setOpacity(double opacity){
+ this->opacity = opacity;
+ for(typename std::list<T*>::iterator it = list.begin(); it != list.end(); it++)
+ (*it)->setOpacity(opacity);
+ };
+
+ const std::list<T*> getList(){return list;};
+ void addElement(T* element){list.push_back(element);};
+ void removeElement(T* element){list.remove(element);};
+
+private:
+
+ // the list containing the elements represented by the group
+ std::list<T*> list;
+};
+
+#endif /* _GRAPHICALGROUP_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _GRAPHICALSURFACE_H_
+#define _GRAPHICALSURFACE_H_
+
+#include "LogicalGraphicsObject.h"
+#include "Rectangle.h"
+#include "Vector2.h"
+#include "Orientation.h"
+
+/**
+ * Abstract Type representing a graphical surface.
+ */
+class GraphicalSurface : public GraphicalObject{
+public:
+ GraphicalSurface(ObjectType type) : GraphicalObject(type,1,true),orientation(Zero),SourceViewport(0,0,0,0),DestinationViewport(0,0,0,0) {
+ };
+
+ /**
+ * Set Orientation value
+ * @param orientation the new value. Multiples of 90 degrees. (0->0°, 1->90°, 2->180°,3->279°)
+ */
+ void setOrientation(OrientationType newOrientation){orientation = newOrientation;};
+ const OrientationType getOrientation(){return orientation;};
+
+ /**
+ * Set Source Viewport (only use portion of source graphics)
+ * @param x Horizontal x position within source (clip from the left)
+ * @param y Vertical y position within source (clip from the top)
+ * @param width Width within source (can be used to clip from the right)
+ * @param height Height within source (can be used to clip fromt he bottom)
+ */
+ void setSourceRegion(const Rectangle& newSource){SourceViewport = newSource;};
+ const Rectangle& getSourceRegion(){ return SourceViewport;};
+
+ /**
+ * Set Destination Viewport (Scale output)
+ * @param x Horizontal x position of destination
+ * @param y Vertical y position of destination
+ * @param width Width of destination
+ * @param height Height of destination
+ */
+ void setDestinationRegion(const Rectangle& newDestination){DestinationViewport = newDestination;};
+
+ void setPosition(const int& x, const int& y){DestinationViewport.x = x; DestinationViewport.y = y;};
+ Vector2 getPosition(){ return Vector2(DestinationViewport.x,DestinationViewport.y);}
+ void setDimension(const int& width, const int& height){DestinationViewport.width = width; DestinationViewport.height = height;};
+ const Rectangle& getDestinationRegion(){ return DestinationViewport;};
+ Vector2 getDimension(){ return Vector2(DestinationViewport.width, DestinationViewport.height);};
+private:
+ OrientationType orientation; // Rotation of the graphical content
+ Rectangle SourceViewport;
+ Rectangle DestinationViewport;
+
+};
+
+#endif /* _GRAPHICALSURFACE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _ILAYERLIST_H_
+#define _ILAYERLIST_H_
+
+#include <semaphore.h>
+#include <list>
+#include <map>
+#include "Layer.h"
+#include "GraphicalGroup.h"
+
+typedef GraphicalGroup<Layer,TypeLayerGroup> LayerGroup;
+typedef GraphicalGroup<Surface, TypeSurfaceGroup> SurfaceGroup;
+
+/*
+ * Represents a list of Layers which contain the Surfaces. Sorting is based upon zorder of the contained layers.
+ */
+class ILayerList{
+public:
+ virtual Layer* createLayer()=0;
+ virtual Surface* createSurface()=0;
+ virtual void removeLayer(Layer* layer)=0;
+ virtual void removeSurface(Surface* surface)=0;
+ virtual Layer* getLayer(int id)=0;
+ virtual Surface* getSurface(int id)=0;
+ virtual SurfaceGroup* getSurfaceGroup(const int id)=0;
+ virtual LayerGroup* getLayerGroup(const int id)=0;
+
+ /**
+ * Get list of ids of all layers currently existing.
+ * @return list of ids of all currently know layers
+ */
+ virtual void getLayerIDs(int* length, int** array)=0;
+ virtual void getSurfaceIDs(int* length, int** array)=0;
+
+ /**
+ * Get list of ids of all layers currently existing.
+ * @return list of ids of all currently know layers
+ */
+ virtual void getLayerGroupIDs(int* length, int* array[])=0;
+
+ /**
+ * Get list of ids of all layers currently existing.
+ * @return list of ids of all currently know layers
+ */
+ virtual void getSurfaceGroupIDs(int* length, int* array[])=0;
+
+ bool debugMode;
+
+};
+
+#endif /* _ILAYERLIST_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _IRENDERER_H_
+#define _IRENDERER_H_
+
+#include "LayerList.h"
+#include "Log.h"
+#include "LayerType.h"
+
+/**
+ * Abstract Base of all CompositingControllers, ie Renderers.
+ */
+class IRenderer {
+public:
+ virtual ~IRenderer(){};
+
+ /**
+ * Start the actual renderingprocess (renderloop)
+ */
+ virtual bool start(int width, int height, const char* displayName )=0;
+
+ /**
+ * Stop renderingprocess
+ */
+ virtual void stop()=0;
+
+ /**
+ * Switch debug mode of this component on or off
+ * @param onoff Turn on debug mode (true) or off (false)
+ */
+ virtual void setdebug(bool onoff)=0;
+
+ virtual uint getLayerTypeCapabilities(LayerType layertype)=0;
+
+
+};
+#endif /* _IRENDERER_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LAYER_H_
+#define _LAYER_H_
+
+#include "Surface.h"
+#include "LayerType.h"
+#include <list>
+/*
+ * A graphical Layerobject which contains Surfaces.
+ */
+class Layer : public GraphicalSurface{
+
+public:
+
+ LayerType getLayerType(){ return layerType; };
+ void setLayerType(LayerType lt){ layerType = lt; }
+
+ void setLayerCapabilities(uint newCapabilities){ capabilities = newCapabilities; };
+ uint getCapabilities(){ return capabilities; };
+
+ void addSurface(Surface* s) { surfaces.push_back(s); };
+ void removeSurface(Surface* s){ surfaces.remove(s); };
+
+ std::list<Surface*>& getAllSurfaces(){return surfaces;}
+
+ std::list<Surface*> surfaces;
+private:
+ LayerType layerType;
+ uint capabilities;
+ Layer() : GraphicalSurface(TypeLayer), layerType(Software_2D), capabilities(0){};
+ friend class LayerList;
+
+};
+
+
+#endif /* _LAYER_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LAYERCAPABILITIES_H_
+#define _LAYERCAPABILITIES_H_
+
+/**
+ * Enumeration of possible PixelFormats
+ */
+enum LayerCapabilities{
+ LayerPosition,
+ LayerScalable,
+ LayerOrientable,
+ Layer3D,
+ LayerComposedByAlpha
+};
+
+#endif /* _LAYERCAPABILITIES_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LAYERLIST_H_
+#define _LAYERLIST_H_
+
+#include <semaphore.h>
+#include <list>
+#include "Layer.h"
+#include "GraphicalGroup.h"
+#include "ILayerList.h"
+
+#include "Shader.h"
+#include <map>
+
+class Command;
+/*
+ * Represents a list of Layers which contain the Surfaces.
+ */
+class LayerList : public ILayerList {
+public:
+ Layer* createLayer();
+ Surface* createSurface();
+ SurfaceGroup* createSurfaceGroup();
+ LayerGroup* createlayerGroup();
+ void removeLayer(Layer* layer);
+ void removeSurface(Surface* surface);
+ void removeLayerGroup(LayerGroup* layer);
+ void removeSurfaceGroup(SurfaceGroup* surface);
+ Layer* getLayer(int id);
+ Surface* getSurface(int id);
+ SurfaceGroup* getSurfaceGroup(const int id);
+ LayerGroup* getLayerGroup(const int id);
+ void getLayerIDs(int* length, int** array);
+ void getSurfaceIDs(int* length, int** array);
+ void getLayerGroupIDs(int* length, int** array);
+ void getSurfaceGroupIDs(int* length, int** array);
+
+ std::list<Layer*>& getCurrentRenderOrder(){return currentRenderOrder;}
+ const std::map<int,Layer*> getAllLayers(){return allLayers;}
+ const std::map<int,Surface*> getAllSurfaces(){return allSurfaces;}
+ std::list<Command*> toBeCommittedList;
+ std::map<int,Shader*> shaderList;
+
+private:
+ std::map<int,LayerGroup*> layerGroupList;
+ std::map<int,SurfaceGroup*> surfaceGroupList;
+ std::map<int,Surface*> allSurfaces;
+ std::map<int,Layer*> allLayers;
+ std::list<Layer*> currentRenderOrder;
+};
+
+#endif /* _LAYERLIST_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LAYERTYPE_H_
+#define _LAYERTYPE_H_
+
+/**
+ * Enumeration of possible LayerTypes
+ */
+enum LayerType{
+ Hardware = 0,
+ Software_2D = 1,
+ Software_2_5D = 2
+};
+
+#endif /* _LAYERTYPE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LAYERMANAGER_H_
+#define _LAYERMANAGER_H_
+
+#include "ObjectType.h"
+#include "IRenderer.h"
+#include "Surface.h"
+#include "Layer.h"
+#include "CommandExecutor.h"
+#include "LayerList.h"
+#include "BaseCommunicator.h"
+#include "LogicalGraphicsObject.h"
+#include "GraphicalSurface.h"
+#include "GraphicalGroup.h"
+#include "errors.h"
+#include "commands/Command.h"
+#include <vector>
+#include "LayerType.h"
+
+class Layermanager : public CommandExecutor{
+public:
+ // the singleton reference
+ static Layermanager* instance;
+ void execute(Command* commandToBeExecuted);
+ uint getLayerTypeCapabilities(LayerType layertype);
+
+ LayerList layerlist;
+
+ void addRenderer(IRenderer* renderer);
+ void RemoveRenderer(IRenderer* renderer);
+ void addCommunicator(BaseCommunicator* communicator);
+ bool startManagement( int width,int height,const char* displayName );
+
+private:
+ Layermanager();
+
+ std::list<IRenderer*> compositingControllers;
+ std::list<BaseCommunicator*> communicationControllers;
+ void printDebugInformation();
+};
+
+#endif /* _LAYERMANAGER_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LOGICALGRAPHICSOBJECT_H_
+#define _LOGICALGRAPHICSOBJECT_H_
+
+#include "ObjectType.h"
+
+class Shader;
+/**
+ * Base class of all objects representing graphical objects within the layermanagement.
+ */
+class GraphicalObject{
+public:
+
+ GraphicalObject(ObjectType type, double opacity, bool visibility) : type(type),id(NextID++),shader(0),opacity(opacity),visibility(visibility)
+ {};
+
+ /**
+ * Set alpha value
+ * @param alpha The new Alpha Value between 0.0 (full transparency) and 1.0 (fully visible)
+ */
+ virtual void setOpacity(double newOpacity){opacity = newOpacity;};
+ double getOpacity(){return opacity;};
+
+ /**
+ * Set the visibility
+ * @param visible set this object visible (true) or invisible (false)
+ */
+ virtual void setVisibility(bool newVisibility){visibility = newVisibility;};
+ bool getVisibility(){ return visibility;};
+
+ int getID() const {return id;};
+
+ /**
+ * Assign custom shader for rendering
+ *
+ * @param s Custom shader. If NULL, default shader will be used.
+ */
+ void setShader(Shader* s)
+ {
+ shader = s;
+ }
+
+ /**
+ * @return currently assigned custom shader object
+ */
+ Shader* getShader()
+ {
+ return shader;
+ }
+
+ ObjectType type;
+
+public:
+ /**
+ * ID of this graphical object (Layerid, surfaceid etc)
+ */
+ int id;
+ /**
+ * Pointer to currently assigned shader. If NULL, a default shader will be used.
+ */
+ Shader* shader;
+ double opacity;
+ bool visibility;
+ static int NextID;
+};
+
+#endif /* _LOGICALGRAPHICSOBJECT_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _GRAPHICALOBJECTTYPE_H_
+#define _GRAPHICALOBJECTTYPE_H_
+
+/**
+ * Enumeration of possible graphicalObjectTypes
+ */
+enum ObjectType{
+ TypeSurface,
+ TypeLayer,
+ TypeSurfaceGroup,
+ TypeLayerGroup
+};
+
+#endif /* _GRAPHICALOBJECTTYPE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _ORIENTATION_H
+#define _ORIENTATION_H
+
+/**
+ * Enumeration of possible orientations. Orientation in this context means Rotation.
+ * Surfaces and Layers can be rotated for composition. Values mean clockwise rotation.
+ */
+enum OrientationType {
+ Zero = 0,
+ Ninety = 1,
+ OneEighty = 2,
+ TwoSeventy = 3
+};
+
+#endif /* _ORIENTATION_H */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _PIXELFORMAT_H_
+#define _PIXELFORMAT_H_
+
+/**
+ * Enumeration of possible PixelFormats
+ */
+enum PixelFormat
+{
+ PIXELFORMAT_R8,
+ PIXELFORMAT_RGB888,
+ PIXELFORMAT_RGBA8888,
+ PIXELFORMAT_RGB565,
+ PIXELFORMAT_RGBA5551,
+ PIXELFORMAT_RGBA6661,
+ PIXELFORMAT_RGBA4444
+};
+
+#endif /* _PIXELFORMAT_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _PLATFORMSURFACE_H_
+#define _PLATFORMSURFACE_H_
+
+class Surface;
+
+/*
+ * Contains platform specific information ie specifics for the rendering used, for instance platform specific handles
+ */
+class PlatformSurface{
+public:
+ /**
+ * Platform specific Surface information is contained in subclasses of PlatformSurface.
+ * The Platformspecific implementation can gain access to platform independant attributes (position, alpha) of the corresponding surface
+ * through the given reference
+ */
+ PlatformSurface(Surface* surface) : s(surface){};
+ virtual ~PlatformSurface(){};
+
+ // Reference to platform independant surface type for access to size etc
+ Surface* s;
+};
+
+#endif /* _PLATFORMSURFACE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _RECTANGLE_H_
+#define _RECTANGLE_H_
+
+#include <ostream>
+
+class Rectangle {
+public:
+ Rectangle(){};
+ Rectangle(int x, int y, int width, int height) : x(x),y(y),width(width),height(height){};
+ int x;
+ int y;
+ int width;
+ int height;
+
+ bool operator ==(const Rectangle rhs) const{
+ return (x==rhs.x && y == rhs.y && width==rhs.width && height==rhs.height);
+ }
+
+ friend std::ostream& operator<<(std::ostream& stream, const Rectangle& obj);
+};
+
+#endif /* _RECTANGLE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SHADER_H_
+#define _SHADER_H_
+
+#include <ShaderProgram.h>
+#include <ShaderUniform.h>
+#include <string>
+#include <map>
+
+/**
+ * Represents a shader instance.
+ *
+ * It stores a set of uniform parameters and refers to an OpenGL program object.
+ * Some uniform variables are pre-defined, like surface position and size,
+ * opacity, etc... Additionally, there may be user-defined uniforms.
+ */
+class Shader
+{
+public:
+ /**
+ * Creates a new shader instance by vertex and fragment shader name.
+ * @param vertName File name of vertex shader.
+ * @param fragName File name of fragment shader.
+ * @return new Shader instance, NULL if shader could not be loaded, compiled or linked.
+ */
+ static Shader* createShader(const std::string& vertName, const std::string& fragName);
+
+ /**
+ * Destructor
+ */
+ ~Shader();
+
+ /**
+ * @return Unique ID of this instance
+ */
+ int getId(void) const
+ {
+ return _id;
+ }
+
+ /**
+ * Start using this shader for rendering.
+ */
+ void use(void) const
+ {
+ _program.use();
+ }
+
+ /**
+ * Set a uniform.
+ */
+ void setUniform(const ShaderUniform& uniform);
+
+ /**
+ * Update uniform values.
+ * Please note that this method doesn't update the standard uniforms
+ * used for position, size, etc... They need to be set separately
+ * by loadCommonUniforms().
+ */
+ void loadUniforms(void) const;
+
+ /**
+ * Load uniform values for common surface properties, like position,
+ * size, opacity, etc...
+ *
+ * @param uniforms Uniform values
+ */
+ void loadCommonUniforms(const ShaderProgram::CommonUniforms& uniforms) const
+ {
+ _program.loadCommonUniforms(uniforms);
+ }
+
+private:
+ /**
+ * Private constructor.
+ * New instances of this class are supposed to be created by createShader(...).
+ *
+ * @param program Program object to be used
+ */
+ Shader(ShaderProgram& program);
+
+private:
+ /// unique shader ID
+ const int _id;
+
+ /// reference to OpenGL program object used by this shader instance
+ ShaderProgram& _program;
+
+ /// a map of user-defined uniforms
+ std::map<std::string,ShaderUniform> _uniformMap;
+
+ /// next unique ID
+ static int _nextId;
+};
+
+#endif /* _SHADER_H_ */
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SHADERPROGRAM_H_
+#define _SHADERPROGRAM_H_
+
+#include <string>
+#include <list>
+
+/**
+ * Represents an OpenGL shader program.
+ *
+ * There is a global list of allocated shader programs. Each instance is reference
+ * counted, so if program is no longer in use by any shader instance, it will
+ * be deleted automatically.
+ */
+class ShaderProgram
+{
+public:
+ /**
+ * Stores uniform values for common surface properties,
+ * like position, size, opacity, etc...
+ */
+ struct CommonUniforms
+ {
+ float x;
+ float y;
+ float width;
+ float height;
+ float opacity;
+ float texRange[2];
+ float texOffset[2];
+ int texUnit;
+ };
+
+ /**
+ * Return a shader program from the gobal list. If no matching instance is found, a new
+ * one will be created and added to the list.
+ *
+ * @param vertName File name of vertex shader.
+ * @param fragName File name of fragment shader.
+ * @return new Program instance, NULL if shader could not be loaded, compiled or linked.
+ */
+ static ShaderProgram* obtain(const std::string& vertName, const std::string& fragName);
+
+ /**
+ * Destructor
+ */
+ virtual ~ShaderProgram();
+
+ /**
+ * Start using the shader program for rendering.
+ */
+ virtual void use(void) const = 0;
+
+ /**
+ * Load uniform values for common surface properties, like position,
+ * size, opacity, etc...
+ *
+ * @param uniforms Uniform values
+ */
+ void loadCommonUniforms(const CommonUniforms& uniforms) const;
+
+ /**
+ * @return The name of the vertex shader
+ */
+ const std::string& getVertexName(void) const
+ {
+ return _vertName;
+ }
+
+ /**
+ * @return The name of the fragment shader
+ */
+ const std::string& getFragmentName(void) const
+ {
+ return _fragName;
+ }
+
+ /**
+ * Increment usage counter for this object.
+ */
+ void ref(void);
+
+ /**
+ * Decrement usage counter for this object.
+ * It will be delete if usage counter reaches 0.
+ */
+ void unref(void);
+
+ virtual int getUniformLocation(const char* name) const = 0;
+
+ virtual void uniform1iv(int location, int count, const int* v) const = 0;
+
+ virtual void uniform1fv(int location, int count, const float* v) const = 0;
+
+ virtual void uniform2fv(int location, int count, const float* v) const = 0;
+
+ virtual void uniform3fv(int location, int count, const float* v) const = 0;
+
+ virtual void uniform4fv(int location, int count, const float* v) const = 0;
+
+ virtual void uniformMatrix2fv(int location, int count, bool transpose, const float* v) const = 0;
+
+ virtual void uniformMatrix3fv(int location, int count, bool transpose, const float* v) const = 0;
+
+ virtual void uniformMatrix4fv(int location, int count, bool transpose, const float* v) const = 0;
+
+protected:
+ /**
+ * Protected constructor.
+ * New instances of this class are supposed to be created by the shader program factory.
+ *
+ * @param vertName File name of vertex shader.
+ * @param fragName File name of fragment shader.
+ */
+ ShaderProgram(const std::string& vertName, const std::string& fragName);
+
+ /**
+ * Update the list of uniform locations
+ */
+ void updateCommonUniformLocations(void);
+
+private:
+ /// usage counter
+ int _refCounter;
+
+ /// name of the vertex shader
+ std::string _vertName;
+
+ /// name of the fragment shader
+ std::string _fragName;
+
+ // uniform locations
+ int _xLoc;
+ int _yLoc;
+ int _widthLoc;
+ int _heightLoc;
+ int _opacityLoc;
+ int _texRangeLoc;
+ int _texOffsetLoc;
+ int _texUnitLoc;
+
+ /// global list of programs
+ static std::list<ShaderProgram*> _programList;
+};
+
+#endif /* _SHADERPROGRAM_H_ */
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SHADERPROGRAMFACTORY_H_
+#define _SHADERPROGRAMFACTORY_H_
+
+#include <string>
+#include <ShaderProgram.h>
+
+/// pointer to shader program creator function
+typedef ShaderProgram* (*PfnShaderProgramCreator)(const std::string&, const std::string&);
+
+/**
+ * Factory for creating platform specific shader programs.
+ */
+class ShaderProgramFactory
+{
+public:
+ /**
+ * Create a new shader program.
+ *
+ * @param vertName File name of vertex shader.
+ * @param fragName File name of fragment shader.
+ * @return new Program instance, NULL if program could not be created.
+ */
+ static ShaderProgram* createProgram(const std::string& vertName, const std::string& fragName);
+
+ /**
+ * Set shader program creator function
+ *
+ * @param creatorFunc Pointer to shader program creator function
+ */
+ static void setCreatorFunc(PfnShaderProgramCreator creatorFunc);
+
+private:
+ /**
+ * Dummy private constructor. Prevents creation of instances of this class.
+ */
+ ShaderProgramFactory(void);
+
+private:
+ /// pointer to shader program creator function
+ static PfnShaderProgramCreator _creator;
+};
+
+#endif /* _SHADERPROGRAMFACTORY_H_ */
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SHADERUNIFORM_H_
+#define _SHADERUNIFORM_H_
+
+#include <string>
+#include <vector>
+
+class ShaderProgram;
+
+/**
+ * Stores values for a shader uniform.
+ */
+class ShaderUniform
+{
+public:
+ /** Uniform data value type */
+ enum Type
+ {
+ Undefined,
+ Vector1f,
+ Vector2f,
+ Vector3f,
+ Vector4f,
+ Matrix2f,
+ Matrix3f,
+ Matrix4f
+ };
+
+ /**
+ * Create a uniform from a string description.
+ *
+ * The string description must in the format as follows:
+ * "name type count [transpose] value1 value2 ..."
+ *
+ * String parameter:
+ * name = the uniform name
+ * type = the element type (1f,2f,3f,4f,m2f,m3f,m4f)
+ * count = number of elements
+ * transpose = 0|1, only available if type is a matrix
+ * value = the data values
+ *
+ * Examples:
+ * "uBlurRadius 1f 1 2.7"
+ * "uSize 2f 1 2.5 1.25"
+ * "uTransform 4f 1 0 1.0 0.0 0.0 1.0 0.0 ..."
+ *
+ * @param desc The description
+ * @return Uniform object or NULL in case of a parse error
+ */
+ static ShaderUniform* createFromStringDescription(const std::string& desc);
+
+ /**
+ * constructor.
+ *
+ * @param name Name of uniform
+ * @param location Uniform location in program
+ */
+ ShaderUniform(const std::string& name, int location=-1);
+
+ /**
+ * Copy constructor
+ */
+ ShaderUniform(const ShaderUniform& other);
+
+ /**
+ * Destructor
+ */
+ ~ShaderUniform();
+
+ /**
+ * @return Uniform name
+ */
+ const std::string& getName(void) const
+ {
+ return _name;
+ }
+
+ /**
+ * Set uniform data of type "float"
+ * This can be Vector1f..Vector4f or Matrix2f..Matrix4f
+ *
+ * @param type Data type
+ * @param count Number of data elements
+ * @param value Data values. Actual number of floats must be (count*(size of type)).
+ * @param transpose Whether to transpose a matrix. Only needed if element type is a matrix.
+ */
+ void setData(Type type, int count, const std::vector<float>& values, bool transpose=false);
+
+ /**
+ * Copy data from another uniform
+ */
+ void setData(const ShaderUniform& other);
+
+ /**
+ * Load uniform data in current OpenGL context.
+ */
+ void load(const ShaderProgram& program) const;
+
+private:
+ /// the uniform name
+ std::string _name;
+
+ /// location in shader program
+ int _location;
+
+ /// the uniform data type
+ Type _type;
+
+ /// number of data elements
+ int _count;
+
+ /// the data for float types
+ std::vector<float> _floatData;
+
+ /// whether to transpose the matrix array
+ bool _transpose;
+
+ /// lookup table for element sizes
+ static const int _vectorSizesOfDataTypes[];
+};
+
+#endif /* _SHADERUNIFORM_H_ */
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SURFACE_H_
+#define _SURFACE_H_
+
+#include "GraphicalSurface.h"
+#include <stdlib.h>
+#include "PlatformSurface.h"
+#include "PixelFormat.h"
+
+/**
+ * Represents a graphical surface generated by an application. Always contained in layers.
+ */
+class Surface : public GraphicalSurface {
+
+public:
+ PixelFormat getPixelFormat(){ return pixformat; }
+ void setPixelFormat(PixelFormat pf){pixformat = pf;}
+
+ // dimensions actually generated by the source application
+ // needed for calculations when using a source viewport
+ int OriginalSourceWidth;
+ int OriginalSourceHeight;
+
+ /**
+ * Platform specific Object containing surface information specific to a used platform.
+ * This typically contains a native window handle/surface handle or information only used
+ * by a specific renderer.unsigned
+ */
+ PlatformSurface *platform; // platform/rendering specific window attributes
+
+ long nativeHandle;
+
+ int frameCounter;
+private:
+ Surface(): GraphicalSurface(TypeSurface) , platform (NULL), frameCounter(0) {}
+
+ friend class LayerList;
+ PixelFormat pixformat;
+
+};
+
+#endif /* _SURFACE_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _VECTOR2_H_
+#define _VECTOR2_H_
+
+#include <ostream>
+
+class Vector2 {
+public:
+ Vector2(){};
+ Vector2(int val1, int val2) : val1(val1), val2(val2){};
+ int val1;
+ int val2;
+
+ bool operator ==(const Vector2 rhs) const{
+ return (val1==rhs.val1 && val2 == rhs.val2);
+ }
+
+ friend std::ostream& operator<<(std::ostream& stream, const Vector2& obj);
+};
+
+#endif /* _VECTOR2_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _COMMAND_H_
+#define _COMMAND_H_
+
+#include <iostream>
+#include <LayerList.h>
+
+class Command {
+public:
+ enum CommandType{
+ Create,
+ Remove,
+ SetVisibility,
+ SetOpacity,
+ GetVisibility,
+ GetOpacity,
+ SetSourceRectangle,
+ SetDestinationRectangle,
+ SetPosition,
+ SetDimension,
+ SetOrientation,
+ GetOrientation,
+ GetDimension,
+ GetPosition,
+ GetPixelformat,
+ LayerAddSurface,
+ LayerRemoveSurface,
+ LayergroupAddLayer,
+ LayergroupRemoveLayer,
+ SurfacegroupAddSurface,
+ SurfacegroupRemoveSurface,
+ CommitChanges,
+ SetLayerRenderOrder,
+ SetSurfaceRenderOrderWithinLayer,
+ Debug,
+ Exit,
+ CreateShader,
+ DestroyShader,
+ SetShader,
+ SetUniforms
+ };
+
+ Command(CommandType commandType) :commandType(commandType) {};
+ virtual ~Command(){};
+ const CommandType commandType;
+ virtual void execute(LayerList& layerlist)=0;
+};
+
+#endif /* _COMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _COMMITCOMMAND_H_
+#define _COMMITCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+#include "Log.h"
+
+class CommitCommand : public Command{
+public:
+ CommitCommand() : Command(CommitChanges){};
+ virtual void execute(LayerList& layerlist){
+ for (std::list<Command*>::iterator it = layerlist.toBeCommittedList.begin();it!=layerlist.toBeCommittedList.end();it++){
+ Command* c = (*it);
+ c->execute(layerlist);
+ delete c;
+ }
+ layerlist.toBeCommittedList.clear();
+ };
+};
+
+
+#endif /* _COMMITCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _CREATECOMMAND_H_
+#define _CREATECOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+#include "Log.h"
+
+class CreateCommand : public Command{
+public:
+ CreateCommand(int handle, ObjectType createType, PixelFormat pixelformat,uint OriginalWidth,uint OriginalHeight,unsigned int* idReturn) : Command(Create), createType(createType), nativeHandle(handle), pixelformat(pixelformat),OriginalWidth(OriginalWidth),OriginalHeight(OriginalHeight), idReturn(idReturn){};
+ const ObjectType createType;
+ const int nativeHandle;
+ const PixelFormat pixelformat;
+ unsigned int OriginalWidth;
+ unsigned int OriginalHeight;
+ unsigned int* idReturn;
+ virtual void execute(LayerList& layerlist){
+ switch(createType){
+ case TypeSurface: {Surface* s = layerlist.createSurface();
+ *idReturn = s->getID();
+ s->nativeHandle = nativeHandle;
+ s->setPixelFormat(pixelformat);
+ s->OriginalSourceWidth = OriginalWidth;
+ s->OriginalSourceHeight = OriginalHeight;
+ LOG_DEBUG("created surface with id:", s->getID());
+ break;}
+ case TypeLayer: {Layer* l = layerlist.createLayer();
+ *idReturn = l->getID();
+// LOG_DEBUG("created layer with id:", l->getID());
+ break;}
+ case TypeSurfaceGroup: {SurfaceGroup* sg = layerlist.createSurfaceGroup();
+ *idReturn = sg->getID();
+// LOG_DEBUG("created surfacegroup with id:", sg->getID());
+ break;}
+ case TypeLayerGroup: {LayerGroup* lg = layerlist.createlayerGroup();
+ *idReturn = lg->getID();
+// LOG_DEBUG("created layergroup with id:", lg->getID());
+ break;}
+ }
+ };
+
+};
+
+
+#endif /* _CREATECOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _CREATESHADERCOMMAND_H_
+#define _CREATESHADERCOMMAND_H_
+
+#include <commands/Command.h>
+#include <string>
+#include "Shader.h"
+
+class CreateShaderCommand : public Command
+{
+public:
+ CreateShaderCommand(const std::string& vertName, const std::string& fragName, uint* id)
+ : Command(CreateShader)
+ , _vertName(vertName)
+ , _fragName(fragName)
+ , returnID(id)
+ {
+ // void
+ };
+
+ void execute(LayerList& layerlist){
+ Shader* shader;
+ int id=0;
+
+ // create new shader instance
+ shader = Shader::createShader(_vertName, _fragName);
+
+ if (shader)
+ {
+ // insert shader to shader map
+ id = shader->getId();
+ layerlist.shaderList.insert(std::pair<int,Shader*>(id, shader));
+ }
+
+ *returnID = id;
+ }
+private:
+ const std::string _vertName;
+ const std::string _fragName;
+ uint* returnID;
+};
+
+#endif /* _CREATESHADERCOMMAND_H_ */
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _DEBUGCOMMAND_H_
+#define _DEBUGCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class DebugCommand : public Command{
+public:
+ DebugCommand(bool onoff) : Command(Debug), onoff(onoff){};
+ const bool onoff;
+
+ virtual void execute(LayerList& layerlist){
+ layerlist.debugMode = onoff;
+ };
+};
+
+
+#endif /* _DEBUGCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _DESTROYSHADERCOMMAND_H_
+#define _DESTROYSHADERCOMMAND_H_
+
+#include <commands/Command.h>
+#include "LogicalGraphicsObject.h"
+
+class DestroyShaderCommand : public Command
+{
+public:
+ DestroyShaderCommand(int shaderid)
+ : Command(DestroyShader)
+ , _id(shaderid)
+ {
+ // void
+ };
+
+ void execute(LayerList& layerlist){
+ std::map<int,Shader*>::iterator it;
+
+ // get shader by its ID
+ it = layerlist.shaderList.find(_id);
+ if (it!=layerlist.shaderList.end())
+ {
+ Shader* shader = (*it).second;
+ if (shader)
+ {
+ // detach shader from all surfaces, surface groups, etc...
+ // from surfaces
+ for (std::map<int,Surface*>::const_iterator surfit = layerlist.getAllSurfaces().begin();surfit!=layerlist.getAllSurfaces().end();surfit++)
+ {
+ GraphicalObject* obj = surfit->second;
+ if (obj && obj->getShader()==shader)
+ {
+ obj->setShader(NULL);
+ }
+ }
+ // from layers
+ for (std::map<int,Layer*>::const_iterator layerit = layerlist.getAllLayers().begin();layerit!=layerlist.getAllLayers().end();layerit++)
+ {
+ GraphicalObject* obj = layerit->second;
+ if (obj && obj->getShader()==shader)
+ {
+ obj->setShader(NULL);
+ }
+ }
+
+ // remove shader from global shader list
+ layerlist.shaderList.erase(it);
+
+ // finally delete it
+ delete shader;
+ }
+ }
+ else
+ {
+ // shader not found
+ LOG_ERROR("Layermanager", "shader ID "<<_id<<" not found");
+ }
+ }
+
+private:
+ const int _id;
+};
+
+#endif /* _DESTROYSHADERCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _EXITCOMMAND_H_
+#define _EXITCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class ExitCommand : public Command{
+public:
+ ExitCommand() : Command(Exit){};
+ virtual void execute(LayerList&){};
+};
+
+
+#endif /* _EXITCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _GETDIMENSIONCOMMAND_H_
+#define _GETDIMENSIONCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class GetDimensionCommand : public Command{
+public:
+ GetDimensionCommand(int id, ObjectType type, uint* widthRet, uint* heightRet) : Command(GetDimension), id(id), type(type), width(widthRet), height(heightRet){};
+ const int id;
+ const ObjectType type;
+ uint* width;
+ uint* height;
+ virtual void execute(LayerList& layerlist){
+ GraphicalSurface* go = NULL;
+ switch(type){
+ case TypeSurface: {go = layerlist.getSurface(id); break;}
+ case TypeLayer: {go = layerlist.getLayer(id); break;}
+ case TypeSurfaceGroup: {break;}
+ case TypeLayerGroup: { break;}
+ }
+ if ( NULL != go )
+ {
+ Vector2 dim = go->getDimension();
+ *width = dim.val1;
+ *height = dim.val2;
+ } else {
+ *width = 0;
+ *height = 0;
+ }
+ }
+};
+
+
+#endif /* _GETDIMENSIONCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _GETOPACITYCOMMAND_H_
+#define _GETOPACITYCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class GetOpacityCommand : public Command{
+public:
+ GetOpacityCommand(int id, ObjectType type, double* returnOpacity) : Command(GetOpacity), id(id), type(type), returnOpacity(returnOpacity){};
+ const int id;
+ const ObjectType type;
+ double* returnOpacity;
+
+ virtual void execute(LayerList& layerlist){
+ GraphicalObject* go;
+ switch(type){
+ case TypeSurface: {go = layerlist.getSurface(id); break;}
+ case TypeLayer: {go = layerlist.getLayer(id); break;}
+ case TypeSurfaceGroup: {go = layerlist.getSurfaceGroup(id); break;}
+ case TypeLayerGroup: { go = layerlist.getLayerGroup(id); break;}
+ }
+ *returnOpacity = go->getOpacity();
+ }
+};
+
+
+#endif /* _GETOPACITYCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _GETORIENTATIONCOMMAND_H_
+#define _GETORIENTATIONCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+#include "Orientation.h"
+
+class GetOrientationCommand : public Command{
+public:
+ GetOrientationCommand(int id, ObjectType type, OrientationType* orientation) : Command(GetOrientation), id(id), type(type), returnOrientation(orientation){};
+ const int id;
+ const ObjectType type;
+ OrientationType* returnOrientation;
+
+ virtual void execute(LayerList& layerlist){
+ switch(type){
+ case TypeSurface: {
+ Surface* s = layerlist.getSurface(id);
+ *returnOrientation = s->getOrientation();
+ break;
+ }
+ case TypeLayer: {
+ Layer*l =layerlist.getLayer(id);
+ *returnOrientation = l->getOrientation();
+ break;
+ }
+ case TypeSurfaceGroup: {break;}
+ case TypeLayerGroup: {break;}
+ }
+
+ }
+};
+
+
+#endif /* _GETORIENTATIONCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _GETPIXELFORMATCOMMAND_H_
+#define _GETPIXELFORMATCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+#include "PixelFormat.h"
+
+class GetPixelformatCommand : public Command{
+public:
+ GetPixelformatCommand(int id, ObjectType type, PixelFormat* f) : Command(GetPixelformat), id(id), type(type), formatreturn(f){};
+ const int id;
+ const ObjectType type;
+ PixelFormat* formatreturn;
+ virtual void execute(LayerList& layerlist){
+ switch(type){
+ case TypeSurface: {
+ Surface* s = layerlist.getSurface(id);
+ *formatreturn = s->getPixelFormat();
+ break;
+ }
+ case TypeLayer:{
+ //Layer* l = layerlist.getLayer(id);
+ //*formatreturn = l->getPixelFormat();
+ break;
+ }
+ case TypeSurfaceGroup: break;
+ case TypeLayerGroup: break;
+ }
+ }
+};
+
+#endif /* _GETPIXELFORMATCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _GETPOSITIONCOMMAND_H_
+#define _GETPOSITIONCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class GetPositionCommand : public Command{
+public:
+ GetPositionCommand(int id, ObjectType type, uint* xRet, uint* yRet) : Command(GetPosition), id(id), type(type), x(xRet),y(yRet){};
+ const int id;
+ const ObjectType type;
+ uint* x;
+ uint* y;
+ virtual void execute(LayerList& layerlist){
+ GraphicalSurface* go = NULL;
+ switch(type){
+ case TypeSurface: {go = layerlist.getSurface(id); break;}
+ case TypeLayer: {go = layerlist.getLayer(id); break;}
+ case TypeSurfaceGroup: {break;}
+ case TypeLayerGroup: { break;}
+ }
+ if ( NULL != go )
+ {
+ Vector2 dim = go->getPosition();
+ *x = dim.val1;
+ *y = dim.val2;
+ } else {
+ *x = 0;
+ *y = 0;
+ }
+ }
+};
+
+
+#endif /* _GETPOSITIONCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _GETVISIBILITYCOMMAND_H_
+#define _GETVISIBILITYCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class GetVisibilityCommand : public Command{
+public:
+ GetVisibilityCommand(int id, ObjectType type, bool* visibility) : Command(GetVisibility), id(id), type(type), visibility(visibility){};
+ const int id;
+ const ObjectType type;
+ bool * visibility;
+ void execute(LayerList& layerlist){
+ GraphicalObject* go;
+ switch(type){
+ case TypeSurface: go = layerlist.getSurface(id);
+ break;
+ case TypeLayer: go = layerlist.getLayer(id);
+ break;
+ case TypeSurfaceGroup: go = layerlist.getSurfaceGroup(id);
+ break;
+ case TypeLayerGroup: go = layerlist.getLayerGroup(id);
+ break;
+ }
+ *visibility = go->getVisibility();
+ }
+};
+
+
+#endif /* _GETVISIBILITYCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LAYERADDSURFACECOMMAND_H_
+#define _LAYERADDSURFACECOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class LayerAddSurfaceCommand : public Command{
+public:
+ LayerAddSurfaceCommand(int layerid, int surfaceid) : Command(LayerAddSurface), layerid(layerid), surfaceid(surfaceid){};
+ const int layerid;
+ const int surfaceid;
+
+ virtual void execute(LayerList& layerlist){
+ Layer* l = layerlist.getLayer(layerid);
+ Surface* s = layerlist.getSurface(surfaceid);
+ l->addSurface(s);
+ };
+};
+
+
+#endif /* _LAYERADDSURFACECOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LAYERREMOVESURFACECOMMAND_H_
+#define _LAYERREMOVESURFACECOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class LayerRemoveSurfaceCommand : public Command{
+public:
+ LayerRemoveSurfaceCommand(int layerid, int surfaceid) : Command(LayerRemoveSurface), layerid(layerid), surfaceid(surfaceid){};
+ const int layerid;
+ const int surfaceid;
+
+ virtual void execute(LayerList& layerlist){
+ Layer* l = layerlist.getLayer(layerid);
+ Surface* s = layerlist.getSurface(surfaceid);
+ l->removeSurface(s);
+ };
+};
+
+
+#endif /* _LAYERREMOVESURFACECOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LAYERGROUPADDLAYERCOMMAND_H_
+#define _LAYERGROUPADDLAYERCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class LayergroupAddLayerCommand : public Command{
+public:
+ LayergroupAddLayerCommand(int layergroupid, int layerid) : Command(LayergroupAddLayer), layergroupid(layergroupid), layerid(layerid){};
+ const int layergroupid;
+ const int layerid;
+
+ virtual void execute(LayerList& layerlist){
+ LayerGroup* lg = layerlist.getLayerGroup(layergroupid);
+ Layer* layer = layerlist.getLayer(layerid);
+ lg->addElement(layer);
+ };
+};
+
+
+#endif /* _LAYERGROUPADDLAYERCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LAYERGROUPREMOVELAYERCOMMAND_H_
+#define _LAYERGROUPREMOVELAYERCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class LayergroupRemoveLayerCommand : public Command{
+public:
+ LayergroupRemoveLayerCommand(int layergroupid, int layerid) : Command(LayergroupRemoveLayer), layergroupid(layergroupid), layerid(layerid){};
+ const int layergroupid;
+ const int layerid;
+
+ virtual void execute(LayerList& layerlist){
+ LayerGroup* lg = layerlist.getLayerGroup(layergroupid);
+ Layer* layer = layerlist.getLayer(layerid);
+ lg->removeElement(layer);
+ };
+};
+
+
+#endif /* _LAYERGROUPREMOVELAYERCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _REMOVECOMMAND_H_
+#define _REMOVECOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class RemoveCommand : public Command{
+public:
+ RemoveCommand(int objectID, ObjectType typeToRemove) : Command(Remove), idToRemove(objectID), typeToRemove(typeToRemove){};
+ const int idToRemove;
+ const ObjectType typeToRemove;
+
+ virtual void execute(LayerList& layerlist){
+ switch(typeToRemove){
+ case TypeSurface: {Surface* s = layerlist.getSurface(idToRemove);
+ layerlist.removeSurface(s);
+ break;}
+ case TypeLayer: {Layer* l = layerlist.getLayer(idToRemove);
+ layerlist.removeLayer(l);
+ break;}
+ case TypeSurfaceGroup: {SurfaceGroup* sg = layerlist.getSurfaceGroup(idToRemove);
+ layerlist.removeSurfaceGroup(sg);
+ break;}
+ case TypeLayerGroup: {LayerGroup* lg = layerlist.getLayerGroup(idToRemove);
+ layerlist.removeLayerGroup(lg);
+ break;}
+ }
+ };
+};
+
+
+#endif /* _REMOVECOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETDESTINATIONRECTANGLECOMMAND_H_
+#define _SETDESTINATIONRECTANGLECOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+#include <vector>
+
+class SetDestinationRectangleCommand : public Command{
+public:
+ SetDestinationRectangleCommand(int id, ObjectType typeToSetOn, int x, int y, int width, int height) : Command(SetDestinationRectangle), id(id), typeToSet(typeToSetOn), x(x),y(y),width(width),height(height){};
+ const int id;
+ const ObjectType typeToSet;
+ const int x;
+ const int y;
+ const int width;
+ const int height;
+
+ virtual void execute(LayerList& layerlist){
+ GraphicalSurface* go = NULL;
+ switch(typeToSet){
+ case TypeSurface: {go = layerlist.getSurface(id); break;}
+ case TypeLayer: {go = layerlist.getLayer(id); break;}
+ case TypeSurfaceGroup: {break;}
+ case TypeLayerGroup: { break;}
+ }
+ const Rectangle r(x,y,width,height);
+ if (NULL != go )
+ {
+ go->setDestinationRegion(r);
+ }
+ }
+};
+
+
+#endif /* _SETDESTINATIONRECTANGLECOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETDIMENSIONCOMMAND_H_
+#define _SETDIMENSIONCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+#include <vector>
+
+class SetDimensionCommand : public Command{
+public:
+ SetDimensionCommand(int id, ObjectType typeToSetOn, int width, int height) : Command(SetDimension), id(id), typeToSet(typeToSetOn), width(width),height(height){};
+ const int id;
+ const ObjectType typeToSet;
+ const int width;
+ const int height;
+
+ virtual void execute(LayerList& layerlist){
+ GraphicalSurface* go = NULL;
+ switch(typeToSet){
+ case TypeSurface: {go = layerlist.getSurface(id); break;}
+ case TypeLayer: {go = layerlist.getLayer(id); break;}
+ case TypeSurfaceGroup: {break;}
+ case TypeLayerGroup: { break;}
+ }
+ if ( NULL != go )
+ {
+ go->setDimension(width,height);
+ }
+ }
+};
+
+
+#endif /* _SETDIMENSIONCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETLAYERORDERCOMMAND_H_
+#define _SETLAYERORDERCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class SetLayerOrderCommand : public Command{
+public:
+ SetLayerOrderCommand(int* array, int length) : Command(SetLayerRenderOrder), array(array), length(length){};
+ int* array;
+ const int length;
+
+ virtual void execute(LayerList& layerlist){
+ layerlist.getCurrentRenderOrder().clear();
+ for (int i=0;i<length;i++){
+ Layer* l = layerlist.getLayer(array[i]);
+ layerlist.getCurrentRenderOrder().push_back(l);
+ }
+ };
+};
+
+
+#endif /* _SETLAYERORDERCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETOPACITYCOMMAND_H_
+#define _SETOPACITYCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class SetOpacityCommand : public Command{
+public:
+ SetOpacityCommand(int id, ObjectType type, double Opacity) : Command(SetOpacity), id(id), type(type), Opacity(Opacity){};
+ const int id;
+ const ObjectType type;
+ const double Opacity;
+ virtual void execute(LayerList& layerlist){
+ GraphicalObject* gs;
+ switch(type){
+ case TypeSurface: gs = layerlist.getSurface(id); break;
+ case TypeLayer:gs = layerlist.getLayer(id); break;
+ case TypeSurfaceGroup: gs = layerlist.getSurfaceGroup(id); break;
+ case TypeLayerGroup: gs = layerlist.getLayerGroup(id); break;
+ }
+ gs->setOpacity(Opacity);
+ }
+};
+
+
+#endif /* _SETOPACITYCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETORDERWITHINLAYERCOMMAND_H_
+#define _SETORDERWITHINLAYERCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class SetOrderWithinLayerCommand : public Command{
+public:
+ SetOrderWithinLayerCommand(int layerid, int* array, int length) : Command(SetSurfaceRenderOrderWithinLayer), layerid(layerid), array(array), length(length){};
+ const int layerid;
+ int* array;
+ int length;
+
+ virtual void execute(LayerList& layerlist){
+ Layer* l = layerlist.getLayer(layerid);
+ l->getAllSurfaces().clear();
+ for (int i=0;i<length;i++){
+ Surface* s = layerlist.getSurface(array[i]);
+ l->getAllSurfaces().push_back(s);
+ }
+ };
+};
+
+
+#endif /* _SETORDERWITHINLAYERCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETORIENTATIONCOMMAND_H_
+#define _SETORIENTATIONCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+#include "Orientation.h"
+
+class SetOrientationCommand : public Command{
+public:
+ SetOrientationCommand(int id, ObjectType type, OrientationType Orientation) : Command(SetOrientation), id(id), type(type), Orientation(Orientation){};
+ const int id;
+ const ObjectType type;
+ const OrientationType Orientation;
+
+ virtual void execute(LayerList& layerlist){
+ GraphicalSurface* gs = NULL;
+ switch(type){
+ case TypeSurface: {gs = layerlist.getSurface(id); break;}
+ case TypeLayer:{gs = layerlist.getLayer(id); break;}
+ case TypeSurfaceGroup:{ break;}
+ case TypeLayerGroup:{break;}
+ }
+ if (NULL != gs)
+ gs->setOrientation(Orientation);
+ }
+};
+
+
+#endif /* _SETORIENTATIONCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETPOSITIONCOMMAND_H_
+#define _SETPOSITIONCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+#include <vector>
+
+class SetPositionCommand : public Command{
+public:
+ SetPositionCommand(int id, ObjectType typeToSetOn, int x, int y ) : Command(SetPosition), id(id), typeToSet(typeToSetOn), x(x),y(y){};
+ const int id;
+ const ObjectType typeToSet;
+ const int x;
+ const int y;
+
+ virtual void execute(LayerList& layerlist){
+ GraphicalSurface* go = NULL;
+ switch(typeToSet){
+ case TypeSurface: {go = layerlist.getSurface(id); break;}
+ case TypeLayer: {go = layerlist.getLayer(id); break;}
+ case TypeSurfaceGroup: {break;}
+ case TypeLayerGroup: { break;}
+ }
+ if (NULL != go)
+ {
+ go->setPosition(x,y);
+ }
+ }
+};
+
+
+#endif /* _SETPOSITIONCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETSHADERCOMMAND_H_
+#define _SETSHADERCOMMAND_H_
+
+#include <commands/Command.h>
+
+class SetShaderCommand : public Command
+{
+public:
+ SetShaderCommand(int id, int shaderid)
+ : Command(SetShader)
+ , _id(id)
+ , _shaderid(shaderid)
+ {
+ // void
+ };
+
+ void execute(LayerList& layerlist){
+ std::map<int,Shader*>::iterator it;
+ GraphicalObject* object = layerlist.getSurface(_id);
+ Shader* shader = NULL;
+
+ if (object)
+ {
+ // get shader by its ID
+ it = layerlist.shaderList.find(_shaderid);
+ if (it!=layerlist.shaderList.end())
+ {
+ shader = (*it).second;
+ }
+
+ if (shader!=NULL || _shaderid==0)
+ {
+ // shaderId==0 detaches the custom shader
+ // (shader is supposed to be NULL in this case)
+
+ object->setShader(shader);
+ }
+ else
+ {
+ // shader not found
+ LOG_ERROR("Layermanager", "shader ID "<<_shaderid<<" not found");
+ }
+ }
+ else
+ {
+ // object not found
+ LOG_ERROR("Layermanager", "object ID "<<_id<<" not found");
+ }
+ }
+
+private:
+ const int _id;
+ const int _shaderid;
+};
+
+#endif /* _SETSHADERCOMMAND_H_ */
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETSOURCERECTANGLECOMMAND_H_
+#define _SETSOURCERECTANGLECOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+#include <vector>
+
+class SetSourceRectangleCommand : public Command{
+public:
+ SetSourceRectangleCommand(int id, ObjectType type, int x, int y, int width, int height) : Command(SetSourceRectangle), id(id), typeToSet(type), x(x),y(y),width(width),height(height){};
+ const int id;
+ const ObjectType typeToSet;
+ const int x;
+ const int y;
+ const int width;
+ const int height;
+ virtual void execute(LayerList& layerlist){
+ GraphicalSurface* go = NULL;
+ switch(typeToSet){
+ case TypeSurface: {go = layerlist.getSurface(id); break;}
+ case TypeLayer: {go = layerlist.getLayer(id); break;}
+ case TypeSurfaceGroup: {break;}
+ case TypeLayerGroup: { break;}
+ }
+ const Rectangle r(x,y,width,height);
+ if ( NULL != go )
+ {
+ go->setSourceRegion(r);
+ }
+ }
+};
+
+
+#endif /* _SETSOURCERECTANGLECOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETUNIFORMSCOMMAND_H_
+#define _SETUNIFORMSCOMMAND_H_
+
+#include <commands/Command.h>
+#include <string>
+#include <vector>
+
+class SetUniformsCommand : public Command
+{
+public:
+ SetUniformsCommand(int shaderid, const std::vector<std::string>& uniforms)
+ : Command(SetUniforms)
+ , _shaderid(shaderid)
+ , _uniforms(uniforms)
+ {
+ // void
+ };
+
+ const std::vector<std::string> getUniforms(){
+ return _uniforms;
+ }
+
+ void execute(LayerList& layerlist){
+ // get shader by its ID
+ std::map<int,Shader*>::iterator siterator;
+ siterator = layerlist.shaderList.find(_shaderid);
+
+ if (siterator!=layerlist.shaderList.end())
+ {
+ Shader* shader = (*siterator).second;
+
+ // get uniform descriptions
+ const std::vector<std::string> uniformDesc = _uniforms;
+ std::vector<std::string>::const_iterator uiterator;
+
+ for (uiterator=uniformDesc.begin(); uiterator!=uniformDesc.end(); uiterator++)
+ {
+ // parse description string and create uniform object
+ ShaderUniform* uniform = ShaderUniform::createFromStringDescription(*uiterator);
+ if (uniform)
+ {
+ shader->setUniform(*uniform);
+ delete uniform;
+ }
+ else
+ {
+ LOG_ERROR("Layermanager", "Failed to parse uniform description");
+ }
+ }
+ }
+ else
+ {
+ // shader not found
+ LOG_ERROR("Layermanager", "shader ID "<<_shaderid<<" not found");
+ }
+ }
+private:
+ const int _shaderid;
+ const std::vector<std::string> _uniforms;
+};
+
+#endif /* _SETUNIFORMSCOMMAND_H_ */
+
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SETVISIBILITYCOMMAND_H_
+#define _SETVISIBILITYCOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class SetVisibilityCommand : public Command{
+public:
+ SetVisibilityCommand(const uint givenid, ObjectType Objecttype, bool newvisibility) : Command(SetVisibility), idtoSet(givenid), otype(Objecttype), visibility(newvisibility){};
+ const uint idtoSet;
+ const ObjectType otype;
+ const bool visibility;
+
+ virtual void execute(LayerList& layerlist){
+ GraphicalObject* go;
+ switch(otype){
+ case TypeSurface: go = layerlist.getSurface(idtoSet);
+ break;
+ case TypeLayer: go = layerlist.getLayer(idtoSet);
+ break;
+ case TypeSurfaceGroup: go = layerlist.getSurfaceGroup(idtoSet);
+ break;
+ case TypeLayerGroup: go = layerlist.getLayerGroup(idtoSet);
+ break;
+ }
+ go->setVisibility(visibility);
+ }
+};
+
+
+#endif /* _SETVISIBILITYCOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SURFACEGROUPADDSURFACECOMMAND_H_
+#define _SURFACEGROUPADDSURFACECOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class SurfacegroupAddSurfaceCommand : public Command{
+public:
+ SurfacegroupAddSurfaceCommand(int surfacegroupid, int surfaceid) : Command(SurfacegroupAddSurface), surfacegroupid(surfacegroupid), surfaceid(surfaceid){};
+ const int surfacegroupid;
+ const int surfaceid;
+
+ virtual void execute(LayerList& layerlist){
+ SurfaceGroup* sg = layerlist.getSurfaceGroup(surfacegroupid);
+ Surface* surface = layerlist.getSurface(surfaceid);
+ sg->addElement(surface);
+ };
+};
+
+
+#endif /* _SURFACEGROUPADDSURFACECOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _SURFACEGROUPREMOVESURFACECOMMAND_H_
+#define _SURFACEGROUPREMOVESURFACECOMMAND_H_
+
+#include "Command.h"
+#include "ObjectType.h"
+
+class SurfacegroupRemoveSurfaceCommand : public Command{
+public:
+ SurfacegroupRemoveSurfaceCommand(int surfacegroupid, int surfaceid) : Command(SurfacegroupRemoveSurface), surfacegroupid(surfacegroupid), surfaceid(surfaceid){};
+ const int surfacegroupid;
+ const int surfaceid;
+
+ virtual void execute(LayerList& layerlist){
+ SurfaceGroup* sg = layerlist.getSurfaceGroup(surfacegroupid);
+ Surface* surface = layerlist.getSurface(surfaceid);
+ sg->removeElement(surface);
+ };
+};
+
+
+#endif /* _SURFACEGROUPREMOVESURFACECOMMAND_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _ERRORS_H_
+#define _ERRORS_H_
+
+#include <string>
+
+class IDNotFoundException {
+public:
+ IDNotFoundException(std::string s) : message(s){};
+
+ std::string message;
+};
+
+#endif /* _ERRORS_H_ */
--- /dev/null
+############################################################################
+#
+# Copyright 2010 BMW Car IT GmbH
+#
+#
+# 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.
+#
+############################################################################
+
+ifneq ($(CONFIG),)
+include ../LayerManagerPlatform/Make$(CONFIG).defs
+endif
+
+SRC = LogicalGraphicsObject.cpp \
+ LayerList.cpp \
+ Layermanager.cpp \
+ main.cpp \
+ shader/Shader.cpp \
+ shader/ShaderProgram.cpp \
+ shader/ShaderProgramFactory.cpp \
+ shader/ShaderUniform.cpp
+
+TARGET_NAME = layermanager
+
+ADD_INCLUDE_DIR+= include \
+ $(PREFIX)/usr/include/layermanager
+
+ADD_LIB_DIR+=$(PREFIX)/usr/lib/layermanager
+
+ADD_LIBS+= pthread dl LayerManagerUtils
+
+OBJS = $(patsubst %.cpp,build/%.o,$(SRC))
+TARGET = build/$(TARGET_NAME)
+INCLUDE= $(patsubst %$,-I%,$(ADD_INCLUDE_DIR))
+LIBS=$(shell pkg-config --libs $(PKG)) $(patsubst %$,-L%,$(ADD_LIB_DIR)) $(patsubst %$,-l%,$(ADD_LIBS))
+
+all: $(TARGET)
+
+build/%.o: src/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+$(TARGET): $(OBJS)
+ $(CXX) -Xlinker -export-dynamic -o $(TARGET) $(OBJS) $(LIBS)
+
+install:
+ mkdir -p $(PREFIX)/usr/include/layermanager
+ install -m 755 include/*.h $(PREFIX)/usr/include/layermanager
+ mkdir -p $(PREFIX)/usr/include/layermanager/commands
+ install -m 755 include/commands/*.h $(PREFIX)/usr/include/layermanager/commands
+
+clean:
+ rm -f $(OBJS) $(TARGET)
+ rm -rf build
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "LayerList.h"
+#include "errors.h"
+#include "Layermanager.h"
+#include "Log.h"
+#include <stdexcept>
+
+Layer* LayerList::createLayer(){
+ Layer* l = new Layer();
+ allLayers.insert(std::pair<int,Layer*>(l->getID(),l));
+ return l;
+}
+
+Surface* LayerList::createSurface(){
+ Surface* s = new Surface();
+ allSurfaces.insert(std::pair<int,Surface*>(s->getID(),s));
+ return s;
+}
+
+SurfaceGroup* LayerList::createSurfaceGroup(){
+ SurfaceGroup* s = new SurfaceGroup();
+ surfaceGroupList.insert(std::pair<int,SurfaceGroup*>(s->getID(),s));
+ return s;
+}
+
+LayerGroup* LayerList::createlayerGroup(){
+ LayerGroup* s = new LayerGroup();
+ layerGroupList.insert(std::pair<int,LayerGroup*>(s->getID(),s));
+ return s;
+}
+
+Layer* LayerList::getLayer(int id){
+ Layer* l = NULL;
+ try{
+ l = allLayers.at(id);
+ }catch (std::out_of_range& e){
+ LOG_ERROR("layer not found",id);
+ throw IDNotFoundException("Layer not found");
+ }
+
+ return l;
+}
+
+Surface* LayerList::getSurface(int id){
+ Surface* s = NULL;
+ try{
+ s = allSurfaces.at(id);
+ }catch (std::out_of_range& e){
+ LOG_ERROR("surface not found",id);
+ throw IDNotFoundException("Surface not found");
+ }
+ return s;
+}
+
+SurfaceGroup* LayerList::getSurfaceGroup(const int id){
+ return surfaceGroupList.at(id);
+}
+
+LayerGroup* LayerList::getLayerGroup(const int id){
+ return layerGroupList.at(id);
+}
+
+void LayerList::removeLayer(Layer* l){
+ // take layer out of list of layers
+ allLayers.erase(l->getID());
+ // remove layer from all layergroups it might be part of
+ for (std::map<int,LayerGroup*>::iterator groupIterator=layerGroupList.begin();groupIterator!=layerGroupList.end();groupIterator++){
+ LayerGroup* lg = groupIterator->second;
+ lg->removeElement(l);
+ }
+ delete l;
+}
+
+void LayerList::removeSurface(Surface* s){
+ // take surface out of list of surfaces
+ allSurfaces.erase(s->getID());
+ // remove surface from all layers it might be on
+ for (std::map<int,Layer*>::iterator layerIterator=allLayers.begin();layerIterator!=allLayers.end();layerIterator++){
+ Layer* l = layerIterator->second;
+ l->removeSurface(s);
+ }
+ // remove surface from all surfacegroups it might be part of
+ for (std::map<int,SurfaceGroup*>::iterator groupIterator=surfaceGroupList.begin();groupIterator!=surfaceGroupList.end();groupIterator++){
+ SurfaceGroup* sg = groupIterator->second;
+ sg->removeElement(s);
+ }
+ delete s;
+}
+
+void LayerList::removeLayerGroup(LayerGroup* l){
+ layerGroupList.erase(l->getID());
+ delete l;
+}
+
+void LayerList::removeSurfaceGroup(SurfaceGroup* s){
+ surfaceGroupList.erase(s->getID());
+ delete s;
+}
+
+void LayerList::getLayerIDs(int* length, int** array){
+ int numOfLayers = allLayers.size();
+ *length = numOfLayers;
+ *array = new int[numOfLayers];
+ int i=0;
+ for (std::map<int,Layer*>::const_iterator it = allLayers.begin(); it != allLayers.end(); it++){
+ (*array)[i] = (*it).first;
+ i++;
+ }
+}
+
+void LayerList::getSurfaceIDs(int* length, int** array){
+ int numOfSurfaces = allSurfaces.size();
+ *length = numOfSurfaces;
+ *array = new int[numOfSurfaces];
+ int i=0;
+ for (std::map<int,Surface*>::const_iterator it = allSurfaces.begin(); it != allSurfaces.end(); it++){
+ (*array)[i] = (*it).first;
+ i++;
+ }
+}
+
+void LayerList::getSurfaceGroupIDs(int* length, int** array){
+ int numOfSurfaceGroups = surfaceGroupList.size();
+ *length = numOfSurfaceGroups;
+ *array = new int[numOfSurfaceGroups];
+
+ int i=0;
+ for (std::map<int,SurfaceGroup*>::const_iterator it = surfaceGroupList.begin(); it != surfaceGroupList.end(); it++){
+ (*array)[i] = (*it).first;
+ i++;
+ }
+}
+
+void LayerList::getLayerGroupIDs(int* length, int** array){
+ int numOfLayergroups = layerGroupList.size();
+ *length = numOfLayergroups;
+ *array = new int[numOfLayergroups];
+
+ int i=0;
+ for (std::map<int,LayerGroup*>::const_iterator it = layerGroupList.begin(); it != layerGroupList.end(); it++){
+ (*array)[i] = (*it).first;
+ i++;
+ }
+}
+
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "Layermanager.h"
+#include "Log.h"
+#include <iomanip>
+
+Layermanager* Layermanager::instance = new Layermanager();
+
+Layermanager::Layermanager() {
+ // default layer
+ //Layer* defaultLayer = layerlist.createLayer();
+}
+
+
+uint Layermanager::getLayerTypeCapabilities(LayerType layertype){
+ // get the first renderer for now TODO
+ IRenderer* renderer = *compositingControllers.begin();
+ if (NULL!=renderer)
+ return renderer->getLayerTypeCapabilities(layertype);
+ else
+ return 0;
+}
+
+void Layermanager::addRenderer(IRenderer* renderer){
+ compositingControllers.push_back(renderer);
+}
+void Layermanager::RemoveRenderer(IRenderer* renderer){
+ compositingControllers.remove(renderer);
+}
+void Layermanager::addCommunicator(BaseCommunicator* communicator){
+ communicationControllers.push_back(communicator);
+}
+
+void Layermanager::printDebugInformation(){
+ // print stuff about layerlist
+ LOG_INFO("LayerManager", "Layer: ID | X | Y | W | H |Al.| Z \n");
+ // loop the layers
+ int length;
+ int* LayerIDs;
+ layerlist.getLayerIDs(&length,&LayerIDs);
+ for (int i=0;i<length;i++)
+// for(std::list<int>::iterator currentLayerID = LayerIDs.begin();
+// currentLayerID != LayerIDs.end(); currentLayerID++)
+ {
+ Layer* currentLayer = layerlist.getLayer(LayerIDs[i]);
+ LOG_INFO("LayerManager", " " << std::setw(4) << currentLayer->getID() << "\n");
+
+ LOG_INFO("LayerManager", " Surface: ID |Al.| Z | SVP: X | Y | W | H DVP: X | Y | W | H \n");
+ // loop the surfaces of within each layer
+ for(std::list<Surface*>::iterator current = currentLayer->surfaces.begin();
+ current != currentLayer->surfaces.end(); current++)
+ {
+ LOG_INFO("LayerManager", " " << std::setw(4) << (*current)->getID() << std::setw(4) << std::setprecision(3) << (*current)->opacity << "\n");
+ }
+ }
+
+}
+
+
+void Layermanager::execute(Command* commandToBeExecuted){
+ LOG_DEBUG("Layermanager", "executing a command");
+ switch(commandToBeExecuted->commandType){
+ case Command::Remove:
+ case Command::SetVisibility:
+ case Command::SetOpacity:
+ case Command::SetSourceRectangle:
+ case Command::SetDestinationRectangle:
+ case Command::SetPosition:
+ case Command::SetDimension:
+ case Command::SetOrientation:
+ case Command::LayerAddSurface:
+ case Command::LayerRemoveSurface:
+ case Command::LayergroupAddLayer:
+ case Command::LayergroupRemoveLayer:
+ case Command::SurfacegroupAddSurface:
+ case Command::SurfacegroupRemoveSurface:
+ case Command::SetLayerRenderOrder:
+ case Command::SetSurfaceRenderOrderWithinLayer:
+ {
+ layerlist.toBeCommittedList.push_back(commandToBeExecuted);
+ break;
+ }
+ case Command::Create:
+ default: {
+ commandToBeExecuted->execute(layerlist);
+ delete commandToBeExecuted;
+ break;
+ }
+ }
+}
+
+
+bool Layermanager::startManagement(int width,int height,const char* displayName)
+{
+ bool result = false;
+
+ for( std::list<IRenderer*>::iterator list_iter = compositingControllers.begin();
+ list_iter != compositingControllers.end(); list_iter++)
+ {
+ if ( (NULL != *list_iter) && ( true==(*list_iter)->start(width, height, displayName) ) )
+ {
+ result = true;
+ }
+ else
+ {
+ result = false;
+ break;
+ }
+ }
+ if (result == false)
+ {
+ LOG_ERROR("LayerManager","Could not start Compositing Controllers");
+ }
+ else
+ {
+ for(std::list<BaseCommunicator*>::iterator list_iter = communicationControllers.begin();
+ list_iter != communicationControllers.end(); list_iter++)
+ {
+ if ( (NULL != *list_iter) && ( true==(*list_iter)->start() ) )
+ {
+ result = true;
+ }
+ else
+ {
+ result = false;
+ break;
+ }
+ }
+ if (result == false)
+ {
+ LOG_ERROR("LayerManager","Could not start Communication Controllers");
+ }
+ }
+
+ return result;
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "LogicalGraphicsObject.h"
+
+int GraphicalObject::NextID = 1;
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "Layermanager.h"
+#include "IRenderer.h"
+#include "BaseCommunicator.h"
+#include <iostream>
+#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <string.h>
+#include "Log.h"
+#include <getopt.h>
+const char* displayName = "Tegra:VGA0";
+int displayWidth = 1280;
+int displayHeight = 480;
+const char* USAGE_DESCRIPTION =
+ "Usage:\t layerManager [options]\n"
+ "Option:\t\n\n"
+ "\t-w: Window Width\t\n"
+ "\t-h: Window Height\t\n"
+ "\t-d: displayName \t\n";
+template<class T>
+T* getCreateFunction(std::string libname)
+{
+ void *libraryHandle;
+ libraryHandle = dlopen (libname.c_str(), RTLD_LAZY);
+ if (NULL == libraryHandle) {
+ LOG_ERROR("Main", dlerror());
+ }
+ // cut off directories
+ int lastSlashPosition = libname.rfind('/')+1;
+ int lengthOfFilenameWithoutDirectories = libname.length()-lastSlashPosition;
+ std::string createfunctionname = libname.substr(lastSlashPosition,lengthOfFilenameWithoutDirectories);
+ LOG_DEBUG("without directory:", createfunctionname);
+ // cut off "lib" in front and cut off .so end"
+ createfunctionname = "create" + createfunctionname.substr(3, createfunctionname.length()-6);
+ dlerror(); /* Clear any existing error */
+ LOG_DEBUG("loading external function with name:", createfunctionname);
+ T* createFunction = (T*) dlsym(libraryHandle, createfunctionname.c_str());
+ const char* dlsym_error = dlerror();
+ if (dlsym_error)
+ {
+ LOG_ERROR("Main", "Cannot load symbol create: " << dlsym_error);
+ }
+ return createFunction;
+}
+void parsecommandline(int argc, char **argv)
+{
+ while (optind < argc)
+ {
+ int option = getopt(argc,argv,"w::h::d::?::");
+ switch (option)
+ {
+ case 'd' :
+ displayName = optarg;
+ break;
+ case 'w':
+ displayWidth = atoi(optarg);
+ break;
+ case 'h':
+ displayHeight = atoi(optarg);
+ break;
+ case '?':
+ default:
+ exit(-1);
+ }
+ }
+}
+
+
+std::string getfirstFileFromDirectory(std::string dirName){
+ DIR *dp;
+ std::string returnValue;
+ struct dirent *dirp;
+ if((dp = opendir(dirName.c_str())) == NULL) {
+ LOG_ERROR("Main", "Error(" << errno << ") opening " << dirName);
+ returnValue = "";
+ }else{
+
+ while ((dirp = readdir(dp)) != NULL) {
+ if (strcmp(dirp->d_name,".")==0)
+ continue;
+ if (strcmp(dirp->d_name,"..")==0)
+ continue;
+ if (strstr (dirp->d_name, ".so")==0)
+ continue;
+ LOG_INFO("Main", "loading file " << dirName << "/" << dirp->d_name);
+ returnValue = std::string(dirName + "/" + dirp->d_name);
+ break;
+ }
+ closedir(dp);
+ }
+ return returnValue;
+ //error
+}
+
+BaseCommunicator* loadCommunicator(Layermanager* executor, ILayerList* layerList){
+ std::string sharedLibraryName = getfirstFileFromDirectory("/usr/lib/layermanager/communicator");
+ BaseCommunicator* (*createFunc)(Layermanager*, ILayerList*) = getCreateFunction<BaseCommunicator*(Layermanager*, ILayerList*)>(sharedLibraryName);
+ LOG_DEBUG("Main", "instantiating communicator");
+ BaseCommunicator* ret = createFunc(executor, layerList);
+ LOG_DEBUG("Main", "found communicator");
+ return ret;
+}
+
+IRenderer* loadRenderer(LayerList* list)
+{ IRenderer* ret = NULL;
+ LOG_DEBUG("Main", "Searching for renderer.");
+ std::string sharedLibraryName = getfirstFileFromDirectory("/usr/lib/layermanager/renderer");
+ if (sharedLibraryName==""){
+ LOG_ERROR("Main","No renderer found!");
+ }else{
+ LOG_DEBUG("Main", "Shared Renderer library " << sharedLibraryName << " found !");
+ IRenderer* (*createFunc)(LayerList*) = getCreateFunction<IRenderer*(LayerList*)>(sharedLibraryName);
+ if ( NULL != createFunc )
+ {
+ LOG_DEBUG("Main", "Entry point of Renderer found !");
+ ret = createFunc(list);
+ if ( NULL == ret )
+ {
+ LOG_ERROR("Main","Render could not initiliazed. Entry Function not callable !");
+ }
+ } else {
+ LOG_ERROR("Main","Render could not initiliazed. Entry Function not found !");
+ }
+ }
+ return ret;
+}
+
+
+int main(int argc, char **argv)
+{
+
+ parsecommandline(argc,(char**)argv);
+ LOG_INFO("Main", "Starting Layermanager.");
+
+ // Create Singleton Instance of Layermanager
+ Layermanager *manager = Layermanager::instance;
+
+ LOG_INFO("Main", "Loading communicator.");
+ // Create a communication mechanism to use
+ BaseCommunicator* comm = loadCommunicator(manager,&manager->layerlist);
+//comm->start();
+//while(true)
+// {
+// sleep(2000);
+// }
+
+ LOG_INFO("Main", "Loading renderer.");
+ // Create Grafikcontroller to use
+ IRenderer* renderer = loadRenderer(&manager->layerlist);
+
+ // inform the layermanager about the renderer
+ manager->addRenderer(renderer);
+
+ // inform the layermanager about the communication class
+ manager->addCommunicator(comm);
+ if ( true == manager->startManagement(displayWidth,displayHeight,displayName) )
+ {
+ // must stay within main method or else application would completely exit
+ LOG_INFO("Main", "Enter Mainloop.");
+ while(true)
+ {
+ sleep(2000);
+ }
+ } else {
+ LOG_ERROR("Main", "Exiting Application.");
+ return -1;
+ }
+ LOG_INFO("Main", "Exiting Application.");
+ // cleanup
+ delete renderer;
+ delete comm;
+ delete manager;
+
+ return 0;
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 <Shader.h>
+
+int Shader::_nextId=1;
+
+Shader* Shader::createShader(const std::string& vertName, const std::string& fragName)
+{
+ Shader* shader = 0;
+ ShaderProgram* program;
+
+ // Obtain shader program. If a shader program of the same name already exists,
+ // its instance will be returned. If it doesn't exist, a new program is returned.
+ program = ShaderProgram::obtain(vertName, fragName);
+
+ if (program)
+ {
+ // create shader instance
+ shader = new Shader(*program);
+ }
+ else
+ {
+ // failed to load, compile or link the program
+ }
+
+ return shader;
+}
+
+Shader::Shader(ShaderProgram& program)
+ : _id(_nextId++)
+ , _program(program)
+ , _uniformMap()
+{
+ // increase program reference counter
+ _program.ref();
+}
+
+Shader::~Shader()
+{
+ // decrease program reference counter.
+ // This might destroy the program if no longer in use.
+ _program.unref();
+}
+
+void Shader::setUniform(const ShaderUniform& uniform)
+{
+ const std::string& name = uniform.getName();
+ std::map<std::string,ShaderUniform>::iterator it;
+
+ it = _uniformMap.find(name);
+
+ if (it==_uniformMap.end())
+ {
+ // add new uniform
+ int location = _program.getUniformLocation(name.c_str());
+ ShaderUniform u(name, location);
+ u.setData(uniform);
+ _uniformMap.insert(std::pair<std::string,ShaderUniform>(name, u));
+ }
+ else
+ {
+ // update uniform data
+ (*it).second.setData(uniform);
+ }
+}
+
+void Shader::loadUniforms(void) const
+{
+ std::map<std::string,ShaderUniform>::const_iterator it;
+
+ for (it=_uniformMap.begin(); it!=_uniformMap.end(); it++)
+ {
+ const ShaderUniform& uniform = (*it).second;
+ uniform.load(_program);
+ }
+}
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 <ShaderProgram.h>
+#include <ShaderProgramFactory.h>
+
+// global program list
+std::list<ShaderProgram*> ShaderProgram::_programList;
+
+ShaderProgram* ShaderProgram::obtain(const std::string& vertName, const std::string& fragName)
+{
+ std::list<ShaderProgram*>::iterator it;
+ ShaderProgram* program = 0;
+
+ // search for a matching shader program in the global list
+ for (it=_programList.begin(); it!=_programList.end(); ++it)
+ {
+ ShaderProgram* p = *it;
+ if (p && p->getVertexName()==vertName && p->getFragmentName()==fragName)
+ {
+ program = p;
+ break;
+ }
+ }
+
+ if (!program)
+ {
+ // no matching program object found in global list -> create a new one
+
+ // we are using a factory approach to create platform specific shader programs:
+ program = ShaderProgramFactory::createProgram(vertName, fragName);
+
+ if (program)
+ {
+ // add program to global list
+ _programList.push_back(program);
+ }
+ }
+
+ return program;
+}
+
+ShaderProgram::ShaderProgram(const std::string& vertName, const std::string& fragName)
+ : _refCounter(0)
+ , _vertName(vertName)
+ , _fragName(fragName)
+{
+ // void
+}
+
+ShaderProgram::~ShaderProgram()
+{
+ // void
+}
+
+void ShaderProgram::ref(void)
+{
+ _refCounter++;
+}
+
+void ShaderProgram::unref(void)
+{
+ _refCounter--;
+ if (_refCounter<=0)
+ {
+ // remove program from global list
+ _programList.remove(this);
+
+ // destroy object
+ delete this;
+ }
+}
+
+void ShaderProgram::loadCommonUniforms(const CommonUniforms& uniforms) const
+{
+ if (_xLoc>=0)
+ uniform1fv(_xLoc, 1, &uniforms.x);
+ if (_yLoc>=0)
+ uniform1fv(_yLoc, 1, &uniforms.y);
+ if (_widthLoc>=0)
+ uniform1fv(_widthLoc, 1, &uniforms.width);
+ if (_heightLoc>=0)
+ uniform1fv(_heightLoc, 1, &uniforms.height);
+ if (_opacityLoc>=0)
+ uniform1fv(_opacityLoc, 1, &uniforms.opacity);
+ if (_texRangeLoc>=0)
+ uniform2fv(_texRangeLoc, 1, uniforms.texRange);
+ if (_texOffsetLoc>=0)
+ uniform2fv(_texOffsetLoc, 1, uniforms.texOffset);
+ if (_texUnitLoc>=0)
+ uniform1iv(_texUnitLoc, 1, &uniforms.texUnit);
+}
+
+void ShaderProgram::updateCommonUniformLocations(void)
+{
+ // get uniform locations for common surface properties
+ _xLoc = getUniformLocation("uX");
+ _yLoc = getUniformLocation("uY");
+ _widthLoc = getUniformLocation("uWidth");
+ _heightLoc = getUniformLocation("uHeight");
+ _opacityLoc = getUniformLocation("uAlphaVal");
+ _texRangeLoc = getUniformLocation("uTexRange");
+ _texOffsetLoc = getUniformLocation("uTexOffset");
+ _texUnitLoc = getUniformLocation("uTexUnit");
+}
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 <ShaderProgramFactory.h>
+
+// pointer to shader program creator function
+PfnShaderProgramCreator ShaderProgramFactory::_creator = 0;
+
+ShaderProgram* ShaderProgramFactory::createProgram(const std::string& vertName, const std::string& fragName)
+{
+ if (_creator!=0)
+ return _creator(vertName, fragName);
+ else
+ return 0;
+}
+
+void ShaderProgramFactory::setCreatorFunc(PfnShaderProgramCreator creatorFunc)
+{
+ _creator = creatorFunc;
+}
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 <ShaderUniform.h>
+#include <ShaderProgram.h>
+#include <iostream>
+#include <sstream>
+#include <string>
+#include "Log.h"
+
+using namespace std;
+
+const int ShaderUniform::_vectorSizesOfDataTypes[]=
+{
+ 0, // Undefined
+ 1, // Vector1f
+ 2, // Vector2f
+ 3, // Vector3f
+ 4, // Vector4f
+ 4, // Matrix2f
+ 9, // Matrix3f
+ 16 // Matrix4f
+};
+
+ShaderUniform* ShaderUniform::createFromStringDescription(const std::string& desc)
+{
+ istringstream iss(desc);
+ vector<float> floatData;
+ Type type = Undefined;
+ string name;
+ string token;
+
+ // get name
+ iss >> name;
+
+ // get type
+ iss >> token;
+ if (token=="1f")
+ type = Vector1f;
+ else if (token=="2f")
+ type = Vector2f;
+ else if (token=="3f")
+ type = Vector3f;
+ else if (token=="4f")
+ type = Vector4f;
+ else if (token=="m2f")
+ type = Matrix2f;
+ else if (token=="m3f")
+ type = Matrix3f;
+ else if (token=="m4f")
+ type = Matrix4f;
+ else
+ {
+ LOG_ERROR("Shader Uniform","Can not parse Type " << token);
+ return NULL;
+ }
+
+ // get element count
+ int count;
+ if((iss >> count).fail())
+ {
+ // failed to parse element count
+ LOG_ERROR("Shader Uniform","Fail to parse element count " << count);
+ return NULL;
+ }
+
+ // get transpose parameter if uniform is a matrix
+ bool transpose = false;
+ if (type==Matrix2f || type==Matrix3f || type==Matrix4f)
+ {
+ if ((iss >> transpose).fail())
+ {
+ LOG_ERROR("Shader Uniform","Fail to parse value ");
+ return NULL;
+ }
+ }
+
+ // parse data values
+ size_t numValuesExpected = count*_vectorSizesOfDataTypes[type];
+ for (size_t i=0; i<numValuesExpected; i++)
+ {
+ float value;
+ if ((iss >> value).fail())
+ {
+ // failed to parse value
+ LOG_ERROR("Shader Uniform","Fail to parse value " << value);
+ return NULL;
+ }
+ floatData.push_back(value);
+ }
+
+ if (floatData.size()!=numValuesExpected)
+ {
+ LOG_ERROR("Shader Uniform","Invalid number of values");
+ return NULL;
+ }
+
+ ShaderUniform* uniform = new ShaderUniform(name);
+ uniform->setData(type, count, floatData, transpose);
+
+ return uniform;
+}
+
+ShaderUniform::ShaderUniform(const std::string& name, int location)
+ : _name(name)
+ , _location(location)
+ , _type(Undefined)
+ , _count(0)
+ , _floatData()
+ , _transpose(false)
+{
+}
+
+ShaderUniform::ShaderUniform(const ShaderUniform& other)
+ : _name(other._name)
+ , _location(other._location)
+ , _type(other._type)
+ , _count(other._count)
+ , _floatData(other._floatData)
+ , _transpose(other._transpose)
+{
+}
+
+ShaderUniform::~ShaderUniform()
+{
+}
+
+void ShaderUniform::setData(Type type, int count, const std::vector<float>& values, bool transpose)
+{
+ size_t numValuesExpected = _vectorSizesOfDataTypes[type] * count;
+
+ if (values.size()==numValuesExpected)
+ {
+ _floatData = values;
+ _type = type;
+ _count = count;
+ _transpose = transpose;
+ }
+ else
+ {
+ // invalid number of floats in vector
+ }
+}
+
+void ShaderUniform::setData(const ShaderUniform& other)
+{
+ _type = other._type;
+ _count = other._count;
+ _floatData = other._floatData;
+ _transpose = other._transpose;
+}
+
+void ShaderUniform::load(const ShaderProgram& program) const
+{
+ if (_location==-1)
+ return;
+
+ // Get C array from vector. We assume the data is internally stored in consecutive memory locations.
+ const float* values = &(*_floatData.begin());
+
+ switch(_type)
+ {
+ case Vector1f:
+ program.uniform1fv(_location, _count, values);
+ break;
+
+ case Vector2f:
+ program.uniform2fv(_location, _count, values);
+ break;
+
+ case Vector3f:
+ program.uniform3fv(_location, _count, values);
+ break;
+
+ case Vector4f:
+ program.uniform4fv(_location, _count, values);
+ break;
+
+ case Matrix2f:
+ program.uniformMatrix2fv(_location, _count, _transpose, values);
+ break;
+
+ case Matrix3f:
+ program.uniformMatrix3fv(_location, _count, _transpose, values);
+ break;
+
+ case Matrix4f:
+ program.uniformMatrix4fv(_location, _count, _transpose, values);
+ break;
+
+ default:
+ break;
+ }
+}
+
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LOG_H_
+#define _LOG_H_
+#include "LogMessageBuffer.h"
+#include <iostream>
+#include <fstream>
+typedef enum {
+ LOG_INFO = 1,
+ LOG_WARNING = 2,
+ LOG_ERROR = 4,
+ LOG_DEBUG = 8
+} LOG_MODES;
+
+class Log {
+
+public:
+ virtual ~Log();
+ static Log* instance;
+ void warning (const std::string moduleName, const std::basic_string<char>& output );
+ void info (const std::string moduleName, const std::basic_string<char>& output );
+ void error (const std::string moduleName, const std::basic_string<char>& output );
+ void debug (const std::string moduleName, const std::basic_string<char>& output );
+ void log(LOG_MODES logMode, const std::string moduleName, const std::basic_string<char>& output );
+private:
+ void LogToFile(std::string logMode, const std::string moduleName, const std::basic_string<char>& output);
+ void LogToConsole(std::string logMode,const std::string moduleName,const std::basic_string<char>& output);
+ Log();
+ std::ofstream* m_fileStream;
+};
+#define LOG_ERROR(module, message) { \
+ LogMessageBuffer oss_; \
+ Log::instance->error(module, oss_.str(oss_<< message)); }
+#define LOG_INFO(module, message) { \
+ LogMessageBuffer oss_; \
+ Log::instance->info(module, oss_.str(oss_<< message)); }
+#define LOG_DEBUG(module, message) { \
+ LogMessageBuffer oss_; \
+ Log::instance->debug(module, oss_.str(oss_<< message)); }
+#define LOG_WARNING(module, message) { \
+ LogMessageBuffer oss_; \
+ Log::instance->warning(module, oss_.str(oss_<< message)); }
+#endif /* _LOG_H_ */
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 _LOGMESSAGEBUFFER_H_
+#define _LOGMESSAGEBUFFER_H_
+#include <sstream>
+
+class LogMessageBuffer {
+ typedef std::ios_base& (*ios_base_manip)(std::ios_base&);
+public:
+ /**
+ * Creates a new instance.
+ */
+ LogMessageBuffer();
+ /**
+ * Destructor.
+ */
+ ~LogMessageBuffer();
+
+
+ LogMessageBuffer& operator<<(const std::basic_string<char>& msg);
+
+ LogMessageBuffer& operator<<(const char* msg);
+
+ LogMessageBuffer& operator<<(char* msg);
+
+ LogMessageBuffer& operator<<(const char msg);
+
+ std::ostream& operator<<(ios_base_manip manip);
+
+ std::ostream& operator<<(bool val);
+
+ std::ostream& operator<<(short val);
+
+ std::ostream& operator<<(int val);
+
+ std::ostream& operator<<(unsigned int val);
+
+ std::ostream& operator<<(long val);
+
+ std::ostream& operator<<(unsigned long val);
+
+ std::ostream& operator<<(float val);
+
+ std::ostream& operator<<(double val);
+
+ std::ostream& operator<<(long double val);
+
+ std::ostream& operator<<(void* val);
+
+ /**
+ * Cast to ostream.
+ */
+ operator std::basic_ostream<char>&();
+
+ const std::basic_string<char>& str(std::basic_ostream<char>& os);
+
+ const std::basic_string<char>& str();
+
+ bool hasStream() const;
+
+ private:
+ /**
+ * No default copy constructor.
+ */
+ LogMessageBuffer(const LogMessageBuffer&);
+ /**
+ * No assignment operator.
+ */
+ LogMessageBuffer& operator=(const LogMessageBuffer&);
+
+ /**
+ * Encapsulated std::string.
+ */
+ std::basic_string<char> buf;
+
+ /**
+ * Encapsulated stream, created on demand.
+ */
+ std::basic_ostringstream<char>* stream;
+ };
+template<class V>
+std::basic_ostream<char>& operator<<(LogMessageBuffer& os, const V& val) {
+ return ((std::basic_ostream<char>&) os) << val;
+}
+
+#endif /* _LOGMESSAGEBUFFER_H_ */
--- /dev/null
+############################################################################
+#
+# Copyright 2010 BMW Car IT GmbH
+#
+#
+# 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.
+#
+############################################################################
+
+
+ifneq ($(CONFIG),)
+include ../LayerManagerPlatform/Make$(CONFIG).defs
+endif
+
+SRC += Log.cpp \
+ LogMessageBuffer.cpp
+
+TARGET_NAME = libLayerManagerUtils.a
+LIB_NAME = $(TARGET_NAME).1.0
+
+
+# ADD PACKAGES/INCLUDE_DIRS/LIBS
+PKG=
+ADD_INCLUDE_DIR+= include \
+ $(PREFIX)/usr/include
+
+ADD_LIB_DIR+=
+ADD_LIBS+=
+
+OBJS += $(patsubst %.cpp,build/%.o,$(SRC))
+LINK =
+TARGET = build/$(TARGET_NAME)
+INCLUDE= $(patsubst %$,-I%,$(ADD_INCLUDE_DIR))
+LIBS+=$(shell pkg-config --libs $(PKG)) $(patsubst %$,-L%,$(ADD_LIB_DIR)) $(patsubst %$,-l%,$(ADD_LIBS))
+
+all: $(TARGET)
+
+build/%.o: src/%.cpp
+ $(shell mkdir -p $(shell dirname $@))
+ $(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $<
+
+$(TARGET): $(OBJS)
+ $(AR) rcs $(TARGET) $(OBJS)
+
+install:
+ mkdir -p $(PREFIX)/usr/lib/layermanager
+ install -m 755 $(TARGET) $(PREFIX)/usr/lib/layermanager
+ mkdir -p $(PREFIX)/usr/include/layermanager/
+ install -m 755 include/Log.h $(PREFIX)/usr/include/layermanager/
+ install -m 755 include/LogMessageBuffer.h $(PREFIX)/usr/include/layermanager/
+
+clean:
+ rm -f $(OBJS) $(TARGET)
+ rm -rf build
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "Log.h"
+
+Log* Log::instance = new Log();
+
+Log::~Log() {
+ // TODO Auto-generated destructor stub
+ m_fileStream->close();
+ Log::instance = NULL;
+}
+Log::Log() {
+ // TODO Auto-generated constructor stub
+ m_fileStream = new std::ofstream("log.txt");
+
+}
+
+void Log::warning (const std::string moduleName,const std::basic_string<char>& output )
+{
+ log(LOG_WARNING,moduleName,output);
+}
+void Log::info (const std::string moduleName,const std::basic_string<char>& output )
+{
+ log(LOG_INFO,moduleName,output);
+}
+void Log::error (const std::string moduleName,const std::basic_string<char>& output )
+{
+ log(LOG_ERROR,moduleName,output);
+}
+void Log::debug (const std::string moduleName,const std::basic_string<char>& output )
+{
+ log(LOG_DEBUG,moduleName,output);
+}
+
+void Log::log(LOG_MODES logMode, const std::string moduleName,const std::basic_string<char>& output )
+{
+
+ if (logMode == LOG_ERROR)
+ {
+ LogToConsole("ERROR",moduleName,output);
+ }
+ else if (logMode == LOG_DEBUG)
+ {
+ LogToConsole("DEBUG",moduleName,output);
+ }
+ else if (logMode == LOG_INFO)
+ {
+ LogToConsole("INFO",moduleName,output);
+ }
+ switch (logMode )
+ {
+ case LOG_ERROR : LogToFile("ERROR",moduleName,output); break;
+ case LOG_WARNING : LogToFile("WARNING",moduleName,output); break;
+ case LOG_INFO : LogToFile("INFO",moduleName,output); break;
+ case LOG_DEBUG : LogToFile("DEBUG",moduleName,output); break;
+ }
+
+}
+void Log::LogToFile(std::string logMode,const std::string moduleName,const std::basic_string<char>& output)
+{
+ *m_fileStream << "[" << moduleName << "][" << logMode << "] " << output << std::endl;
+}
+void Log::LogToConsole(std::string logMode,const std::string moduleName,const std::basic_string<char>& output)
+{
+ std::cout << "[" << moduleName << "][" << logMode << "] " << output << std::endl;
+}
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010 BMW Car IT GmbH
+*
+*
+* 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 "LogMessageBuffer.h"
+
+LogMessageBuffer::LogMessageBuffer() : stream(0) {}
+
+LogMessageBuffer::~LogMessageBuffer() {
+ delete stream;
+}
+
+LogMessageBuffer& LogMessageBuffer::operator<<(const std::basic_string<char>& msg) {
+ if (stream == 0) {
+ buf.append(msg);
+ } else {
+ *stream << msg;
+ }
+ return *this;
+}
+
+LogMessageBuffer& LogMessageBuffer::operator<<(const char* msg) {
+ const char* actualMsg = msg;
+ if (actualMsg == 0) {
+ actualMsg = "null";
+ }
+ if (stream == 0) {
+ buf.append(actualMsg);
+ } else {
+ *stream << actualMsg;
+ }
+ return *this;
+}
+LogMessageBuffer& LogMessageBuffer::operator<<(char* msg) {
+ return operator<<((const char*) msg);
+}
+
+LogMessageBuffer& LogMessageBuffer::operator<<(const char msg) {
+ if (stream == 0) {
+ buf.append(1, msg);
+ } else {
+ buf.assign(1, msg);
+ *stream << buf;
+ }
+ return *this;
+}
+
+LogMessageBuffer::operator std::basic_ostream<char>&() {
+ if (stream == 0) {
+ stream = new std::basic_ostringstream<char>();
+ if (!buf.empty()) {
+ *stream << buf;
+ }
+ }
+ return *stream;
+}
+
+const std::basic_string<char>& LogMessageBuffer::str(std::basic_ostream<char>&) {
+ buf = stream->str();
+ return buf;
+}
+
+const std::basic_string<char>& LogMessageBuffer::str() {
+ return buf;
+}
+
+bool LogMessageBuffer::hasStream() const {
+ return (stream != 0);
+}
+
+std::ostream& LogMessageBuffer::operator<<(ios_base_manip manip) {
+ std::ostream& s = *this;
+ (*manip)(s);
+ return s;
+}
+
+std::ostream& LogMessageBuffer::operator<<(bool val) { return ((std::ostream&) *this).operator<<(val); }
+std::ostream& LogMessageBuffer::operator<<(short val) { return ((std::ostream&) *this).operator<<(val); }
+std::ostream& LogMessageBuffer::operator<<(int val) { return ((std::ostream&) *this).operator<<(val); }
+std::ostream& LogMessageBuffer::operator<<(unsigned int val) { return ((std::ostream&) *this).operator<<(val); }
+std::ostream& LogMessageBuffer::operator<<(long val) { return ((std::ostream&) *this).operator<<(val); }
+std::ostream& LogMessageBuffer::operator<<(unsigned long val) { return ((std::ostream&) *this).operator<<(val); }
+std::ostream& LogMessageBuffer::operator<<(float val) { return ((std::ostream&) *this).operator<<(val); }
+std::ostream& LogMessageBuffer::operator<<(double val) { return ((std::ostream&) *this).operator<<(val); }
+std::ostream& LogMessageBuffer::operator<<(long double val) { return ((std::ostream&) *this).operator<<(val); }
+std::ostream& LogMessageBuffer::operator<<(void* val) { return ((std::ostream&) *this).operator<<(val); }
--- /dev/null
+Version 0.1.0
+-------------
+Initial published Version.