diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-06-09 22:17:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-06-09 22:17:33 +0300 |
commit | a15180669891dcb4f0a4dff891e8a129b3788776 (patch) | |
tree | 3907a8c7a4dc3afc3289e57dba93e0fbf9514fd9 /source | |
parent | 10d57f991b06ae7c0a0b5e492eec8c7163debf80 (diff) | |
parent | d733826708f9b562687b78424e5c0835cba8c3c9 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source')
50 files changed, 712 insertions, 296 deletions
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 41726e41176..aa7d539538b 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -55,6 +55,10 @@ #include "BIF_gl.h" #include "BLF_api.h" +#ifndef BLF_STANDALONE +#include "GPU_basic_shader.h" +#endif + #include "blf_internal_types.h" #include "blf_internal.h" @@ -179,6 +183,16 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); +#ifndef BLF_STANDALONE + /* needed since basic shader doesn't support alpha-only textures, + * while we could add support this is only used in a few places + * (an alternative could be to have a simple shader for BLF). */ + if (GLEW_ARB_texture_swizzle && GPU_basic_shader_use_glsl_get()) { + GLint swizzle_mask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA}; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle_mask); + } +#endif + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA8, gc->p2_width, gc->p2_height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL); } diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index e30dbd706a3..6b81c47765b 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -1181,6 +1181,10 @@ static void emDM_drawMappedFaces( /* if non zero we know a face was rendered */ if (poly_prev != GL_ZERO) glEnd(); + + if (draw_option_prev == DM_DRAW_OPTION_STIPPLE) { + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); + } } static void bmdm_get_tri_uv(BMLoop *ltri[3], MLoopUV *luv[3], const int cd_loop_uv_offset) diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index aed33d2c64d..98757407e89 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -541,7 +541,7 @@ int BKE_vfont_select_get(Object *ob, int *r_start, int *r_end) BLI_assert(ef->len >= 0); BLI_assert(ef->selstart >= 0 && ef->selstart <= ef->len + 1); - BLI_assert(ef->selend >= 0 && ef->selend <= ef->len); + BLI_assert(ef->selend >= 0 && ef->selend <= ef->len + 1); BLI_assert(ef->pos >= 0 && ef->pos <= ef->len); if (ef->selstart == 0) { diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index a8d3c600817..d2bfcfb0887 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -608,7 +608,7 @@ static MovieClip *movieclip_alloc(Main *bmain, const char *name) return clip; } -static void movieclip_load_get_szie(MovieClip *clip) +static void movieclip_load_get_size(MovieClip *clip) { int width, height; MovieClipUser user = {0}; @@ -670,7 +670,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name) detect_clip_source(clip); - movieclip_load_get_szie(clip); + movieclip_load_get_size(clip); if (clip->lastsize[0]) { int width = clip->lastsize[0]; @@ -1276,7 +1276,7 @@ void BKE_movieclip_reload(MovieClip *clip) detect_clip_source(clip); clip->lastsize[0] = clip->lastsize[1] = 0; - movieclip_load_get_szie(clip); + movieclip_load_get_size(clip); movieclip_calc_length(clip); diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c index 3c2444b0ef1..a40e4f72636 100644 --- a/source/blender/blenkernel/intern/tracking_util.c +++ b/source/blender/blenkernel/intern/tracking_util.c @@ -529,7 +529,7 @@ typedef struct AccessCacheKey { static unsigned int accesscache_hashhash(const void *key_v) { const AccessCacheKey *key = (const AccessCacheKey *) key_v; - /* TODP(sergey): Need better hasing here for faster frame access. */ + /* TODP(sergey): Need better hashing here for faster frame access. */ return key->clip_index << 16 | key->frame; } diff --git a/source/blender/blenlib/BLI_array_store_utils.h b/source/blender/blenlib/BLI_array_store_utils.h new file mode 100644 index 00000000000..6b2a28846f4 --- /dev/null +++ b/source/blender/blenlib/BLI_array_store_utils.h @@ -0,0 +1,50 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BLI_ARRAY_STORE_UTILS_H__ +#define __BLI_ARRAY_STORE_UTILS_H__ + +/** \file BLI_array_store_utils.h + * \ingroup bli + */ + +struct BArrayStore; + +struct BArrayStore_AtSize { + struct BArrayStore **stride_table; + int stride_table_len; +}; + +BArrayStore *BLI_array_store_at_size_ensure( + struct BArrayStore_AtSize *bs_stride, + const int stride, const int chunk_size); + +BArrayStore *BLI_array_store_at_size_get( + struct BArrayStore_AtSize *bs_stride, + const int stride); + +void BLI_array_store_at_size_clear( + struct BArrayStore_AtSize *bs_stride); + +void BLI_array_store_at_size_calc_memory_usage( + struct BArrayStore_AtSize *bs_stride, + size_t *r_size_expanded, size_t *r_size_compacted); + +#endif /* __BLI_ARRAY_STORE_UTILS_H__ */ diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 42d958774d8..9978d1d19af 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -53,6 +53,7 @@ set(SRC intern/BLI_mempool.c intern/DLRB_tree.c intern/array_store.c + intern/array_store_utils.c intern/array_utils.c intern/astar.c intern/boxpack2d.c @@ -122,6 +123,7 @@ set(SRC BLI_args.h BLI_array.h BLI_array_store.h + BLI_array_store_utils.h BLI_array_utils.h BLI_astar.h BLI_bitmap.h diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 06946e520a8..f943a8119c4 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -69,7 +69,7 @@ const unsigned int hashsizes[] = { /** * \note Max load #GHASH_LIMIT_GROW used to be 3. (pre 2.74). - * Python uses 0.6666, tommyhaslib even goes down to 0.5. + * Python uses 0.6666, tommyhashlib even goes down to 0.5. * Reducing our from 3 to 0.75 gives huge speedup (about twice quicker pure GHash insertions/lookup, * about 25% - 30% quicker 'dynamic-topology' stroke drawing e.g.). * Min load #GHASH_LIMIT_SHRINK is a quarter of max load, to avoid resizing to quickly. diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c index b7a51f2c48e..783dba5510c 100644 --- a/source/blender/blenlib/intern/BLI_mempool.c +++ b/source/blender/blenlib/intern/BLI_mempool.c @@ -622,7 +622,7 @@ void *BLI_mempool_iterstep(BLI_mempool_iter *iter) iter->curindex = 0; iter->curchunk = iter->curchunk->next; if (iter->curchunk == NULL) { - return NULL; + return (ret->freeword == FREEWORD) ? NULL : ret; } curnode = CHUNK_DATA(iter->curchunk); } diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c index 9baccf38fa3..33565596c1f 100644 --- a/source/blender/blenlib/intern/array_store.c +++ b/source/blender/blenlib/intern/array_store.c @@ -36,7 +36,7 @@ * * This diagram is an overview of the structure of a single array-store. * - * \note The only 2 structues here which are referenced externally are the. + * \note The only 2 structures here which are referenced externally are the. * * - BArrayStore: The whole array store. * - BArrayState: Represents a single state (array) of data. @@ -92,7 +92,7 @@ * First matches at either end of the array are detected. * For identical arrays this is all thats needed. * - * De-duplication is performed on any remaining chunks, by hasing the first few bytes of the chunk + * De-duplication is performed on any remaining chunks, by hashing the first few bytes of the chunk * (see: BCHUNK_HASH_TABLE_ACCUMULATE_STEPS). * * \note This is cached for reuse since the referenced data never changes. @@ -650,7 +650,7 @@ static void bchunk_list_append_data( * Use for adding arrays of arbitrary sized memory at once. * * \note This function takes care not to perform redundant chunk-merging checks, - * so we can write succesive fixed size chunks quickly. + * so we can write successive fixed size chunks quickly. */ static void bchunk_list_append_data_n( const BArrayInfo *info, BArrayMemory *bs_mem, @@ -1680,7 +1680,7 @@ void *BLI_array_store_state_data_get_alloc( /** \} */ -/** \name Debigging API (for testing). +/** \name Debugging API (for testing). * \{ */ /* only for test validation */ diff --git a/source/blender/blenlib/intern/array_store_utils.c b/source/blender/blenlib/intern/array_store_utils.c new file mode 100644 index 00000000000..83cd28ddf11 --- /dev/null +++ b/source/blender/blenlib/intern/array_store_utils.c @@ -0,0 +1,103 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenlib/intern/array_store_utils.c + * \ingroup bli + * \brief Helper functions for BLI_array_store API. + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" + +#include "BLI_array_store.h" +#include "BLI_array_store_utils.h" /* own include */ + +#include "BLI_math_base.h" + +BArrayStore *BLI_array_store_at_size_ensure( + struct BArrayStore_AtSize *bs_stride, + const int stride, const int chunk_size) +{ + if (bs_stride->stride_table_len < stride) { + bs_stride->stride_table_len = stride; + bs_stride->stride_table = MEM_recallocN(bs_stride->stride_table, sizeof(*bs_stride->stride_table) * stride); + } + BArrayStore **bs_p = &bs_stride->stride_table[stride - 1]; + + if ((*bs_p) == NULL) { +#if 0 + unsigned int chunk_count = chunk_size; +#else + /* calculate best chunk-count to fit a power of two */ + unsigned int chunk_count = chunk_size; + { + unsigned int size = chunk_count * stride; + size = power_of_2_max_u(size); + size = MEM_SIZE_OPTIMAL(size); + chunk_count = size / stride; + } +#endif + + (*bs_p) = BLI_array_store_create(stride, chunk_count); + } + return *bs_p; +} + +BArrayStore *BLI_array_store_at_size_get( + struct BArrayStore_AtSize *bs_stride, + const int stride) +{ + BLI_assert(stride > 0 && stride <= bs_stride->stride_table_len); + return bs_stride->stride_table[stride - 1]; +} + +void BLI_array_store_at_size_clear( + struct BArrayStore_AtSize *bs_stride) +{ + for (int i = 0; i < bs_stride->stride_table_len; i += 1) { + if (bs_stride->stride_table[i]) { + BLI_array_store_destroy(bs_stride->stride_table[i]); + } + } + + MEM_freeN(bs_stride->stride_table); + bs_stride->stride_table = NULL; + bs_stride->stride_table_len = 0; +} + + +void BLI_array_store_at_size_calc_memory_usage( + struct BArrayStore_AtSize *bs_stride, + size_t *r_size_expanded, size_t *r_size_compacted) +{ + size_t size_compacted = 0; + size_t size_expanded = 0; + for (int i = 0; i < bs_stride->stride_table_len; i++) { + BArrayStore *bs = bs_stride->stride_table[i]; + if (bs) { + size_compacted += BLI_array_store_calc_size_compacted_get(bs); + size_expanded += BLI_array_store_calc_size_expanded_get(bs); + } + } + + *r_size_expanded = size_expanded; + *r_size_compacted = size_compacted; +} diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c index 180d62105c4..abb8ff35a45 100644 --- a/source/blender/blenlib/intern/math_color_inline.c +++ b/source/blender/blenlib/intern/math_color_inline.c @@ -65,7 +65,7 @@ MALWAYS_INLINE __m128 linearrgb_to_srgb_v4_simd(const __m128 c) MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3]) { - float r[4] = {srgb[0], srgb[1], srgb[2], 0.0f}; + float r[4] = {srgb[0], srgb[1], srgb[2], 1.0f}; __m128 *rv = (__m128 *)&r; *rv = srgb_to_linearrgb_v4_simd(*rv); linear[0] = r[0]; @@ -75,7 +75,7 @@ MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3]) MINLINE void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3]) { - float r[4] = {linear[0], linear[1], linear[2], 0.0f}; + float r[4] = {linear[0], linear[1], linear[2], 1.0f}; __m128 *rv = (__m128 *)&r; *rv = linearrgb_to_srgb_v4_simd(*rv); srgb[0] = r[0]; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index ced53bdf2e4..cd150b2b70e 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1181,11 +1181,12 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *ob, OperationKey done_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); add_relation(solver_key, done_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Result"); + } else { + OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); + add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "IK Solver Result"); } parchan->flag |= POSE_DONE; - OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE); - add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "IK Solver Result"); root_map->add_bone(parchan->name, rootchan->name); diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 30d243867b0..fda665b0db4 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -80,11 +80,12 @@ static void flush_init_func(void *data_v, int i) */ Depsgraph *graph = (Depsgraph *)data_v; OperationDepsNode *node = graph->operations[i]; - IDDepsNode *id_node = node->owner->owner; + ComponentDepsNode *comp_node = node->owner; + IDDepsNode *id_node = comp_node->owner; id_node->done = 0; + comp_node->done = 0; node->scheduled = false; - node->owner->flags &= ~DEPSCOMP_FULLY_SCHEDULED; - if (node->owner->type == DEPSNODE_TYPE_PROXY) { + if (comp_node->type == DEPSNODE_TYPE_PROXY) { node->flag |= DEPSOP_FLAG_NEEDS_UPDATE; } } @@ -136,49 +137,10 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph) for (;;) { node->flag |= DEPSOP_FLAG_NEEDS_UPDATE; - IDDepsNode *id_node = node->owner->owner; - - if (id_node->done == 0) { - deg_editors_id_update(bmain, id_node->id); - id_node->done = 1; - } - - lib_id_recalc_tag(bmain, id_node->id); - /* TODO(sergey): For until we've got proper data nodes in the graph. */ - lib_id_recalc_data_tag(bmain, id_node->id); - - ID *id = id_node->id; - /* This code is used to preserve those areas which does direct - * object update, - * - * Plus it ensures visibility changes and relations and layers - * visibility update has proper flags to work with. - */ - if (GS(id->name) == ID_OB) { - Object *object = (Object *)id; - ComponentDepsNode *comp_node = node->owner; - if (comp_node->type == DEPSNODE_TYPE_ANIMATION) { - object->recalc |= OB_RECALC_TIME; - } - else if (comp_node->type == DEPSNODE_TYPE_TRANSFORM) { - object->recalc |= OB_RECALC_OB; - } - else { - object->recalc |= OB_RECALC_DATA; - } - } - - /* TODO(sergey): For until incremental updates are possible - * witin a component at least we tag the whole component - * for update. - */ - ComponentDepsNode *component = node->owner; - if ((component->flags & DEPSCOMP_FULLY_SCHEDULED) == 0) { - foreach (OperationDepsNode *op, component->operations) { - op->flag |= DEPSOP_FLAG_NEEDS_UPDATE; - } - component->flags |= DEPSCOMP_FULLY_SCHEDULED; - } + ComponentDepsNode *comp_node = node->owner; + IDDepsNode *id_node = comp_node->owner; + id_node->done = 1; + comp_node->done = 1; /* Flush to nodes along links... */ if (node->outlinks.size() == 1) { @@ -203,6 +165,52 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph) } } } + + GHASH_FOREACH_BEGIN(DEG::IDDepsNode *, id_node, graph->id_hash) + { + if (id_node->done == 1) { + ID *id = id_node->id; + Object *object = NULL; + + if (GS(id->name) == ID_OB) { + object = (Object *)id; + } + + deg_editors_id_update(bmain, id_node->id); + + lib_id_recalc_tag(bmain, id_node->id); + /* TODO(sergey): For until we've got proper data nodes in the graph. */ + lib_id_recalc_data_tag(bmain, id_node->id); + + GHASH_FOREACH_BEGIN(const ComponentDepsNode *, comp_node, id_node->components) + { + if (comp_node->done) { + foreach (OperationDepsNode *op, comp_node->operations) { + op->flag |= DEPSOP_FLAG_NEEDS_UPDATE; + } + if (object != NULL) { + /* This code is used to preserve those areas which does + * direct object update, + * + * Plus it ensures visibility changes and relations and + * layers visibility update has proper flags to work with. + */ + if (comp_node->type == DEPSNODE_TYPE_ANIMATION) { + object->recalc |= OB_RECALC_TIME; + } + else if (comp_node->type == DEPSNODE_TYPE_TRANSFORM) { + object->recalc |= OB_RECALC_OB; + } + else { + object->recalc |= OB_RECALC_DATA; + } + } + } + } + GHASH_FOREACH_END(); + } + } + GHASH_FOREACH_END(); } static void graph_clear_func(void *data_v, int i) diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc index 7e49fec051f..8e74317cfa2 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc @@ -86,7 +86,6 @@ static void comp_node_hash_value_free(void *value_v) ComponentDepsNode::ComponentDepsNode() : entry_operation(NULL), exit_operation(NULL), - flags(0), layers(0) { operations_map = BLI_ghash_new(comp_node_hash_key, diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h index df321ea9299..6ff4345d28b 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h @@ -47,13 +47,6 @@ struct Depsgraph; struct OperationDepsNode; struct BoneComponentDepsNode; -typedef enum eDepsComponent_Flag { - /* Temporary flags, meaning all the component's operations has been - * scheduled for update. - */ - DEPSCOMP_FULLY_SCHEDULED = 1, -} eDepsComponent_Flag; - /* ID Component - Base type for all components */ struct ComponentDepsNode : public DepsNode { /* Key used to look up operations within a component */ @@ -165,8 +158,6 @@ struct ComponentDepsNode : public DepsNode { // XXX: a poll() callback to check if component's first node can be started? - int flags; - /* Temporary bitmask, used during graph construction. */ int layers; }; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 172f2b9069e..66b3a63c669 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -2035,7 +2035,7 @@ bool autokeyframe_cfra_can_key(Scene *scene, ID *id) else { /* Normal Mode (or treat as being normal mode): * - * Just in case the flags are't set properly (i.e. only on/off is set, without a mode) + * Just in case the flags aren't set properly (i.e. only on/off is set, without a mode) * let's set the "normal" flag too, so that it will all be sane everywhere... */ scene->toolsettings->autokey_mode = AUTOKEY_MODE_NORMAL; diff --git a/source/blender/editors/curve/CMakeLists.txt b/source/blender/editors/curve/CMakeLists.txt index ebdf6bb43ff..2f5b2ab6e87 100644 --- a/source/blender/editors/curve/CMakeLists.txt +++ b/source/blender/editors/curve/CMakeLists.txt @@ -43,6 +43,7 @@ set(SRC editcurve_paint.c editcurve_select.c editfont.c + editfont_undo.c curve_intern.h ) diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 7c1fe0cadf0..053a7ee5023 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1794,64 +1794,6 @@ void FONT_OT_unlink(wmOperatorType *ot) ot->exec = font_unlink_exec; } - -/* **************** undo for font object ************** */ - -static void undoFont_to_editFont(void *strv, void *ecu, void *UNUSED(obdata)) -{ - Curve *cu = (Curve *)ecu; - EditFont *ef = cu->editfont; - const char *str = strv; - - ef->pos = *((const short *)str); - ef->len = *((const short *)(str + 2)); - - memcpy(ef->textbuf, str + 4, (ef->len + 1) * sizeof(wchar_t)); - memcpy(ef->textbufinfo, str + 4 + (ef->len + 1) * sizeof(wchar_t), ef->len * sizeof(CharInfo)); - - ef->selstart = ef->selend = 0; - -} - -static void *editFont_to_undoFont(void *ecu, void *UNUSED(obdata)) -{ - Curve *cu = (Curve *)ecu; - EditFont *ef = cu->editfont; - char *str; - - /* The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo */ - str = MEM_callocN((MAXTEXT + 6) * sizeof(wchar_t) + (MAXTEXT + 4) * sizeof(CharInfo), "string undo"); - - /* Copy the string and string information */ - memcpy(str + 4, ef->textbuf, (ef->len + 1) * sizeof(wchar_t)); - memcpy(str + 4 + (ef->len + 1) * sizeof(wchar_t), ef->textbufinfo, ef->len * sizeof(CharInfo)); - - *((short *)(str + 0)) = ef->pos; - *((short *)(str + 2)) = ef->len; - - return str; -} - -static void free_undoFont(void *strv) -{ - MEM_freeN(strv); -} - -static void *get_undoFont(bContext *C) -{ - Object *obedit = CTX_data_edit_object(C); - if (obedit && obedit->type == OB_FONT) { - return obedit->data; - } - return NULL; -} - -/* and this is all the undo system needs to know */ -void undo_push_font(bContext *C, const char *name) -{ - undo_editmode_push(C, name, get_undoFont, free_undoFont, undoFont_to_editFont, editFont_to_undoFont, NULL); -} - /** * TextBox selection */ diff --git a/source/blender/editors/curve/editfont_undo.c b/source/blender/editors/curve/editfont_undo.c new file mode 100644 index 00000000000..a0453f9694d --- /dev/null +++ b/source/blender/editors/curve/editfont_undo.c @@ -0,0 +1,311 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/curve/editfont_undo.c + * \ingroup edcurve + */ + +#include <stdlib.h> +#include <string.h> +#include <wchar.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" + +#include "DNA_curve_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "BKE_context.h" +#include "BKE_font.h" + +#include "ED_curve.h" +#include "ED_util.h" + +#define USE_ARRAY_STORE + +#ifdef USE_ARRAY_STORE +// # define DEBUG_PRINT +# include "BLI_array_store.h" +# include "BLI_array_store_utils.h" +# include "BLI_listbase.h" +# define ARRAY_CHUNK_SIZE 32 +#endif + +typedef struct UndoFont { + wchar_t *textbuf; + struct CharInfo *textbufinfo; + + int len, pos; + +#ifdef USE_ARRAY_STORE + struct { + BArrayState *textbuf; + BArrayState *textbufinfo; + } store; +#endif +} UndoFont; + + +#ifdef USE_ARRAY_STORE + +/** \name Array Store + * \{ */ + +static struct { + struct BArrayStore_AtSize bs_stride; + int users; + + /* We could have the undo API pass in the previous state, for now store a local list */ + ListBase local_links; + +} uf_arraystore = {NULL}; + +/** + * \param create: When false, only free the arrays. + * This is done since when reading from an undo state, they must be temporarily expanded. + * then discarded afterwards, having this argument avoids having 2x code paths. + */ +static void uf_arraystore_compact_ex( + UndoFont *uf, const UndoFont *uf_ref, + bool create) +{ +#define STATE_COMPACT(uf, id, len) \ + if ((uf)->id) { \ + BLI_assert(create == ((uf)->store.id == NULL)); \ + if (create) { \ + BArrayState *state_reference = uf_ref ? uf_ref->store.id : NULL; \ + const size_t stride = sizeof(*(uf)->id); \ + BArrayStore *bs = BLI_array_store_at_size_ensure(&uf_arraystore.bs_stride, stride, ARRAY_CHUNK_SIZE); \ + (uf)->store.id = BLI_array_store_state_add( \ + bs, (uf)->id, (size_t)(len) * stride, state_reference); \ + } \ + /* keep uf->len for validation */ \ + MEM_freeN((uf)->id); \ + (uf)->id = NULL; \ + } ((void)0) + + STATE_COMPACT(uf, textbuf, uf->len + 1); + STATE_COMPACT(uf, textbufinfo, uf->len + 1); + +#undef STATE_COMPACT + + if (create) { + uf_arraystore.users += 1; + } +} + +/** + * Move data from allocated arrays to de-duplicated states and clear arrays. + */ +static void uf_arraystore_compact(UndoFont *um, const UndoFont *uf_ref) +{ + uf_arraystore_compact_ex(um, uf_ref, true); +} + +static void uf_arraystore_compact_with_info(UndoFont *um, const UndoFont *uf_ref) +{ +#ifdef DEBUG_PRINT + size_t size_expanded_prev, size_compacted_prev; + BLI_array_store_at_size_calc_memory_usage(&uf_arraystore.bs_stride, &size_expanded_prev, &size_compacted_prev); +#endif + + uf_arraystore_compact(um, uf_ref); + +#ifdef DEBUG_PRINT + { + size_t size_expanded, size_compacted; + BLI_array_store_at_size_calc_memory_usage(&uf_arraystore.bs_stride, &size_expanded, &size_compacted); + + const double percent_total = size_expanded ? + (((double)size_compacted / (double)size_expanded) * 100.0) : -1.0; + + size_t size_expanded_step = size_expanded - size_expanded_prev; + size_t size_compacted_step = size_compacted - size_compacted_prev; + const double percent_step = size_expanded_step ? + (((double)size_compacted_step / (double)size_expanded_step) * 100.0) : -1.0; + + printf("overall memory use: %.8f%% of expanded size\n", percent_total); + printf("step memory use: %.8f%% of expanded size\n", percent_step); + } +#endif +} + +/** + * Remove data we only expanded for temporary use. + */ +static void uf_arraystore_expand_clear(UndoFont *um) +{ + uf_arraystore_compact_ex(um, NULL, false); +} + +static void uf_arraystore_expand(UndoFont *uf) +{ +#define STATE_EXPAND(uf, id, len) \ + if ((uf)->store.id) { \ + const size_t stride = sizeof(*(uf)->id); \ + BArrayState *state = (uf)->store.id; \ + size_t state_len; \ + (uf)->id = BLI_array_store_state_data_get_alloc(state, &state_len); \ + BLI_assert((len) == (state_len / stride)); \ + UNUSED_VARS_NDEBUG(stride); \ + } ((void)0) + + STATE_EXPAND(uf, textbuf, uf->len + 1); + STATE_EXPAND(uf, textbufinfo, uf->len + 1); + +#undef STATE_EXPAND +} + +static void uf_arraystore_free(UndoFont *uf) +{ +#define STATE_FREE(uf, id) \ + if ((uf)->store.id) { \ + const size_t stride = sizeof(*(uf)->id); \ + BArrayStore *bs = BLI_array_store_at_size_get(&uf_arraystore.bs_stride, stride); \ + BArrayState *state = (uf)->store.id; \ + BLI_array_store_state_remove(bs, state); \ + (uf)->store.id = NULL; \ + } ((void)0) + + STATE_FREE(uf, textbuf); + STATE_FREE(uf, textbufinfo); + +#undef STATE_FREE + + uf_arraystore.users -= 1; + + BLI_assert(uf_arraystore.users >= 0); + + if (uf_arraystore.users == 0) { +#ifdef DEBUG_PRINT + printf("editfont undo store: freeing all data!\n"); +#endif + + BLI_array_store_at_size_clear(&uf_arraystore.bs_stride); + } + +} + +/** \} */ + +#endif /* USE_ARRAY_STORE */ + +static void undoFont_to_editFont(void *uf_v, void *ecu, void *UNUSED(obdata)) +{ + Curve *cu = (Curve *)ecu; + EditFont *ef = cu->editfont; + const UndoFont *uf = uf_v; + + size_t final_size; + +#ifdef USE_ARRAY_STORE + uf_arraystore_expand(uf_v); +#endif + + final_size = sizeof(wchar_t) * (uf->len + 1); + memcpy(ef->textbuf, uf->textbuf, final_size); + + final_size = sizeof(CharInfo) * (uf->len + 1); + memcpy(ef->textbufinfo, uf->textbufinfo, final_size); + + ef->pos = uf->pos; + ef->len = uf->len; + + ef->selstart = ef->selend = 0; + +#ifdef USE_ARRAY_STORE + uf_arraystore_expand_clear(uf_v); +#endif +} + +static void *editFont_to_undoFont(void *ecu, void *UNUSED(obdata)) +{ + Curve *cu = (Curve *)ecu; + EditFont *ef = cu->editfont; + + UndoFont *uf = MEM_callocN(sizeof(*uf), __func__); + + size_t final_size; + + final_size = sizeof(wchar_t) * (ef->len + 1); + uf->textbuf = MEM_mallocN(final_size, __func__); + memcpy(uf->textbuf, ef->textbuf, final_size); + + final_size = sizeof(CharInfo) * (ef->len + 1); + uf->textbufinfo = MEM_mallocN(final_size, __func__); + memcpy(uf->textbufinfo, ef->textbufinfo, final_size); + + uf->pos = ef->pos; + uf->len = ef->len; + +#ifdef USE_ARRAY_STORE + { + const UndoFont *uf_ref = uf_arraystore.local_links.last ? + ((LinkData *)uf_arraystore.local_links.last)->data : NULL; + + /* add oursrlves */ + BLI_addtail(&uf_arraystore.local_links, BLI_genericNodeN(uf)); + + uf_arraystore_compact_with_info(uf, uf_ref); + } +#endif + + return uf; +} + +static void free_undoFont(void *uf_v) +{ + UndoFont *uf = uf_v; + +#ifdef USE_ARRAY_STORE + { + LinkData *link = BLI_findptr(&uf_arraystore.local_links, uf, offsetof(LinkData, data)); + BLI_remlink(&uf_arraystore.local_links, link); + MEM_freeN(link); + } + uf_arraystore_free(uf); +#endif + + if (uf->textbuf) { + MEM_freeN(uf->textbuf); + } + if (uf->textbufinfo) { + MEM_freeN(uf->textbufinfo); + } + + MEM_freeN(uf); +} + +static void *get_undoFont(bContext *C) +{ + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_FONT) { + return obedit->data; + } + return NULL; +} + +/* and this is all the undo system needs to know */ +void undo_push_font(bContext *C, const char *name) +{ + undo_editmode_push(C, name, get_undoFont, free_undoFont, undoFont_to_editFont, editFont_to_undoFont, NULL); +} diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index 0ac5c17a552..d3d2c465d46 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -94,6 +94,7 @@ void glutil_draw_filled_arc(float start, float angle, float radius, int nsegment * The param must cause only one value to be gotten from GL. */ float glaGetOneFloat(int param); +int glaGetOneInt(int param); /** * Functions like glRasterPos2i, except ensures that the resulting diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 05ac39b9879..eacf769270b 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -606,7 +606,7 @@ typedef enum eAnimUnitConv_Flags { ANIM_UNITCONV_SKIPKNOTS = (1 << 4), /* Scale FCurve i a way it fits to -1..1 space */ ANIM_UNITCONV_NORMALIZE = (1 << 5), - /* Only whennormalization is used: use scale factor from previous run, + /* Only when normalization is used: use scale factor from previous run, * prevents curves from jumping all over the place when tweaking them. */ ANIM_UNITCONV_NORMALIZE_FREEZE = (1 << 6), diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index 278e3f97ba7..859d45e9c86 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -72,8 +72,7 @@ void ED_curve_deselect_all(struct EditNurb *editnurb); void ED_curve_select_all(struct EditNurb *editnurb); void ED_curve_select_swap(struct EditNurb *editnurb, bool hide_handles); -/* editfont.h */ -void undo_push_font(struct bContext *C, const char *name); +/* editfont.c */ void ED_curve_editfont_load(struct Object *obedit); void ED_curve_editfont_make(struct Object *obedit); void ED_curve_editfont_free(struct Object *obedit); @@ -89,6 +88,9 @@ bool ED_curve_active_center(struct Curve *cu, float center[3]); bool ED_curve_editfont_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); +/* editfont_undo.c */ +void undo_push_font(struct bContext *C, const char *name); + #if 0 /* debug only */ void printknots(struct Object *obedit); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 5b8b8ae5bdb..ff4e11ac58b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -8436,6 +8436,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar, uiListDyn *dyn_data; int retval = WM_UI_HANDLER_CONTINUE; int type = event->type, val = event->val; + bool redraw = false; int mx, my; ui_list = listbox->custom_data; @@ -8525,7 +8526,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar, ui_apply_but_undo(listbox); ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; - ED_region_tag_redraw(ar); + redraw = true; } retval = WM_UI_HANDLER_BREAK; } @@ -8537,8 +8538,8 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar, ui_list->list_grip += (type == WHEELUPMOUSE) ? -1 : 1; ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; - ED_region_tag_redraw(ar); + redraw = true; retval = WM_UI_HANDLER_BREAK; } else if (ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { @@ -8546,13 +8547,22 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar, /* list template will clamp */ ui_list->list_scroll += (type == WHEELUPMOUSE) ? -1 : 1; - ED_region_tag_redraw(ar); - + redraw = true; retval = WM_UI_HANDLER_BREAK; } } } + if (redraw) { + if (listbox->block->flag & UI_BLOCK_POPUP) { + /* popups need special refreshing */ + ED_region_tag_refresh_ui(ar); + } + else { + ED_region_tag_redraw(ar); + } + } + return retval; } @@ -9794,11 +9804,21 @@ static int ui_handle_menus_recursive( } else { uiBlock *block = menu->region->uiblocks.first; + uiBut *listbox = ui_list_find_mouse_over(menu->region, event); - if (block->flag & UI_BLOCK_RADIAL) + if (block->flag & UI_BLOCK_RADIAL) { retval = ui_pie_handler(C, event, menu); - else if (event->type == LEFTMOUSE || event->val != KM_DBL_CLICK) - retval = ui_handle_menu_event(C, event, menu, level, is_parent_inside, is_parent_menu, is_floating); + } + else if (event->type == LEFTMOUSE || event->val != KM_DBL_CLICK) { + if (listbox) { + retval = ui_handle_list_event(C, event, menu->region, listbox); + } + if (retval == WM_UI_HANDLER_CONTINUE) { + retval = ui_handle_menu_event( + C, event, menu, level, + is_parent_inside, is_parent_menu, is_floating); + } + } } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index b7096583376..f1f9c4ef0cb 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2783,7 +2783,7 @@ static void uilist_prepare( layoutdata->end_idx = min_ii(layoutdata->start_idx + rows * columns, len); } -static void uilist_resize_update_cb(bContext *UNUSED(C), void *arg1, void *UNUSED(arg2)) +static void uilist_resize_update_cb(bContext *C, void *arg1, void *UNUSED(arg2)) { uiList *ui_list = arg1; uiListDyn *dyn_data = ui_list->dyn_data; @@ -2796,6 +2796,9 @@ static void uilist_resize_update_cb(bContext *UNUSED(C), void *arg1, void *UNUSE dyn_data->resize_prev += diff * UI_UNIT_Y; ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; } + + /* In case uilist is in popup, we need special refreshing */ + ED_region_tag_refresh_ui(CTX_wm_menu(C)); } static void *uilist_item_use_dynamic_tooltip(PointerRNA *itemptr, const char *propname) diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c index b9d3fd6c8be..8b16b2a977e 100644 --- a/source/blender/editors/mesh/editmesh_undo.c +++ b/source/blender/editors/mesh/editmesh_undo.c @@ -49,7 +49,7 @@ # endif # include "BLI_array_store.h" -# include "BLI_math_base.h" +# include "BLI_array_store_utils.h" /* check on best size later... */ # define ARRAY_CHUNK_SIZE 256 @@ -89,8 +89,7 @@ typedef struct UndoMesh { #ifdef USE_ARRAY_STORE /* NULL arrays are considered empty */ - struct { - /* most data is stored as 'custom' data */ + struct { /* most data is stored as 'custom' data */ BArrayCustomData *vdata, *edata, *ldata, *pdata; BArrayState **keyblocks; BArrayState *mselect; @@ -105,8 +104,7 @@ typedef struct UndoMesh { * \{ */ static struct { - BArrayStore **bs_all; - int bs_all_len; + struct BArrayStore_AtSize bs_stride; int users; /* We could have the undo API pass in the previous state, for now store a local list */ @@ -118,57 +116,6 @@ static struct { } um_arraystore = {NULL}; -static BArrayStore *array_store_at_size_ensure(const int stride) -{ - if (um_arraystore.bs_all_len < stride) { - um_arraystore.bs_all_len = stride; - um_arraystore.bs_all = MEM_recallocN(um_arraystore.bs_all, sizeof(*um_arraystore.bs_all) * stride); - } - BArrayStore **bs_p = &um_arraystore.bs_all[stride - 1]; - - if ((*bs_p) == NULL) { -#if 0 - unsigned int chunk_count = ARRAY_CHUNK_SIZE; -#else - /* calculate best chunk-count to fit a power of two */ - unsigned int chunk_count = ARRAY_CHUNK_SIZE; - { - unsigned int size = chunk_count * stride; - size = power_of_2_max_u(size); - size = MEM_SIZE_OPTIMAL(size); - chunk_count = size / stride; - } -#endif - - (*bs_p) = BLI_array_store_create(stride, chunk_count); - } - return *bs_p; -} - -static BArrayStore *array_store_at_size_get(const int stride) -{ - BLI_assert(stride > 0 && stride <= um_arraystore.bs_all_len); - return um_arraystore.bs_all[stride - 1]; -} - -#ifdef DEBUG_PRINT -static void um_arraystore_memory_usage(size_t *r_size_expanded, size_t *r_size_compacted) -{ - size_t size_compacted = 0; - size_t size_expanded = 0; - for (int i = 0; i < um_arraystore.bs_all_len; i++) { - BArrayStore *bs = um_arraystore.bs_all[i]; - if (bs) { - size_compacted += BLI_array_store_calc_size_compacted_get(bs); - size_expanded += BLI_array_store_calc_size_expanded_get(bs); - } - } - - *r_size_expanded = size_expanded; - *r_size_compacted = size_compacted; -} -#endif - static void um_arraystore_cd_compact( struct CustomData *cdata, const size_t data_len, bool create, @@ -194,7 +141,7 @@ static void um_arraystore_cd_compact( } const int stride = CustomData_sizeof(type); - BArrayStore *bs = create ? array_store_at_size_ensure(stride) : NULL; + BArrayStore *bs = create ? BLI_array_store_at_size_ensure(&um_arraystore.bs_stride, stride, ARRAY_CHUNK_SIZE) : NULL; const int layer_len = layer_end - layer_start; if (create) { @@ -299,7 +246,7 @@ static void um_arraystore_cd_free(BArrayCustomData *bcd) while (bcd) { BArrayCustomData *bcd_next = bcd->next; const int stride = CustomData_sizeof(bcd->type); - BArrayStore *bs = array_store_at_size_get(stride); + BArrayStore *bs = BLI_array_store_at_size_get(&um_arraystore.bs_stride, stride); for (int i = 0; i < bcd->states_len; i++) { if (bcd->states[i]) { BLI_array_store_state_remove(bs, bcd->states[i]); @@ -328,7 +275,7 @@ static void um_arraystore_compact_ex( if (me->key && me->key->totkey) { const size_t stride = me->key->elemsize; - BArrayStore *bs = create ? array_store_at_size_ensure(stride) : NULL; + BArrayStore *bs = create ? BLI_array_store_at_size_ensure(&um_arraystore.bs_stride, stride, ARRAY_CHUNK_SIZE) : NULL; if (create) { um->store.keyblocks = MEM_mallocN(me->key->totkey * sizeof(*um->store.keyblocks), __func__); } @@ -355,7 +302,7 @@ static void um_arraystore_compact_ex( if (create) { BArrayState *state_reference = um_ref ? um_ref->store.mselect : NULL; const size_t stride = sizeof(*me->mselect); - BArrayStore *bs = array_store_at_size_ensure(stride); + BArrayStore *bs = BLI_array_store_at_size_ensure(&um_arraystore.bs_stride, stride, ARRAY_CHUNK_SIZE); um->store.mselect = BLI_array_store_state_add( bs, me->mselect, (size_t)me->totselect * stride, state_reference); } @@ -384,7 +331,7 @@ static void um_arraystore_compact_with_info(UndoMesh *um, const UndoMesh *um_ref { #ifdef DEBUG_PRINT size_t size_expanded_prev, size_compacted_prev; - um_arraystore_memory_usage(&size_expanded_prev, &size_compacted_prev); + BLI_array_store_at_size_calc_memory_usage(&um_arraystore.bs_stride, &size_expanded_prev, &size_compacted_prev); #endif #ifdef DEBUG_TIME @@ -400,7 +347,7 @@ static void um_arraystore_compact_with_info(UndoMesh *um, const UndoMesh *um_ref #ifdef DEBUG_PRINT { size_t size_expanded, size_compacted; - um_arraystore_memory_usage(&size_expanded, &size_compacted); + BLI_array_store_at_size_calc_memory_usage(&um_arraystore.bs_stride, &size_expanded, &size_compacted); const double percent_total = size_expanded ? (((double)size_compacted / (double)size_expanded) * 100.0) : -1.0; @@ -483,7 +430,7 @@ static void um_arraystore_free(UndoMesh *um) if (um->store.keyblocks) { const size_t stride = me->key->elemsize; - BArrayStore *bs = array_store_at_size_get(stride); + BArrayStore *bs = BLI_array_store_at_size_get(&um_arraystore.bs_stride, stride); for (int i = 0; i < me->key->totkey; i++) { BArrayState *state = um->store.keyblocks[i]; BLI_array_store_state_remove(bs, state); @@ -494,7 +441,7 @@ static void um_arraystore_free(UndoMesh *um) if (um->store.mselect) { const size_t stride = sizeof(*me->mselect); - BArrayStore *bs = array_store_at_size_get(stride); + BArrayStore *bs = BLI_array_store_at_size_get(&um_arraystore.bs_stride, stride); BArrayState *state = um->store.mselect; BLI_array_store_state_remove(bs, state); um->store.mselect = NULL; @@ -508,15 +455,7 @@ static void um_arraystore_free(UndoMesh *um) #ifdef DEBUG_PRINT printf("mesh undo store: freeing all data!\n"); #endif - for (int i = 0; i < um_arraystore.bs_all_len; i += 1) { - if (um_arraystore.bs_all[i]) { - BLI_array_store_destroy(um_arraystore.bs_all[i]); - } - } - - MEM_freeN(um_arraystore.bs_all); - um_arraystore.bs_all = NULL; - um_arraystore.bs_all_len = 0; + BLI_array_store_at_size_clear(&um_arraystore.bs_stride); #ifdef USE_ARRAY_STORE_THREAD BLI_task_pool_free(um_arraystore.task_pool); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 014268262c4..93bac3f6660 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -327,6 +327,13 @@ float glaGetOneFloat(int param) return v; } +int glaGetOneInt(int param) +{ + GLint v; + glGetIntegerv(param, &v); + return v; +} + void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y) { GLubyte dummy = 0; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index d273f8320a1..e4c26064fec 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -202,7 +202,7 @@ typedef struct ProjPaintImage { */ typedef struct ProjStrokeHandle { /* Support for painting from multiple views at once, - * currently used to impliment summetry painting, + * currently used to impliment symmetry painting, * we can assume at least the first is set while painting. */ struct ProjPaintState *ps_views[8]; int ps_views_tot; @@ -717,7 +717,7 @@ static bool project_paint_PickColor( } /** - * Check if 'pt' is infront of the 3 verts on the Z axis (used for screenspace occlusuion test) + * Check if 'pt' is infront of the 3 verts on the Z axis (used for screenspace occlusion test) * \return * - `0`: no occlusion * - `-1`: no occlusion but 2D intersection is true diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 92be88bd5c6..fe80bba9f0b 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1322,7 +1322,7 @@ static bool do_weight_paint_normalize_all_locked( /** * \note same as function above except it does a second pass without active group - * if nomalize fails with it. + * if normalize fails with it. */ static void do_weight_paint_normalize_all_locked_try_active( MDeformVert *dvert, const int defbase_tot, const bool *vgroup_validmap, @@ -1339,7 +1339,7 @@ static void do_weight_paint_normalize_all_locked_try_active( * - With 1.0 weight painted into active: * nonzero locked weight; first pass zeroed out unlocked weight; scale 1 down to fit. * - With 0.0 weight painted into active: - * no unlocked groups; first pass did nothing; increaze 0 to fit. + * no unlocked groups; first pass did nothing; increase 0 to fit. */ do_weight_paint_normalize_all_locked(dvert, defbase_tot, vgroup_validmap, lock_flags); } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index f4171221816..f1309de3726 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -983,10 +983,11 @@ static GLubyte bm_dot7[] = {0x0, 0x38, 0x7C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38}; static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned int id, bPoseChannel *pchan, EditBone *ebone) { + /* call this once, avoid constant changing */ + BLI_assert(glaGetOneInt(GL_UNPACK_ALIGNMENT) == 1); + float length; - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - if (pchan) length = pchan->bone->length; else @@ -2692,6 +2693,11 @@ bool draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (v3d->flag2 & V3D_RENDER_OVERRIDE) return true; + /* needed for 'draw_line_bone' which draws pixel. */ + if (arm->drawtype == ARM_LINE) { + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + } + if (dt > OB_WIRE) { /* we use color for solid lighting */ if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) { @@ -2767,5 +2773,9 @@ bool draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* restore */ glFrontFace(GL_CCW); + if (arm->drawtype == ARM_LINE) { + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + } + return retval; } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 1c1068eff78..d8364011036 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -369,15 +369,18 @@ static bool set_draw_settings_cached(int clearcache, MTexPoly *texface, Material } if (c_badtex) lit = 0; - if (lit != c_lit || ma != c_ma) { - if (lit) { - int options = GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR; + if (lit != c_lit || ma != c_ma || textured != c_textured) { + int options = GPU_SHADER_USE_COLOR; - if (gtexdraw.two_sided_lighting) - options |= GPU_SHADER_TWO_SIDED; - if (c_textured && !c_badtex) - options |= GPU_SHADER_TEXTURE_2D; + if (c_textured && !c_badtex) { + options |= GPU_SHADER_TEXTURE_2D; + } + if (gtexdraw.two_sided_lighting) { + options |= GPU_SHADER_TWO_SIDED; + } + if (lit) { + options |= GPU_SHADER_LIGHTING; if (!ma) ma = give_current_material_or_def(NULL, 0); /* default material */ @@ -385,12 +388,10 @@ static bool set_draw_settings_cached(int clearcache, MTexPoly *texface, Material mul_v3_v3fl(specular, &ma->specr, ma->spec); GPU_basic_shader_colors(NULL, specular, ma->har, 1.0f); - GPU_basic_shader_bind(options); - } - else { - GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); } + GPU_basic_shader_bind(options); + c_lit = lit; c_ma = ma; } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 48701ed1db6..1f0ea4eaf9b 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4907,7 +4907,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg * Get the world-space 3d location from a screen-space 2d point. * * \param mval: Input screen-space pixel location. - * \param mouse_worldloc: Output world-space loction. + * \param mouse_worldloc: Output world-space location. * \param fallback_depth_pt: Use this points depth when no depth can be found. */ bool ED_view3d_autodist( diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 5d49d1d9315..2fb92d73515 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -686,7 +686,7 @@ static void TRANSFORM_OT_tilt(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Tilt"; - /* optionals - + /* optional - * "Tilt selected vertices" * "Specify an extra axis rotation for selected vertices of 3D curve" */ ot->description = "Tilt selected control vertices of 3D curve"; diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index b11a2d5d01e..d706c574d1f 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -198,7 +198,7 @@ static void raycast_all_cb(void *userdata, int index, const BVHTreeRay *ray, BVH mul_m3_v3((float(*)[3])data->timat, normal); normalize_v3(normal); - /* currently unused, and causes issues when looptri's havn't been calculated. + /* currently unused, and causes issues when looptri's haven't been calculated. * since theres some overhead in ensuring this data is valid, it may need to be optional. */ #if 0 if (data->dm) { @@ -735,7 +735,7 @@ static bool snapDerivedMesh( if (bb) { BoundBox bb_temp; - /* We cannot aford a bbox with some null dimension, which may happen in some cases... + /* We cannot afford a bounding box with some null dimension, which may happen in some cases... * Threshold is rather high, but seems to be needed to get good behavior, see T46099. */ bb = BKE_boundbox_ensure_minimum_dimensions(bb, &bb_temp, 1e-1f); diff --git a/source/blender/gpu/GPU_basic_shader.h b/source/blender/gpu/GPU_basic_shader.h index fa53a01ff5e..6c78aec2ec7 100644 --- a/source/blender/gpu/GPU_basic_shader.h +++ b/source/blender/gpu/GPU_basic_shader.h @@ -94,8 +94,9 @@ if (GPU_basic_shader_use_glsl_get()) { \ } ((void)0) -void GPU_basic_shader_colors(const float diffuse[3], const float specular[3], - int shininess, float alpha); +void GPU_basic_shader_colors( + const float diffuse[3], const float specular[3], + int shininess, float alpha); /* Fixed Function Lighting */ diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 75d6362f13e..bc732387c85 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -97,8 +97,9 @@ void GPU_clear_tpage(bool force); * - this affects fixed functions materials and texface, not glsl */ int GPU_default_lights(void); -int GPU_scene_object_lights(struct Scene *scene, struct Object *ob, - int lay, float viewmat[4][4], int ortho); +int GPU_scene_object_lights( + struct Scene *scene, struct Object *ob, + int lay, float viewmat[4][4], int ortho); /* Text render * - based on moving uv coordinates */ @@ -132,13 +133,15 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap); void GPU_paint_update_image(struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h); void GPU_update_images_framechange(void); int GPU_update_image_time(struct Image *ima, double time); -int GPU_verify_image(struct Image *ima, - struct ImageUser *iuser, int textarget, int tftile, bool compare, bool mipmap, bool is_data); -void GPU_create_gl_tex(unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth, - int textarget, bool mipmap, bool use_hight_bit_depth, struct Image *ima); +int GPU_verify_image( + struct Image *ima, struct ImageUser *iuser, + int textarget, int tftile, bool compare, bool mipmap, bool is_data); +void GPU_create_gl_tex( + unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth, + int textarget, bool mipmap, bool use_hight_bit_depth, struct Image *ima); void GPU_create_gl_tex_compressed( - unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, - int textarget, struct Image *ima, struct ImBuf *ibuf); + unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, + int textarget, struct Image *ima, struct ImBuf *ibuf); bool GPU_upload_dxt_texture(struct ImBuf *ibuf); void GPU_free_image(struct Image *ima); void GPU_free_images(void); diff --git a/source/blender/gpu/intern/gpu_basic_shader.c b/source/blender/gpu/intern/gpu_basic_shader.c index cc4eafc1f62..3855c15d905 100644 --- a/source/blender/gpu/intern/gpu_basic_shader.c +++ b/source/blender/gpu/intern/gpu_basic_shader.c @@ -528,8 +528,9 @@ int GPU_basic_shader_bound_options(void) /* Material Colors */ -void GPU_basic_shader_colors(const float diffuse[3], const float specular[3], - int shininess, float alpha) +void GPU_basic_shader_colors( + const float diffuse[3], const float specular[3], + int shininess, float alpha) { float gl_diffuse[4], gl_specular[4]; diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 62146595eae..880c432b978 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -53,8 +53,6 @@ #include "BKE_mesh.h" #include "BKE_pbvh.h" -#include "DNA_userdef_types.h" - #include "GPU_buffers.h" #include "GPU_draw.h" #include "GPU_basic_shader.h" diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 9f41253b176..a89efce3077 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -86,8 +86,10 @@ typedef struct GPUFunction { } GPUFunction; /* Indices match the GPUType enum */ -static const char *GPU_DATATYPE_STR[17] = {"", "float", "vec2", "vec3", "vec4", - NULL, NULL, NULL, NULL, "mat3", NULL, NULL, NULL, NULL, NULL, NULL, "mat4"}; +static const char *GPU_DATATYPE_STR[17] = { + "", "float", "vec2", "vec3", "vec4", + NULL, NULL, NULL, NULL, "mat3", NULL, NULL, NULL, NULL, NULL, NULL, "mat4", +}; /* GLSL code parsing for finding function definitions. * These are stored in a hash for lookup when creating a material. */ diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c index c2a2b1804ca..964c2b5051e 100644 --- a/source/blender/gpu/intern/gpu_compositing.c +++ b/source/blender/gpu/intern/gpu_compositing.c @@ -34,16 +34,11 @@ #include "BLI_sys_types.h" #include "BLI_rect.h" #include "BLI_math.h" -#include "BLI_listbase.h" -#include "BLI_linklist.h" #include "BLI_rand.h" #include "DNA_vec_types.h" -#include "DNA_view3d_types.h" #include "DNA_scene_types.h" -#include "DNA_object_types.h" -#include "DNA_camera_types.h" #include "DNA_gpu_types.h" #include "GPU_compositing.h" diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index a0fd9417af0..86d82e34027 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -39,7 +39,6 @@ #include <string.h> #include "GPU_glew.h" -#include "GPU_debug.h" #include "BLI_blenlib.h" #include "BLI_linklist.h" @@ -69,10 +68,11 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_node.h" -#include "BKE_object.h" #include "BKE_scene.h" -#include "BKE_subsurf.h" #include "BKE_DerivedMesh.h" +#ifdef WITH_GAMEENGINE +# include "BKE_object.h" +#endif #include "GPU_basic_shader.h" #include "GPU_buffers.h" @@ -84,9 +84,13 @@ #include "PIL_time.h" -#include "smoke_API.h" +#ifdef WITH_SMOKE +# include "smoke_API.h" +#endif #ifdef WITH_OPENSUBDIV +# include "BKE_subsurf.h" +# include "BKE_DerivedMesh.h" # include "BKE_editmesh.h" # include "gpu_codegen.h" @@ -560,7 +564,9 @@ static void gpu_verify_high_bit_srgb_buffer(float *srgb_frect, } } -int GPU_verify_image(Image *ima, ImageUser *iuser, int textarget, int tftile, bool compare, bool mipmap, bool is_data) +int GPU_verify_image( + Image *ima, ImageUser *iuser, + int textarget, int tftile, bool compare, bool mipmap, bool is_data) { unsigned int *bind = NULL; int tpx = 0, tpy = 0; @@ -842,8 +848,9 @@ static void gpu_del_cube_map(void **cube_map) } /* Image *ima can be NULL */ -void GPU_create_gl_tex(unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth, - int textarget, bool mipmap, bool use_high_bit_depth, Image *ima) +void GPU_create_gl_tex( + unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth, + int textarget, bool mipmap, bool use_high_bit_depth, Image *ima) { ImBuf *ibuf = NULL; diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 3c96b628cd6..b8a39c81122 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -32,9 +32,6 @@ * with checks for drivers and GPU support. */ -#include "MEM_guardedalloc.h" - -#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_math_base.h" #include "BLI_math_vector.h" @@ -42,7 +39,6 @@ #include "BKE_global.h" #include "GPU_basic_shader.h" -#include "GPU_draw.h" #include "GPU_extensions.h" #include "GPU_glew.h" #include "GPU_texture.h" diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index a6d120b8943..c0400cdb04c 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -29,8 +29,6 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BLI_math_base.h" -#include "BLI_math_vector.h" #include "BKE_global.h" diff --git a/source/blender/gpu/intern/gpu_init_exit.c b/source/blender/gpu/intern/gpu_init_exit.c index 8fed6a9ee80..c72c83b6b07 100644 --- a/source/blender/gpu/intern/gpu_init_exit.c +++ b/source/blender/gpu/intern/gpu_init_exit.c @@ -29,11 +29,8 @@ * \ingroup gpu */ -#include "BKE_DerivedMesh.h" - #include "BLI_sys_types.h" #include "GPU_init_exit.h" /* interface */ -#include "GPU_buffers.h" #include "BKE_global.h" diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 67a06167a23..79d11ae0972 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -31,7 +31,6 @@ * Manages materials, lights and textures. */ - #include <math.h> #include <string.h> @@ -49,7 +48,6 @@ #include "BKE_anim.h" #include "BKE_colortools.h" -#include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_main.h" @@ -68,7 +66,9 @@ #include "gpu_codegen.h" -#include <string.h> +#ifdef WITH_OPENSUBDIV +# include "BKE_DerivedMesh.h" +#endif /* Structs */ diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 25352001056..5a1b38e6be7 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -27,7 +27,6 @@ #include "MEM_guardedalloc.h" -#include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_math_base.h" #include "BLI_math_vector.h" diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index 294b08f155a..827c52c9a5f 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -32,7 +32,6 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_math_base.h" -#include "BLI_math_vector.h" #include "BKE_global.h" diff --git a/source/blender/physics/intern/implicit_blender.c b/source/blender/physics/intern/implicit_blender.c index 832d516b839..2ad8ee0547f 100644 --- a/source/blender/physics/intern/implicit_blender.c +++ b/source/blender/physics/intern/implicit_blender.c @@ -1586,8 +1586,11 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data *data, int i, int j, floa // calculate elonglation spring_length(data, i, j, extent, dir, &length, vel); - - if (length > restlen || no_compress) { + + /* This code computes not only the force, but also its derivative. + Zero derivative effectively disables the spring for the implicit solver. + Thus length > restlen makes cloth unconstrained at the start of simulation. */ + if ((length >= restlen && length > 0) || no_compress) { float stretch_force, f[3], dfdx[3][3], dfdv[3][3]; stretch_force = stiffness * (length - restlen); diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index db933ad2d76..1357729e898 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -233,19 +233,15 @@ static void wm_gesture_draw_circle(wmGesture *gt) } struct LassoFillData { - unsigned int *px; + unsigned char *px; int width; }; static void draw_filled_lasso_px_cb(int x, int x_end, int y, void *user_data) { struct LassoFillData *data = user_data; - unsigned char *col = (unsigned char *)&(data->px[(y * data->width) + x]); - do { - col[0] = col[1] = col[2] = 0xff; - col[3] = 0x10; - col += 4; - } while (++x != x_end); + unsigned char *col = &(data->px[(y * data->width) + x]); + memset(col, 0x10, x_end - x); } static void draw_filled_lasso(wmWindow *win, wmGesture *gt) @@ -273,7 +269,7 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt) if (BLI_rcti_is_empty(&rect) == false) { const int w = BLI_rcti_size_x(&rect); const int h = BLI_rcti_size_y(&rect); - unsigned int *pixel_buf = MEM_callocN(sizeof(*pixel_buf) * w * h, __func__); + unsigned char *pixel_buf = MEM_callocN(sizeof(*pixel_buf) * w * h, __func__); struct LassoFillData lasso_fill_data = {pixel_buf, w}; fill_poly_v2i_n( @@ -281,19 +277,27 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt) (const int (*)[2])moves, tot, draw_filled_lasso_px_cb, &lasso_fill_data); - int bound_options; - GPU_BASIC_SHADER_DISABLE_AND_STORE(bound_options); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glColor4f(1, 1, 1, 1); + glPixelTransferf(GL_RED_BIAS, 1); + glPixelTransferf(GL_GREEN_BIAS, 1); + glPixelTransferf(GL_BLUE_BIAS, 1); + + GPU_basic_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR); glEnable(GL_BLEND); - // glColor4f(1.0, 1.0, 1.0, 0.05); + glaDrawPixelsTex(rect.xmin, rect.ymin, w, h, GL_ALPHA, GL_UNSIGNED_BYTE, GL_NEAREST, pixel_buf); + glDisable(GL_BLEND); - glRasterPos2f(rect.xmin, rect.ymin); + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); - glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixel_buf); + glPixelTransferf(GL_RED_BIAS, 0); + glPixelTransferf(GL_GREEN_BIAS, 0); + glPixelTransferf(GL_BLUE_BIAS, 0); - GPU_BASIC_SHADER_ENABLE_AND_RESTORE(bound_options); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glDisable(GL_BLEND); MEM_freeN(pixel_buf); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index b4295bb2607..866e332b34f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1391,7 +1391,7 @@ static void dialog_exec_cb(bContext *C, void *arg1, void *arg2) } } -static void dialog_check_cb(bContext *C, void *op_ptr, void *UNUSED(arg)) +static void popup_check_cb(bContext *C, void *op_ptr, void *UNUSED(arg)) { wmOperator *op = op_ptr; if (op->type->check) { @@ -1423,7 +1423,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style); - UI_block_func_set(block, dialog_check_cb, op, NULL); + UI_block_func_set(block, popup_check_cb, op, NULL); uiLayoutOperatorButs(C, layout, op, NULL, 'H', UI_LAYOUT_OP_SHOW_TITLE); @@ -1463,9 +1463,13 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style); + UI_block_func_set(block, popup_check_cb, op, NULL); + /* since ui is defined the auto-layout args are not used */ uiLayoutOperatorButs(C, layout, op, NULL, 'V', 0); + UI_block_func_set(block, NULL, NULL, NULL); + UI_block_bounds_set_popup(block, 4, 0, 0); return block; |