20 #include "../exception.h"
28 inputBitmap(nullptr), outputBitmap(nullptr), shader(nullptr)
40 static const int MIN_PIXEL_COUNT_PER_THREAD = 64;
49 inputBitmap->getWidth() == outputBitmap->getWidth() &&
50 inputBitmap->getHeight() <= outputBitmap->getHeight(),
51 "Incompatible input and output bitmaps sizes");
59 "Input and output bitmaps are not attached to the same context");
60 if (shader && !shader->usesContext(inputBitmap->getContext())) {
65 shader =
new ImageShader(inputBitmap->getContext());
67 getGlslDeclarations() +
"\n" +
69 "lowp vec4 " +GLSL_RGBA_INPUT+
" = texture2D(" +
88 unlock(inputBitmap, outputBitmap);
94 const int w = inputBitmap->getWidth();
96 nPix =
w * inputBitmap->getHeight(),
106 shader->prepare(gpu, inputBitmap, outputBitmap);
107 shader->process(gpu);
115 TaskDeviceRequirement::GPU_ONLY : TaskDeviceRequirement::CPU_ONLY;
static ThreadIndex validThreadCount(int number)
Valid thread count from a given integer value.
TaskDeviceRequirement
Specifies which device (CPU and/or GPU) is used to run the task.
virtual std::string getGlslDeclarations() const
Provides GLSL declarations used in the GLSL code.
virtual void beforeProcessing(ThreadIndex threadCount, ProcessingTarget target, GraphicPipeline *gpu)
Instruction called before the task is executed.
virtual TaskDeviceRequirement getUsedDevices() const final
Communicates devices (CPU and/or GPU) the task is run on.
virtual void afterProcessing(ThreadIndex threadCount, GraphicPipeline *gpu, bool aborted)
Instruction called after the task is executed.
virtual bool processOnGPU(GraphicPipeline &gpu, TaskThread &thread) final
Executes the task on GPU.
virtual void setup(bool useGpu)
A callback run every time before the filter is applied to the image.
virtual bool process(TaskThread &thread) final
Executes the task on CPU within a given thread.
ThreadIndex getMaxThreads() const
Gives the upper limint on the number of threads the task may be performed by.
virtual ~PixelwiseFilter()
static const std::string GLSL_RGBA_INPUT
static const char * TEXTURE_COORDINATES_ID
Texture coordinates shader variable name in vertex shader.
Internal low-level GPU control API.
A GLSL program to process images.
static const std::string CODE_HEADER
Shader code header containing necessary declarations.
static const std::string INPUT_IMAGE_ID
Shader variable name referring to the input image.
static void check(const bool condition, const std::string &message)
virtual ThreadIndex numThreads() const =0
ThreadIndex currentThread() const
uint32_t msize
memory size
unsigned char ThreadIndex
number of threads / thread index
jlong jstring jint jint jint jint w