Merge branch 'release/1.10.x'

This commit is contained in:
rdb 2021-07-02 16:03:41 +02:00
commit 0c5fedfc9b
7 changed files with 54 additions and 7 deletions

View File

@ -746,6 +746,14 @@ get_num_unused_states() {
for (size_t si = 0; si < size; ++si) {
const RenderState *state = _states.get_key(si);
std::pair<StateCount::iterator, bool> ir =
state_count.insert(StateCount::value_type(state, 1));
if (!ir.second) {
// If the above insert operation fails, then it's already in the
// cache; increment its value.
(*(ir.first)).second++;
}
size_t i;
size_t cache_size = state->_composition_cache.get_num_entries();
for (i = 0; i < cache_size; ++i) {
@ -1843,6 +1851,7 @@ init_states() {
// is declared globally, and lives forever.
RenderState *state = new RenderState;
state->local_object();
state->cache_ref_only();
state->_saved_entry = _states.store(state, nullptr);
_empty_state = state;
}

View File

@ -145,6 +145,7 @@ PUBLISHED:
static void list_states(std::ostream &out);
static bool validate_states();
EXTENSION(static PyObject *get_states());
EXTENSION(static PyObject *get_unused_states());
PUBLISHED:
// These methods are intended for use by low-level code, but they're also

View File

@ -139,4 +139,29 @@ get_states() {
return list;
}
/**
* Returns a list of all of the "unused" RenderState objects in the state
* cache. See get_num_unused_states().
*/
PyObject *Extension<RenderState>::
get_unused_states() {
extern struct Dtool_PyTypedObject Dtool_RenderState;
LightReMutexHolder holder(*RenderState::_states_lock);
PyObject *list = PyList_New(0);
size_t size = RenderState::_states.get_num_entries();
for (size_t si = 0; si < size; ++si) {
const RenderState *state = RenderState::_states.get_key(si);
if (state->get_cache_ref_count() == state->get_ref_count()) {
state->ref();
PyObject *a =
DTool_CreatePyInstanceTyped((void *)state, Dtool_RenderState,
true, true, state->get_type_index());
PyList_Append(list, a);
Py_DECREF(a);
}
}
return list;
}
#endif // HAVE_PYTHON

View File

@ -32,6 +32,7 @@ public:
PyObject *get_composition_cache() const;
PyObject *get_invert_composition_cache() const;
static PyObject *get_states();
static PyObject *get_unused_states();
};
#endif // HAVE_PYTHON

View File

@ -1017,6 +1017,14 @@ get_num_unused_states() {
for (size_t si = 0; si < size; ++si) {
const TransformState *state = _states.get_key(si);
std::pair<StateCount::iterator, bool> ir =
state_count.insert(StateCount::value_type(state, 1));
if (!ir.second) {
// If the above insert operation fails, then it's already in the
// cache; increment its value.
(*(ir.first)).second++;
}
size_t i;
size_t cache_size = state->_composition_cache.get_num_entries();
for (i = 0; i < cache_size; ++i) {

View File

@ -860,12 +860,15 @@ set_properties_now(WindowProperties &properties) {
int value_mask = 0;
if (_properties.get_fullscreen()) {
changes.x = 0;
changes.y = 0;
value_mask |= CWX | CWY;
properties.clear_origin();
} else if (properties.has_origin()) {
if (_properties.get_x_origin() != 0 ||
_properties.get_y_origin() != 0) {
changes.x = 0;
changes.y = 0;
value_mask |= CWX | CWY;
properties.clear_origin();
}
}
else if (properties.has_origin()) {
changes.x = properties.get_x_origin();
changes.y = properties.get_y_origin();
if (changes.x != -1) value_mask |= CWX;

View File

@ -619,7 +619,7 @@ load_mesh(size_t index) {
PT(GeomVertexArrayFormat) aformat = new GeomVertexArrayFormat;
aformat->add_column(InternalName::get_vertex(), 3, Geom::NT_stdfloat, Geom::C_point);
if (mesh.HasNormals()) {
aformat->add_column(InternalName::get_normal(), 3, Geom::NT_stdfloat, Geom::C_vector);
aformat->add_column(InternalName::get_normal(), 3, Geom::NT_stdfloat, Geom::C_normal);
}
if (mesh.HasVertexColors(0)) {
aformat->add_column(InternalName::get_color(), 4, Geom::NT_stdfloat, Geom::C_color);