|
@@ -124,6 +124,13 @@ PGItem(const PGItem ©) :
|
|
|
new_sd._frame_style = old_sd._frame_style;
|
|
new_sd._frame_style = old_sd._frame_style;
|
|
|
|
|
|
|
|
_state_defs.push_back(new_sd);
|
|
_state_defs.push_back(new_sd);
|
|
|
|
|
+
|
|
|
|
|
+#ifdef THREADED_PIPELINE
|
|
|
|
|
+ if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
|
|
|
|
|
+ ((PGItem &)copy).update_frame((int)i);
|
|
|
|
|
+ update_frame((int)i);
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -199,8 +206,10 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) {
|
|
|
if (state >= 0 && (size_t)state < _state_defs.size()) {
|
|
if (state >= 0 && (size_t)state < _state_defs.size()) {
|
|
|
StateDef &state_def = _state_defs[state];
|
|
StateDef &state_def = _state_defs[state];
|
|
|
if (!state_def._root.is_empty()) {
|
|
if (!state_def._root.is_empty()) {
|
|
|
- if (state_def._frame_stale) {
|
|
|
|
|
- update_frame(state);
|
|
|
|
|
|
|
+ if (Thread::get_current_pipeline_stage() == 0) {
|
|
|
|
|
+ if (state_def._frame_stale) {
|
|
|
|
|
+ update_frame(state);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
state_def_root = state_def._root.node();
|
|
state_def_root = state_def._root.node();
|
|
@@ -347,9 +356,8 @@ void PGItem::
|
|
|
r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state,
|
|
r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state,
|
|
|
GeomTransformer &transformer, Thread *current_thread) {
|
|
GeomTransformer &transformer, Thread *current_thread) {
|
|
|
LightReMutexHolder holder(_lock);
|
|
LightReMutexHolder holder(_lock);
|
|
|
- StateDefs::iterator di;
|
|
|
|
|
- for (di = _state_defs.begin(); di != _state_defs.end(); ++di) {
|
|
|
|
|
- NodePath &root = (*di)._root;
|
|
|
|
|
|
|
+ for (StateDef &def : _state_defs) {
|
|
|
|
|
+ NodePath &root = def._root;
|
|
|
if (!root.is_empty()) {
|
|
if (!root.is_empty()) {
|
|
|
PandaNode *child = root.node();
|
|
PandaNode *child = root.node();
|
|
|
CPT(RenderState) child_state = node_state->compose(child->get_state());
|
|
CPT(RenderState) child_state = node_state->compose(child->get_state());
|
|
@@ -375,9 +383,9 @@ xform(const LMatrix4 &mat) {
|
|
|
_frame.set(ll[0], ur[0], ll[2], ur[2]);
|
|
_frame.set(ll[0], ur[0], ll[2], ur[2]);
|
|
|
|
|
|
|
|
// Transform the individual states and their frame styles.
|
|
// Transform the individual states and their frame styles.
|
|
|
- StateDefs::iterator di;
|
|
|
|
|
- for (di = _state_defs.begin(); di != _state_defs.end(); ++di) {
|
|
|
|
|
- NodePath &root = (*di)._root;
|
|
|
|
|
|
|
+ for (size_t state = 0; state < _state_defs.size(); ++state) {
|
|
|
|
|
+ StateDef &def = _state_defs[state];
|
|
|
|
|
+ NodePath &root = def._root;
|
|
|
// Apply the matrix to the previous transform.
|
|
// Apply the matrix to the previous transform.
|
|
|
root.set_transform(root.get_transform()->compose(TransformState::make_mat(mat)));
|
|
root.set_transform(root.get_transform()->compose(TransformState::make_mat(mat)));
|
|
|
|
|
|
|
@@ -386,8 +394,16 @@ xform(const LMatrix4 &mat) {
|
|
|
gr.apply_attribs(root.node());
|
|
gr.apply_attribs(root.node());
|
|
|
|
|
|
|
|
// Transform the frame style too.
|
|
// Transform the frame style too.
|
|
|
- if ((*di)._frame_style.xform(mat)) {
|
|
|
|
|
- (*di)._frame_stale = true;
|
|
|
|
|
|
|
+ if (def._frame_style.xform(mat)) {
|
|
|
|
|
+#ifdef THREADED_PIPELINE
|
|
|
|
|
+ if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
|
|
|
|
|
+ update_frame((int)state);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+#endif
|
|
|
|
|
+ {
|
|
|
|
|
+ def._frame_stale = true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
mark_internal_bounds_stale();
|
|
mark_internal_bounds_stale();
|
|
@@ -767,9 +783,7 @@ move(const MouseWatcherParameter ¶m) {
|
|
|
*/
|
|
*/
|
|
|
void PGItem::
|
|
void PGItem::
|
|
|
background_press(const MouseWatcherParameter ¶m) {
|
|
background_press(const MouseWatcherParameter ¶m) {
|
|
|
- BackgroundFocus::const_iterator fi;
|
|
|
|
|
- for (fi = _background_focus.begin(); fi != _background_focus.end(); ++fi) {
|
|
|
|
|
- PGItem *item = *fi;
|
|
|
|
|
|
|
+ for (PGItem *item : _background_focus) {
|
|
|
if (!item->get_focus()) {
|
|
if (!item->get_focus()) {
|
|
|
item->press(param, true);
|
|
item->press(param, true);
|
|
|
}
|
|
}
|
|
@@ -781,9 +795,7 @@ background_press(const MouseWatcherParameter ¶m) {
|
|
|
*/
|
|
*/
|
|
|
void PGItem::
|
|
void PGItem::
|
|
|
background_release(const MouseWatcherParameter ¶m) {
|
|
background_release(const MouseWatcherParameter ¶m) {
|
|
|
- BackgroundFocus::const_iterator fi;
|
|
|
|
|
- for (fi = _background_focus.begin(); fi != _background_focus.end(); ++fi) {
|
|
|
|
|
- PGItem *item = *fi;
|
|
|
|
|
|
|
+ for (PGItem *item : _background_focus) {
|
|
|
if (!item->get_focus()) {
|
|
if (!item->get_focus()) {
|
|
|
item->release(param, true);
|
|
item->release(param, true);
|
|
|
}
|
|
}
|
|
@@ -795,9 +807,7 @@ background_release(const MouseWatcherParameter ¶m) {
|
|
|
*/
|
|
*/
|
|
|
void PGItem::
|
|
void PGItem::
|
|
|
background_keystroke(const MouseWatcherParameter ¶m) {
|
|
background_keystroke(const MouseWatcherParameter ¶m) {
|
|
|
- BackgroundFocus::const_iterator fi;
|
|
|
|
|
- for (fi = _background_focus.begin(); fi != _background_focus.end(); ++fi) {
|
|
|
|
|
- PGItem *item = *fi;
|
|
|
|
|
|
|
+ for (PGItem *item : _background_focus) {
|
|
|
if (!item->get_focus()) {
|
|
if (!item->get_focus()) {
|
|
|
item->keystroke(param, true);
|
|
item->keystroke(param, true);
|
|
|
}
|
|
}
|
|
@@ -809,9 +819,7 @@ background_keystroke(const MouseWatcherParameter ¶m) {
|
|
|
*/
|
|
*/
|
|
|
void PGItem::
|
|
void PGItem::
|
|
|
background_candidate(const MouseWatcherParameter ¶m) {
|
|
background_candidate(const MouseWatcherParameter ¶m) {
|
|
|
- BackgroundFocus::const_iterator fi;
|
|
|
|
|
- for (fi = _background_focus.begin(); fi != _background_focus.end(); ++fi) {
|
|
|
|
|
- PGItem *item = *fi;
|
|
|
|
|
|
|
+ for (PGItem *item : _background_focus) {
|
|
|
if (!item->get_focus()) {
|
|
if (!item->get_focus()) {
|
|
|
item->candidate(param, true);
|
|
item->candidate(param, true);
|
|
|
}
|
|
}
|
|
@@ -952,6 +960,12 @@ clear_state_def(int state) {
|
|
|
_state_defs[state]._frame_stale = true;
|
|
_state_defs[state]._frame_stale = true;
|
|
|
|
|
|
|
|
mark_internal_bounds_stale();
|
|
mark_internal_bounds_stale();
|
|
|
|
|
+
|
|
|
|
|
+#ifdef THREADED_PIPELINE
|
|
|
|
|
+ if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
|
|
|
|
|
+ update_frame(state);
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -991,15 +1005,24 @@ get_frame_style(int state) {
|
|
|
void PGItem::
|
|
void PGItem::
|
|
|
set_frame_style(int state, const PGFrameStyle &style) {
|
|
set_frame_style(int state, const PGFrameStyle &style) {
|
|
|
LightReMutexHolder holder(_lock);
|
|
LightReMutexHolder holder(_lock);
|
|
|
- // Get the state def node, mainly to ensure that this state is slotted and
|
|
|
|
|
- // listed as having been defined.
|
|
|
|
|
- NodePath &root = do_get_state_def(state);
|
|
|
|
|
- nassertv(!root.is_empty());
|
|
|
|
|
|
|
+
|
|
|
|
|
+ slot_state_def(state);
|
|
|
|
|
+
|
|
|
|
|
+ if (_state_defs[state]._root.is_empty()) {
|
|
|
|
|
+ // Create a new node.
|
|
|
|
|
+ _state_defs[state]._root = NodePath("state_" + format_string(state));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
_state_defs[state]._frame_style = style;
|
|
_state_defs[state]._frame_style = style;
|
|
|
_state_defs[state]._frame_stale = true;
|
|
_state_defs[state]._frame_stale = true;
|
|
|
|
|
|
|
|
mark_internal_bounds_stale();
|
|
mark_internal_bounds_stale();
|
|
|
|
|
+
|
|
|
|
|
+#ifdef THREADED_PIPELINE
|
|
|
|
|
+ if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
|
|
|
|
|
+ update_frame(state);
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_AUDIO
|
|
#ifdef HAVE_AUDIO
|
|
@@ -1165,11 +1188,10 @@ mouse_to_local(const LPoint2 &mouse_point) const {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Called when the user changes the frame size.
|
|
|
|
|
|
|
+ * Called when the user changes the frame size. Assumes the lock is held.
|
|
|
*/
|
|
*/
|
|
|
void PGItem::
|
|
void PGItem::
|
|
|
frame_changed() {
|
|
frame_changed() {
|
|
|
- LightReMutexHolder holder(_lock);
|
|
|
|
|
mark_frames_stale();
|
|
mark_frames_stale();
|
|
|
if (_notify != nullptr) {
|
|
if (_notify != nullptr) {
|
|
|
_notify->item_frame_changed(this);
|
|
_notify->item_frame_changed(this);
|
|
@@ -1202,6 +1224,7 @@ do_get_state_def(int state) {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Ensures there is a slot in the array for the given state definition.
|
|
* Ensures there is a slot in the array for the given state definition.
|
|
|
|
|
+ * Assumes the lock is already held.
|
|
|
*/
|
|
*/
|
|
|
void PGItem::
|
|
void PGItem::
|
|
|
slot_state_def(int state) {
|
|
slot_state_def(int state) {
|
|
@@ -1212,6 +1235,7 @@ slot_state_def(int state) {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Generates a new instance of the frame geometry for the indicated state.
|
|
* Generates a new instance of the frame geometry for the indicated state.
|
|
|
|
|
+ * Assumes the lock is already held.
|
|
|
*/
|
|
*/
|
|
|
void PGItem::
|
|
void PGItem::
|
|
|
update_frame(int state) {
|
|
update_frame(int state) {
|
|
@@ -1234,15 +1258,26 @@ update_frame(int state) {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Marks all the frames in all states stale, so that they will be regenerated
|
|
* Marks all the frames in all states stale, so that they will be regenerated
|
|
|
- * the next time each state is requested.
|
|
|
|
|
|
|
+ * the next time each state is requested. Assumes the lock is already held.
|
|
|
*/
|
|
*/
|
|
|
void PGItem::
|
|
void PGItem::
|
|
|
mark_frames_stale() {
|
|
mark_frames_stale() {
|
|
|
- StateDefs::iterator di;
|
|
|
|
|
- for (di = _state_defs.begin(); di != _state_defs.end(); ++di) {
|
|
|
|
|
- // Remove the old frame, if any.
|
|
|
|
|
- (*di)._frame.remove_node();
|
|
|
|
|
- (*di)._frame_stale = true;
|
|
|
|
|
|
|
+#ifdef THREADED_PIPELINE
|
|
|
|
|
+ // If we are using the threaded pipeline, we must update the frame geometry
|
|
|
|
|
+ // immediately on the App thread, since this class isn't pipeline-cycled.
|
|
|
|
|
+ if (Pipeline::get_render_pipeline()->get_num_stages() > 1) {
|
|
|
|
|
+ for (int state = 0; state < (int)_state_defs.size(); ++state) {
|
|
|
|
|
+ update_frame(state);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+#endif
|
|
|
|
|
+ {
|
|
|
|
|
+ for (StateDef &def : _state_defs) {
|
|
|
|
|
+ // Remove the old frame, if any.
|
|
|
|
|
+ def._frame.remove_node();
|
|
|
|
|
+ def._frame_stale = true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
mark_internal_bounds_stale();
|
|
mark_internal_bounds_stale();
|
|
|
}
|
|
}
|
|
@@ -1294,9 +1329,8 @@ clip_frame(ClipPoints &source_points, const LPlane &plane) const {
|
|
|
LPoint2 last_point(source_points.back());
|
|
LPoint2 last_point(source_points.back());
|
|
|
bool last_is_in = is_right(last_point - from2d, delta2d);
|
|
bool last_is_in = is_right(last_point - from2d, delta2d);
|
|
|
bool all_in = last_is_in;
|
|
bool all_in = last_is_in;
|
|
|
- ClipPoints::const_iterator pi;
|
|
|
|
|
- for (pi = source_points.begin(); pi != source_points.end(); ++pi) {
|
|
|
|
|
- LPoint2 this_point(*pi);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ for (LPoint2 this_point : source_points) {
|
|
|
bool this_is_in = is_right(this_point - from2d, delta2d);
|
|
bool this_is_in = is_right(this_point - from2d, delta2d);
|
|
|
|
|
|
|
|
// There appears to be a compiler bug in gcc 4.0: we need to extract this
|
|
// There appears to be a compiler bug in gcc 4.0: we need to extract this
|