Beatmup
Kernels::BinaryOpBody< in_t, out_t > Class Template Reference

Static Public Member Functions

static void process (in_t op1, in_t op2, out_t out, BitmapBinaryOperation::Operation operation, int width, int height, const IntPoint &op1Origin, const IntPoint &op2Origin, const IntPoint &outOrigin, const TaskThread &tt)
 Performs a binary operation on two bitmaps. More...
 
static void processAlignedBinaryMask (in_t op1, in_t op2, out_t out, BitmapBinaryOperation::Operation operation, int width, int height, const IntPoint &op1Origin, const IntPoint &op2Origin, const IntPoint &outOrigin, const TaskThread &tt)
 Performs a binary operation on two binary masks. More...
 

Detailed Description

template<class in_t, class out_t>
class Kernels::BinaryOpBody< in_t, out_t >

Definition at line 29 of file operator.cpp.

Member Function Documentation

◆ process()

template<class in_t , class out_t >
static void Kernels::BinaryOpBody< in_t, out_t >::process ( in_t  op1,
in_t  op2,
out_t  out,
BitmapBinaryOperation::Operation  operation,
int  width,
int  height,
const IntPoint op1Origin,
const IntPoint op2Origin,
const IntPoint outOrigin,
const TaskThread tt 
)
inlinestatic

Performs a binary operation on two bitmaps.

Definition at line 35 of file operator.cpp.

43  {
45  return;
46 
47  for (int y = tt.currentThread(); y < height; y += tt.numThreads()) {
48  op1.goTo(op1Origin.x, op1Origin.y + y);
49  op2.goTo(op2Origin.x, op2Origin.y + y);
50  out.goTo(outOrigin.x, outOrigin.y + y);
51 
52  switch (operation) {
53  case BitmapBinaryOperation::Operation::ADD:
54  for (int x = 0; x < width; ++x, op1++, op2++, out++) {
55  out = op1() + op2();
56  }
57  break;
58 
59  case BitmapBinaryOperation::Operation::MULTIPLY:
60  for (int x = 0; x < width; ++x, op1++, op2++, out++) {
61  out = op1() * op2();
62  }
63  break;
64 
65  default: return;
66  }
67 
68  if (tt.isTaskAborted())
69  return;
70  }
71  }
virtual ThreadIndex numThreads() const =0
ThreadIndex currentThread() const
Definition: parallelism.h:165
virtual bool isTaskAborted() const =0
Returns true if the task is asked to stop from outside.
@ NONE
no extension
Definition: program.h:64
jobject jlong jint jint y
jlong jint width
jlong jint jint height
jobject jlong jint x
JNIEnv jlong jint out
Beatmup::IntPoint outOrigin(left, top)
jlong jobject jobject jobject op2Origin
jlong jobject jobject op1Origin

◆ processAlignedBinaryMask()

template<class in_t , class out_t >
static void Kernels::BinaryOpBody< in_t, out_t >::processAlignedBinaryMask ( in_t  op1,
in_t  op2,
out_t  out,
BitmapBinaryOperation::Operation  operation,
int  width,
int  height,
const IntPoint op1Origin,
const IntPoint op2Origin,
const IntPoint outOrigin,
const TaskThread tt 
)
inlinestatic

Performs a binary operation on two binary masks.

Definition at line 77 of file operator.cpp.

85  {
87  return;
88 
89  BEATMUP_ASSERT_DEBUG(op1Origin.x % 8 == 0);
90  BEATMUP_ASSERT_DEBUG(op2Origin.x % 8 == 0);
92 
93  for (int y = tt.currentThread(); y < height; y += tt.numThreads()) {
94  int x = 0;
95 
96  // running aligned part first
97  op1.goTo(op1Origin.x, op1Origin.y + y);
98  op2.goTo(op2Origin.x, op2Origin.y + y);
99  out.goTo(outOrigin.x, outOrigin.y + y);
100 
102  *p1 = (pixint_platform*)*op1,
103  *p2 = (pixint_platform*)*op2,
104  *po = (pixint_platform*)*out;
105 
106  static const int step = 8 * sizeof(pixint_platform);
107 
108  switch (operation) {
109  case BitmapBinaryOperation::Operation::ADD:
110  for (x = 0; x + step <= width; x += step, p1++, p2++, po++) {
111  *po = *p1 | *p2;
112  }
113  break;
114 
115  case BitmapBinaryOperation::Operation::MULTIPLY:
116  for (x = 0; x + step <= width; x += step, p1++, p2++, po++) {
117  *po = *p1 & *p2;
118  }
119  break;
120 
121  default: return;
122  }
123 
124  // if unaligned reminder, deal with it
125  if (x < width) {
126  op1.goTo(op1Origin.x + x, op1Origin.y + y);
127  op2.goTo(op2Origin.x + x, op2Origin.y + y);
128  out.goTo(outOrigin.x + x, outOrigin.y + y);
129 
130  switch (operation) {
131  case BitmapBinaryOperation::Operation::ADD:
132  for (; x < width; ++x, op1++, op2++, out++) {
133  out = op1() + op2();
134  }
135  break;
136 
137  case BitmapBinaryOperation::Operation::MULTIPLY:
138  for (; x < width; ++x, op1++, op2++, out++) {
139  out = op1() * op2();
140  }
141  break;
142 
143  default: return;
144  }
145 
146  }
147 
148  if (tt.isTaskAborted())
149  return;
150  }
151  }
#define BEATMUP_ASSERT_DEBUG(C)
Definition: exception.h:163
uint32_t pixint_platform
Definition: basic_types.h:31
jlong jint jfloat step

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