Panda3D
 All Classes Functions Variables Enumerations
graphicsThreadingModel.I
00001 // Filename: graphicsThreadingModel.I
00002 // Created by:  drose (27Jan03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: GraphicsThreadingModel::Copy Constructor
00018 //       Access: Published
00019 //  Description: 
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE GraphicsThreadingModel::
00022 GraphicsThreadingModel(const GraphicsThreadingModel &copy) :
00023   _cull_name(copy._cull_name),
00024   _cull_stage(copy._cull_stage),
00025   _draw_name(copy._draw_name),
00026   _draw_stage(copy._draw_stage),
00027   _cull_sorting(copy._cull_sorting)
00028 {
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: GraphicsThreadingModel::Copy Assignment Operator
00033 //       Access: Published
00034 //  Description: 
00035 ////////////////////////////////////////////////////////////////////
00036 INLINE void GraphicsThreadingModel::
00037 operator = (const GraphicsThreadingModel &copy) {
00038   _cull_name = copy._cull_name;
00039   _cull_stage = copy._cull_stage;
00040   _draw_name = copy._draw_name;
00041   _draw_stage = copy._draw_stage;
00042   _cull_sorting = copy._cull_sorting;
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: GraphicsThreadingModel::get_cull_name
00047 //       Access: Published
00048 //  Description: Returns the name of the thread that will handle
00049 //               culling in this model.
00050 ////////////////////////////////////////////////////////////////////
00051 INLINE const string &GraphicsThreadingModel::
00052 get_cull_name() const {
00053   return _cull_name;
00054 }
00055 
00056 ////////////////////////////////////////////////////////////////////
00057 //     Function: GraphicsThreadingModel::set_cull_name
00058 //       Access: Published
00059 //  Description: Changes the name of the thread that will handle
00060 //               culling in this model.  This won't change any windows
00061 //               that were already created with this model; this only
00062 //               has an effect on newly-opened windows.
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE void GraphicsThreadingModel::
00065 set_cull_name(const string &cull_name) {
00066   _cull_name = cull_name;
00067   update_stages();
00068 }
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //     Function: GraphicsThreadingModel::get_cull_stage
00072 //       Access: Published
00073 //  Description: Returns the pipeline stage from which the cull thread
00074 //               should access data.  This will be 0 if the cull is
00075 //               run in the same thread as app, or 1 if it is its own
00076 //               thread.
00077 ////////////////////////////////////////////////////////////////////
00078 INLINE int GraphicsThreadingModel::
00079 get_cull_stage() const {
00080   return _cull_stage;
00081 }
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 //     Function: GraphicsThreadingModel::get_draw_name
00085 //       Access: Published
00086 //  Description: Returns the name of the thread that will handle
00087 //               sending the actual graphics primitives to the
00088 //               graphics API in this model.
00089 ////////////////////////////////////////////////////////////////////
00090 INLINE const string &GraphicsThreadingModel::
00091 get_draw_name() const {
00092   return _draw_name;
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: GraphicsThreadingModel::set_draw_name
00097 //       Access: Published
00098 //  Description: Changes the name of the thread that will handle
00099 //               drawing in this model.  This won't change any windows
00100 //               that were already created with this model; this only
00101 //               has an effect on newly-opened windows.
00102 ////////////////////////////////////////////////////////////////////
00103 INLINE void GraphicsThreadingModel::
00104 set_draw_name(const string &draw_name) {
00105   _draw_name = draw_name;
00106   update_stages();
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: GraphicsThreadingModel::get_draw_stage
00111 //       Access: Published
00112 //  Description: Returns the pipeline stage from which the draw thread
00113 //               should access data.  This will be the same value as
00114 //               get_cull_stage() if cull and draw are run in the same
00115 //               thread, or one more than that value if draw should be
00116 //               in its own thread.
00117 ////////////////////////////////////////////////////////////////////
00118 INLINE int GraphicsThreadingModel::
00119 get_draw_stage() const {
00120   return _draw_stage;
00121 }
00122 
00123 ////////////////////////////////////////////////////////////////////
00124 //     Function: GraphicsThreadingModel::get_cull_sorting
00125 //       Access: Published
00126 //  Description: Returns true if the model involves a separate cull
00127 //               pass, or false if culling happens implicitly, at the
00128 //               same time as draw.
00129 ////////////////////////////////////////////////////////////////////
00130 INLINE bool GraphicsThreadingModel::
00131 get_cull_sorting() const {
00132   return _cull_sorting;
00133 
00134 }
00135 
00136 ////////////////////////////////////////////////////////////////////
00137 //     Function: GraphicsThreadingModel::set_cull_sorting
00138 //       Access: Published
00139 //  Description: Changes the flag that indicates whether the threading
00140 //               model involves a separate cull pass.  This won't
00141 //               change any windows that were already created with
00142 //               this model; this only has an effect on newly-opened
00143 //               windows.
00144 ////////////////////////////////////////////////////////////////////
00145 INLINE void GraphicsThreadingModel::
00146 set_cull_sorting(bool cull_sorting) {
00147   _cull_sorting = cull_sorting;
00148   update_stages();
00149 }
00150 
00151 ////////////////////////////////////////////////////////////////////
00152 //     Function: GraphicsThreadingModel::is_single_threaded
00153 //       Access: Published
00154 //  Description: Returns true if the threading model is a
00155 //               single-threaded model, or false if it involves
00156 //               threads.
00157 ////////////////////////////////////////////////////////////////////
00158 INLINE bool GraphicsThreadingModel::
00159 is_single_threaded() const {
00160   return _cull_name.empty() && _draw_name.empty();
00161 }
00162 
00163 ////////////////////////////////////////////////////////////////////
00164 //     Function: GraphicsThreadingModel::is_default
00165 //       Access: Published
00166 //  Description: Returns true if the threading model is the default,
00167 //               cull-then-draw single-threaded model, or false
00168 //               otherwise.
00169 ////////////////////////////////////////////////////////////////////
00170 INLINE bool GraphicsThreadingModel::
00171 is_default() const {
00172   return is_single_threaded() && _cull_sorting;
00173 }
00174 
00175 
00176 ////////////////////////////////////////////////////////////////////
00177 //     Function: GraphicsThreadingModel::output
00178 //       Access: Published
00179 //  Description: 
00180 ////////////////////////////////////////////////////////////////////
00181 INLINE void GraphicsThreadingModel::
00182 output(ostream &out) const {
00183   out << get_model();
00184 }
00185 
00186 INLINE ostream &
00187 operator << (ostream &out, const GraphicsThreadingModel &threading_model) {
00188   threading_model.output(out);
00189   return out;
00190 }
 All Classes Functions Variables Enumerations