Commit: c9e3ae3f070d1df5c0efb2281fb99bcdfd1a0587 Author: Falk David Date: Fri May 13 16:07:31 2022 +0200 Branches: gpencil-new-data-proposal https://developer.blender.org/rBc9e3ae3f070d1df5c0efb2281fb99bcdfd1a0587
Cleanup, comments =================================================================== M source/blender/blenkernel/intern/gpencil_new_proposal.hh M source/blender/blenkernel/intern/gpencil_new_proposal_test.cc =================================================================== diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh b/source/blender/blenkernel/intern/gpencil_new_proposal.hh index 630f324c6cb..3f328ee36e6 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh +++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh @@ -120,13 +120,17 @@ typedef struct GPData { GPDataRuntimeHandle *runtime; } GPData; -/* This is the ID_GP structure that holds all the information at the object data level. */ +/** + * This would be the new Grease Pencil ID structure. This is where the animation data, materials, etc. are stored. + * Layers, Frames, Groups and RuntimeData would be stored in GPData. + */ typedef struct GreasePencil { ID id; /* Animation data (must be immediately after id). */ struct AnimData *adt; - /* Pointer to the actual data-block containing the frames, layers and layer groups. */ + /* Pointer to the actual data-block containing the frames, layers and layer groups. Note: This is + * stored as a pointer to easily wrap it in a class. */ GPData *grease_pencil_data; /* GreasePencil flag. */ diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc index d7ce5c803c6..4ca0ca7a4fb 100644 --- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc +++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc @@ -21,7 +21,7 @@ namespace blender::bke { -class GPLayerGroup : ::GPLayerGroup { +class GPLayerGroup : ::GPLayerGroup { /* Unused for now. Placeholder class. */ public: GPLayerGroup() { @@ -64,7 +64,7 @@ class GPDataRuntime { mutable Map<int, Vector<int64_t>> frame_index_masks_cache; mutable std::mutex frame_index_masks_cache_mutex; - IndexMask get_cached_frame_index_mask(int layer_index) + IndexMask frame_index_masks_cache_for_layer(int layer_index) { return frame_index_masks_cache.lookup(layer_index).as_span(); } @@ -290,6 +290,7 @@ class GPData : public ::GPData { if (this->layers_size > 0) { this->layers_array = reinterpret_cast<::GPLayer *>( MEM_malloc_arrayN(this->layers_size, sizeof(::GPLayer), __func__)); + default_construct_n(reinterpret_cast<GPLayer *>(this->layers_array), this->layers_size); this->active_layer_index = 0; } else { @@ -348,7 +349,7 @@ class GPData : public ::GPData { Span<GPFrame> frames() const { - return {(const GPFrame *)this->frames_array, this->frames_size}; + return {reinterpret_cast<const GPFrame *>(this->frames_array), this->frames_size}; } const GPFrame &frames(int index) const @@ -358,7 +359,7 @@ class GPData : public ::GPData { MutableSpan<GPFrame> frames_for_write() { - return {(GPFrame *)this->frames_array, this->frames_size}; + return {reinterpret_cast<GPFrame *>(this->frames_array), this->frames_size}; } GPFrame &frames_for_write(int index) @@ -374,13 +375,13 @@ class GPData : public ::GPData { /* If the indices are cached for this layer, use the cache. */ if (this->runtime->frame_index_masks_cache.contains(layer_index)) { - return this->runtime->get_cached_frame_index_mask(layer_index); + return this->runtime->frame_index_masks_cache_for_layer(layer_index); } /* A double checked lock. */ std::scoped_lock{this->runtime->frame_index_masks_cache_mutex}; if (this->runtime->frame_index_masks_cache.contains(layer_index)) { - return this->runtime->get_cached_frame_index_mask(layer_index); + return this->runtime->frame_index_masks_cache_for_layer(layer_index); } Vector<int64_t> indices; @@ -410,7 +411,7 @@ class GPData : public ::GPData { Span<GPLayer> layers() const { - return {(const GPLayer *)this->layers_array, this->layers_size}; + return {reinterpret_cast<const GPLayer *>(this->layers_array), this->layers_size}; } const GPLayer &layers(int index) const @@ -420,7 +421,7 @@ class GPData : public ::GPData { MutableSpan<GPLayer> layers_for_write() { - return {(GPLayer *)this->layers_array, this->layers_size}; + return {reinterpret_cast<GPLayer *>(this->layers_array), this->layers_size}; } GPLayer &layers_for_write(int index) @@ -463,6 +464,7 @@ class GPData : public ::GPData { /* Sort frame array. */ update_frames_array(); + /* Find the frame again and return its index (now from the sorted array). */ auto it = std::lower_bound(this->frames().begin(), this->frames().end(), std::pair<int, int>(layer_index, new_frame.start_time)); @@ -542,7 +544,7 @@ class GPData : public ::GPData { reinterpret_cast<GPLayer *>(dst.layers_array)); dst.active_layer_index = src.active_layer_index; - /* Copy layer groups. */ + /* Copy layer default group. */ *dst.default_group = *src.default_group; } @@ -630,7 +632,7 @@ class GPData : public ::GPData { /* Make sure frames are ordered chronologically and by layer order. */ std::sort(this->frames_for_write().begin(), this->frames_for_write().end()); - /* Clear the cached indices since they are probably no longer valid. */ + /* Clear the cached indices since they are (probably) no longer valid. */ this->runtime->frame_index_masks_cache.clear(); } }; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs