-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pixel_Stream_Base.h
40 lines (33 loc) · 1.06 KB
/
Pixel_Stream_Base.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef MANDELBROT_FRACTAL_DRAWER_BUFFER_BASE_H
#define MANDELBROT_FRACTAL_DRAWER_BUFFER_BASE_H
#include "OpenCL/cl.hpp"
#include <memory>
#include <vector>
#include "Bounds2D.h"
#include "RGB.h"
class Pixel_Stream_Base {
friend class Pixel_Calculator;
// Stores the pixel data
std::vector<RGB> buffer;
protected:
std::vector<RGB> &get_buffer() {
return buffer;
}
// Iterator to where in the buffer the appending is happening
typename std::vector<RGB>::iterator pos_iter;
// Represents the size of the window to which the buffer is writing
std::shared_ptr<Bounds2D<int>> bounds;
public:
Pixel_Stream_Base(std::shared_ptr<Bounds2D<int>> &bnd) :
buffer(bnd->size()), bounds(bnd) { pos_iter = buffer.begin(); }
virtual ~Pixel_Stream_Base() { };
virtual void flush() = 0;
Pixel_Stream_Base &operator<<(RGB &&val) {
if (pos_iter != buffer.end()) {
*(pos_iter) = std::move(val);
++pos_iter;
}
return *this;
}
};
#endif //MANDELBROT_FRACTAL_DRAWER_BUFFER_BASE_H