Beatmup
bitmap_from_chunk.h
Go to the documentation of this file.
1
/*
2
Beatmup image and signal processing library
3
Copyright (C) 2020, lnstadrum
4
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#pragma once
20
#include "../parallelism.h"
21
#include "../bitmap/abstract_bitmap.h"
22
#include "../bitmap/content_lock.h"
23
#include "
chunkfile.h
"
24
25
namespace
Beatmup
{
26
27
/**
28
Loads a bitmap content from chunk.
29
The bitmap needs to be created in advance. The loaded chunk contains pixel data in binary form.
30
*/
31
class
BitmapFromChunk
:
public
AbstractTask
,
public
BitmapContentLock
{
32
private
:
33
virtual
bool
process
(
TaskThread
& thread);
34
virtual
void
beforeProcessing
(
ThreadIndex
threadCount,
ProcessingTarget
target,
GraphicPipeline
* gpu);
35
virtual
void
afterProcessing
(
ThreadIndex
threadCount,
GraphicPipeline
* gpu,
bool
aborted);
36
AbstractBitmap
*
bitmap
;
37
ChunkCollection
*
collection
;
38
std::string
chunkId
;
39
public
:
40
inline
BitmapFromChunk
():
bitmap
(nullptr),
collection
(nullptr) {}
41
inline
BitmapFromChunk
(
AbstractBitmap
&
bitmap
,
ChunkCollection
&
collection
,
const
std::string&
chunkId
):
42
bitmap
(&
bitmap
),
collection
(&
collection
),
chunkId
(
chunkId
) {}
43
44
inline
void
setBitmap
(
AbstractBitmap
*
bitmap
) { this->bitmap =
bitmap
; }
45
46
inline
void
setCollection
(
ChunkCollection
*
collection
) { this->collection =
collection
; }
47
48
inline
void
setChunkId
(
const
std::string&
chunkId
) { this->chunkId =
chunkId
; }
49
50
/**
51
Loads a bitmap content from a given collection and chunk.
52
Launches a task in the main thread pool of the bitmap context.
53
\param[in,out] bitmap The bitmap to load
54
\param[in,out] collection The collection to load from
55
\param[in,out] chunkId Chunk ID containing the content to load
56
*/
57
static
void
load
(
AbstractBitmap
&
bitmap
,
ChunkCollection
&
collection
,
const
std::string&
chunkId
);
58
};
59
}
chunkfile.h
Beatmup::AbstractBitmap
A very basic class for any image.
Definition:
abstract_bitmap.h:87
Beatmup::AbstractTask
Task: an operation that can be executed by multiple threads in parallel.
Definition:
parallelism.h:90
Beatmup::BitmapContentLock
Makes sure the bitmap content is accessible within an image processing task.
Definition:
content_lock.h:34
Beatmup::BitmapFromChunk
Loads a bitmap content from chunk.
Definition:
bitmap_from_chunk.h:31
Beatmup::BitmapFromChunk::BitmapFromChunk
BitmapFromChunk()
Definition:
bitmap_from_chunk.h:40
Beatmup::BitmapFromChunk::chunkId
std::string chunkId
Definition:
bitmap_from_chunk.h:38
Beatmup::BitmapFromChunk::afterProcessing
virtual void afterProcessing(ThreadIndex threadCount, GraphicPipeline *gpu, bool aborted)
Instruction called after the task is executed.
Definition:
bitmap_from_chunk.cpp:41
Beatmup::BitmapFromChunk::load
static void load(AbstractBitmap &bitmap, ChunkCollection &collection, const std::string &chunkId)
Loads a bitmap content from a given collection and chunk.
Definition:
bitmap_from_chunk.cpp:46
Beatmup::BitmapFromChunk::setChunkId
void setChunkId(const std::string &chunkId)
Definition:
bitmap_from_chunk.h:48
Beatmup::BitmapFromChunk::setCollection
void setCollection(ChunkCollection *collection)
Definition:
bitmap_from_chunk.h:46
Beatmup::BitmapFromChunk::bitmap
AbstractBitmap * bitmap
Definition:
bitmap_from_chunk.h:36
Beatmup::BitmapFromChunk::setBitmap
void setBitmap(AbstractBitmap *bitmap)
Definition:
bitmap_from_chunk.h:44
Beatmup::BitmapFromChunk::BitmapFromChunk
BitmapFromChunk(AbstractBitmap &bitmap, ChunkCollection &collection, const std::string &chunkId)
Definition:
bitmap_from_chunk.h:41
Beatmup::BitmapFromChunk::collection
ChunkCollection * collection
Definition:
bitmap_from_chunk.h:37
Beatmup::BitmapFromChunk::process
virtual bool process(TaskThread &thread)
Executes the task on CPU within a given thread.
Definition:
bitmap_from_chunk.cpp:23
Beatmup::BitmapFromChunk::beforeProcessing
virtual void beforeProcessing(ThreadIndex threadCount, ProcessingTarget target, GraphicPipeline *gpu)
Instruction called before the task is executed.
Definition:
bitmap_from_chunk.cpp:29
Beatmup::ChunkCollection
A key-value pair set storing pieces of arbitrary data (chunks) under string keys.
Definition:
chunkfile.h:36
Beatmup::GraphicPipeline
Internal low-level GPU control API.
Definition:
pipeline.h:33
Beatmup::TaskThread
Thread executing tasks.
Definition:
parallelism.h:154
Beatmup
Definition:
basic_types.h:22
Beatmup::ThreadIndex
unsigned char ThreadIndex
number of threads / thread index
Definition:
parallelism.h:68
Beatmup::ProcessingTarget
ProcessingTarget
Definition:
basic_types.h:55
core
utils
bitmap_from_chunk.h
Generated on Tue Nov 21 2023 13:54:27 for Beatmup by
1.9.1