Beatmup
Beatmup::Swapper Class Reference

#include <swapper.h>

Inheritance diagram for Beatmup::Swapper:
Beatmup::GpuTask Beatmup::AbstractTask Beatmup::Object

Public Member Functions

 Swapper (bool fromGpuToCpu)
 
void setBitmap (AbstractBitmap &)
 
- Public Member Functions inherited from Beatmup::AbstractTask
virtual void beforeProcessing (ThreadIndex threadCount, ProcessingTarget target, GraphicPipeline *gpu)
 Instruction called before the task is executed. More...
 
virtual void afterProcessing (ThreadIndex threadCount, GraphicPipeline *gpu, bool aborted)
 Instruction called after the task is executed. More...
 
- Public Member Functions inherited from Beatmup::Object
virtual ~Object ()
 

Static Public Member Functions

static void pullPixels (AbstractBitmap &bitmap)
 Copies bitmap from GPU memory to RAM. More...
 
static void pushPixels (AbstractBitmap &bitmap)
 Copies bitmap from RAM to GPU memory. More...
 
- Static Public Member Functions inherited from Beatmup::AbstractTask
static ThreadIndex validThreadCount (int number)
 Valid thread count from a given integer value. More...
 

Private Member Functions

bool processOnGPU (GraphicPipeline &gpu, TaskThread &)
 Executes the task on GPU. More...
 

Private Attributes

AbstractBitmapbitmap
 
bool fromGpuToCpu
 

Additional Inherited Members

- Public Types inherited from Beatmup::AbstractTask
enum class  TaskDeviceRequirement { CPU_ONLY , GPU_OR_CPU , GPU_ONLY }
 Specifies which device (CPU and/or GPU) is used to run the task. More...
 

Detailed Description

Definition at line 25 of file swapper.h.

Constructor & Destructor Documentation

◆ Swapper()

Swapper::Swapper ( bool  fromGpuToCpu)

Definition at line 39 of file swapper.cpp.

39  : bitmap(nullptr), fromGpuToCpu(fromGpuToCpu)
40 {}
AbstractBitmap * bitmap
Definition: swapper.h:27
bool fromGpuToCpu
Definition: swapper.h:28

Member Function Documentation

◆ processOnGPU()

bool Swapper::processOnGPU ( GraphicPipeline gpu,
TaskThread thread 
)
privatevirtual

Executes the task on GPU.

Parameters
gpugraphic pipeline instance
threadassociated task execution context
Returns
true if the execution is finished correctly, false otherwise

Reimplemented from Beatmup::AbstractTask.

Definition at line 25 of file swapper.cpp.

25  {
26  BitmapContentLock lock;
29 
30  if (fromGpuToCpu)
31  gpu.pullPixels(*bitmap);
32  else
33  gpu.pushPixels(*bitmap);
34 
35  lock.unlockAll();
36  return true;
37 }
Makes sure the bitmap content is accessible within an image processing task.
Definition: content_lock.h:34
void writeLock(GraphicPipeline *gpu, AbstractBitmap *bitmap, ProcessingTarget target)
Locks content of a bitmap for writing using a specific processing target device.
void unlockAll()
Unlocks all the locked bitmaps unconditionally.
void pullPixels(AbstractBitmap &bitmap)
Transfers bitmap pixels from GPU to CPU.
Definition: pipeline.cpp:921
void pushPixels(AbstractBitmap &bitmap)
Transfers bitmap pixels from CPU to GPU.
Definition: pipeline.cpp:926

◆ setBitmap()

void Swapper::setBitmap ( AbstractBitmap bitmap)

Definition at line 43 of file swapper.cpp.

43  {
44  this->bitmap = &bitmap;
45 }

◆ pullPixels()

void Swapper::pullPixels ( AbstractBitmap bitmap)
static

Copies bitmap from GPU memory to RAM.

Definition at line 48 of file swapper.cpp.

48  {
50  Swapper me(true);
51  me.setBitmap(bitmap);
53  }
54 }
Context & getContext() const
bool isUpToDate(ProcessingTarget) const
float performTask(AbstractTask &task, const PoolIndex pool=DEFAULT_POOL)
Performs a given task.
Definition: context.cpp:240

◆ pushPixels()

void Swapper::pushPixels ( AbstractBitmap bitmap)
static

Copies bitmap from RAM to GPU memory.

Definition at line 57 of file swapper.cpp.

57  {
59  Swapper me(false);
60  me.setBitmap(bitmap);
62  }
63 }

Member Data Documentation

◆ bitmap

AbstractBitmap* Beatmup::Swapper::bitmap
private

Definition at line 27 of file swapper.h.

◆ fromGpuToCpu

bool Beatmup::Swapper::fromGpuToCpu
private

Definition at line 28 of file swapper.h.


The documentation for this class was generated from the following files: