Beatmup
bitmap_from_chunk.cpp
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 #include "bitmap_from_chunk.h"
20 
21 using namespace Beatmup;
22 
25  return true;
26 }
27 
28 
30  NullTaskInput::check(bitmap, "bitmap");
31  NullTaskInput::check(collection, "chunk collection");
33  const size_t chunkSize = collection->chunkSize(chunkId);
34  const size_t bitmapSize = bitmap->getMemorySize();
35  InvalidArgument::check(chunkSize == bitmapSize,
36  "Chunk size does not match bitmap size: " + std::to_string(chunkSize) + " vs " + std::to_string(bitmapSize) + " bytes");
38 }
39 
40 
41 void BitmapFromChunk::afterProcessing(ThreadIndex threadCount, GraphicPipeline* gpu, bool aborted) {
42  unlock(bitmap);
43 }
44 
45 
46 void BitmapFromChunk::load(AbstractBitmap& bitmap, ChunkCollection& collection, const std::string& chunkId) {
49 }
A very basic class for any image.
Context & getContext() const
virtual const pixbyte * getData(int x, int y) const =0
Returns a pointer to given pixel.
virtual const msize getMemorySize() const =0
Bitmap size in bytes.
void unlock(AbstractBitmap *bitmap)
Drops a lock to the bitmap.
void writeLock(GraphicPipeline *gpu, AbstractBitmap *bitmap, ProcessingTarget target)
Locks content of a bitmap for writing using a specific processing target device.
Loads a bitmap content from chunk.
virtual void afterProcessing(ThreadIndex threadCount, GraphicPipeline *gpu, bool aborted)
Instruction called after the task is executed.
static void load(AbstractBitmap &bitmap, ChunkCollection &collection, const std::string &chunkId)
Loads a bitmap content from a given collection and chunk.
ChunkCollection * collection
virtual bool process(TaskThread &thread)
Executes the task on CPU within a given thread.
virtual void beforeProcessing(ThreadIndex threadCount, ProcessingTarget target, GraphicPipeline *gpu)
Instruction called before the task is executed.
A key-value pair set storing pieces of arbitrary data (chunks) under string keys.
Definition: chunkfile.h:36
virtual bool chunkExists(const std::string &id) const =0
Check if a specific chunk exists.
virtual chunksize_t chunkSize(const std::string &id) const =0
Retrieves size of a specific chunk.
virtual chunksize_t fetch(const std::string &id, void *data, const chunksize_t limit)=0
Reads a chunk.
float performTask(AbstractTask &task, const PoolIndex pool=DEFAULT_POOL)
Performs a given task.
Definition: context.cpp:240
Internal low-level GPU control API.
Definition: pipeline.h:33
static void check(const bool condition, const std::string &message)
Definition: exception.h:75
static void check(const void *pointer, const char *which)
Definition: exception.h:115
Thread executing tasks.
Definition: parallelism.h:154
unsigned char ThreadIndex
number of threads / thread index
Definition: parallelism.h:68
ProcessingTarget
Definition: basic_types.h:55
std::string to_string(Beatmup::NNets::ActivationFunction function)
Beatmup::InternalBitmap * bitmap
Beatmup::NNets::InferenceTask * task