Beatmup
|
Makes sure the bitmap content is accessible within an image processing task. More...
#include <content_lock.h>
Classes | |
struct | LockDescriptor |
Public Member Functions | |
BitmapContentLock () | |
~BitmapContentLock () | |
void | readLock (GraphicPipeline *gpu, AbstractBitmap *bitmap, ProcessingTarget target) |
Locks content of a bitmap for reading using a specific processing target device. More... | |
void | writeLock (GraphicPipeline *gpu, AbstractBitmap *bitmap, ProcessingTarget target) |
Locks content of a bitmap for writing using a specific processing target device. More... | |
void | unlock (AbstractBitmap *bitmap) |
Drops a lock to the bitmap. More... | |
void | unlockAll () |
Unlocks all the locked bitmaps unconditionally. More... | |
template<const ProcessingTarget target> | |
void | lock (GraphicPipeline *gpu, AbstractBitmap *input, AbstractBitmap *output) |
void | lock (GraphicPipeline *gpu, ProcessingTarget target, AbstractBitmap *input, AbstractBitmap *output) |
template<const ProcessingTarget target> | |
void | lock (GraphicPipeline *gpu, std::initializer_list< AbstractBitmap * > read, std::initializer_list< AbstractBitmap * > write) |
template<typename ... Args> | |
void | unlock (AbstractBitmap *first, Args ... others) |
Private Member Functions | |
BitmapContentLock (const BitmapContentLock &)=delete | |
Private Attributes | |
std::map< AbstractBitmap *, LockDescriptor > | bitmaps |
Makes sure the bitmap content is accessible within an image processing task.
To enable direct access to pixels, a specific operation of locking the bitmap content is typically required. When done, the bitmap content needs to be unlocked. Depending on the access type (reading/writing) an the processing target (CPU or GPU), a memory allocation and/or data transfer may be required. BitmapContentLock performs the data transfer if necessary. It also handles multiple locking of the same bitmap by reference counting.
Definition at line 34 of file content_lock.h.
|
privatedelete |
|
inline |
Definition at line 48 of file content_lock.h.
BitmapContentLock::~BitmapContentLock | ( | ) |
Definition at line 29 of file content_lock.cpp.
void BitmapContentLock::readLock | ( | GraphicPipeline * | gpu, |
AbstractBitmap * | bitmap, | ||
ProcessingTarget | target | ||
) |
Locks content of a bitmap for reading using a specific processing target device.
If the lock is already acquired, only increases the counter. If the bitmap was previously locked for a different target device, an exception is thrown.
gpu | A graphic pipeline instance. Used to transfer the pixel data between CPU and GPU if needed. |
bitmap | The bitmap to lock |
target | Target processing device to make the pixel content readable for (CPU or GPU) |
Definition at line 37 of file content_lock.cpp.
void BitmapContentLock::writeLock | ( | GraphicPipeline * | gpu, |
AbstractBitmap * | bitmap, | ||
ProcessingTarget | target | ||
) |
Locks content of a bitmap for writing using a specific processing target device.
If the lock is already acquired, only increases the counter. If the bitmap was previously locked for reading, an exception is thrown. However, it is allowed to lock for different devices, or to lock for writing first and reading later.
gpu | A graphic pipeline instance |
bitmap | The bitmap to lock |
target | Target processing device to make the pixel content readable for (CPU or GPU) |
Definition at line 101 of file content_lock.cpp.
void BitmapContentLock::unlock | ( | AbstractBitmap * | bitmap | ) |
Drops a lock to the bitmap.
If no other locks own the content, the bitmap is unlocked.
Definition at line 145 of file content_lock.cpp.
void BitmapContentLock::unlockAll | ( | ) |
|
inline |
Definition at line 84 of file content_lock.h.
|
inline |
Definition at line 89 of file content_lock.h.
|
inline |
Definition at line 95 of file content_lock.h.
|
inline |
Definition at line 103 of file content_lock.h.
|
private |
Definition at line 45 of file content_lock.h.