Files
test/source/blender/blenlib/intern/bitmap.c
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

49 lines
1.1 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2012 by Nicholas Bishop. All rights reserved. */
/** \file
* \ingroup bli
*
* Utility functions for variable size bit-masks.
*/
#include <limits.h>
#include <string.h>
#include "BLI_bitmap.h"
#include "BLI_utildefines.h"
void BLI_bitmap_set_all(BLI_bitmap *bitmap, bool set, size_t bits)
{
memset(bitmap, set ? UCHAR_MAX : 0, BLI_BITMAP_SIZE(bits));
}
void BLI_bitmap_flip_all(BLI_bitmap *bitmap, size_t bits)
{
size_t num_blocks = _BITMAP_NUM_BLOCKS(bits);
for (size_t i = 0; i < num_blocks; i++) {
bitmap[i] ^= ~(BLI_bitmap)0;
}
}
void BLI_bitmap_copy_all(BLI_bitmap *dst, const BLI_bitmap *src, size_t bits)
{
memcpy(dst, src, BLI_BITMAP_SIZE(bits));
}
void BLI_bitmap_and_all(BLI_bitmap *dst, const BLI_bitmap *src, size_t bits)
{
size_t num_blocks = _BITMAP_NUM_BLOCKS(bits);
for (size_t i = 0; i < num_blocks; i++) {
dst[i] &= src[i];
}
}
void BLI_bitmap_or_all(BLI_bitmap *dst, const BLI_bitmap *src, size_t bits)
{
size_t num_blocks = _BITMAP_NUM_BLOCKS(bits);
for (size_t i = 0; i < num_blocks; i++) {
dst[i] |= src[i];
}
}