20 #ifndef OPENXCOM_SHADERDRAWHELPER_H
21 #define OPENXCOM_SHADERDRAWHELPER_H
24 #include "GraphSubset.h"
50 inline Scalar(T& t) : ref(t)
62 template<
typename Pixel>
66 typedef Pixel* PixelPtr;
67 typedef Pixel& PixelRef;
70 const PixelPtr _orgin;
79 _range_base(s._range_base),
80 _range_domain(s.getDomain()),
96 inline ShaderBase(std::vector<Pixel>& f,
int max_x,
int max_y):
98 _range_base(max_x, max_y),
99 _range_domain(max_x, max_y),
105 inline PixelPtr ptr()
const
109 inline int pitch()
const
114 inline void setDomain(
const GraphSubset& g)
116 _range_domain = GraphSubset::intersection(g, _range_base);
118 inline const GraphSubset& getDomain()
const
120 return _range_domain;
122 inline const GraphSubset& getBaseDomain()
const
127 inline const GraphSubset& getImage()
const
129 return _range_domain;
138 template<
typename Pixel>
142 typedef const Pixel* PixelPtr;
143 typedef const Pixel& PixelRef;
146 const PixelPtr _orgin;
155 _range_base(s.getBaseDomain()),
156 _range_domain(s.getDomain()),
165 _range_base(s.getBaseDomain()),
166 _range_domain(s.getDomain()),
182 inline ShaderBase(
const std::vector<Pixel>& f,
int max_x,
int max_y):
184 _range_base(max_x, max_y),
185 _range_domain(max_x, max_y),
191 inline PixelPtr ptr()
const
195 inline int pitch()
const
200 inline void setDomain(
const GraphSubset& g)
202 _range_domain = GraphSubset::intersection(g, _range_base);
204 inline const GraphSubset& getDomain()
const
206 return _range_domain;
208 inline const GraphSubset& getBaseDomain()
const
213 inline const GraphSubset& getImage()
const
215 return _range_domain;
229 typedef Uint8* PixelPtr;
230 typedef Uint8& PixelRef;
233 const PixelPtr _orgin;
242 _range_base(s.getBaseDomain()),
243 _range_domain(s.getDomain()),
257 _orgin((Uint8*) s->getSurface()->pixels),
258 _range_base(s->getWidth(), s->getHeight()),
259 _range_domain(s->getWidth(), s->getHeight()),
260 _pitch(s->getSurface()->pitch)
275 inline ShaderBase(std::vector<Uint8>& f,
int max_x,
int max_y):
277 _range_base(max_x, max_y),
278 _range_domain(max_x, max_y),
284 inline PixelPtr ptr()
const
288 inline int pitch()
const
293 inline void setDomain(
const GraphSubset& g)
295 _range_domain = GraphSubset::intersection(g, _range_base);
297 inline const GraphSubset& getDomain()
const
299 return _range_domain;
301 inline const GraphSubset& getBaseDomain()
const
306 inline const GraphSubset& getImage()
const
308 return _range_domain;
322 typedef const Uint8* PixelPtr;
323 typedef const Uint8& PixelRef;
326 const PixelPtr _orgin;
335 _range_base(s.getBaseDomain()),
336 _range_domain(s.getDomain()),
345 _range_base(s.getBaseDomain()),
346 _range_domain(s.getDomain()),
360 _orgin((Uint8*) s->getSurface()->pixels),
361 _range_base(s->getWidth(), s->getHeight()),
362 _range_domain(s->getWidth(), s->getHeight()),
363 _pitch(s->getSurface()->pitch)
378 inline ShaderBase(
const std::vector<Uint8>& f,
int max_x,
int max_y):
380 _range_base(max_x, max_y),
381 _range_domain(max_x, max_y),
387 inline PixelPtr ptr()
const
391 inline int pitch()
const
396 inline void setDomain(
const GraphSubset& g)
398 _range_domain = GraphSubset::intersection(g, _range_base);
400 inline const GraphSubset& getDomain()
const
402 return _range_domain;
404 inline const GraphSubset& getBaseDomain()
const
409 inline const GraphSubset& getImage()
const
411 return _range_domain;
418 template<
typename SurfaceType>
442 inline void mod_y(
int& begin,
int& end);
443 inline void set_y(
const int& begin,
const int& end);
447 inline void mod_x(
int& begin,
int& end);
448 inline void set_x(
const int& begin,
const int& end);
451 inline int& get_ref();
477 inline void mod_y(
int&,
int&)
481 inline void set_y(
const int&,
const int&)
491 inline void mod_x(
int&,
int&)
495 inline void set_x(
const int&,
const int&)
532 inline void mod_y(
int&,
int&)
536 inline void set_y(
const int&,
const int&)
545 inline void mod_x(
int&,
int&)
549 inline void set_x(
const int&,
const int&)
558 inline const int& get_ref()
564 template<
typename PixelPtr,
typename PixelRef>
575 const std::pair<int, int> step;
579 data(base + d.beg_x*s.first + d.beg_y*s.second),
580 ptr_pos_y(0), ptr_pos_x(0),
582 start_x(), start_y(),
596 r = GraphSubset::intersection(range, r);
601 start_x = r.beg_x - range.beg_x;
602 start_y = r.beg_y - range.beg_y;
606 inline void mod_y(
int&,
int&)
608 ptr_pos_y = data + step.first * start_x + step.second * start_y;
610 inline void set_y(
const int& begin,
const int&)
612 ptr_pos_y += step.second*begin;
616 ptr_pos_y += step.second;
620 inline void mod_x(
int&,
int&)
622 ptr_pos_x = ptr_pos_y;
624 inline void set_x(
const int& begin,
const int&)
626 ptr_pos_x += step.first*begin;
630 ptr_pos_x += step.first;
633 inline PixelRef get_ref()
641 template<
typename Pixel>
644 typedef typename ShaderBase<Pixel>::PixelPtr PixelPtr;
645 typedef typename ShaderBase<Pixel>::PixelRef PixelRef;
helper class for handling implementation differences in different surfaces types Used in function Sha...
Definition: ShaderDrawHelper.h:419
ShaderBase(const ShaderBase< Pixel > &s)
copy constructor
Definition: ShaderDrawHelper.h:163
ShaderBase(const ShaderBase &s)
copy constructor
Definition: ShaderDrawHelper.h:77
ShaderBase(Surface *s)
create surface using surface s as data source.
Definition: ShaderDrawHelper.h:256
const GraphSubset & get_range()
function used only when SurfaceType can be used as destination surface if that type should not be use...
ShaderBase(std::vector< Pixel > &f, int max_x, int max_y)
create surface using vector f as data source.
Definition: ShaderDrawHelper.h:96
ShaderBase(const std::vector< Pixel > &f, int max_x, int max_y)
create surface using vector f as data source.
Definition: ShaderDrawHelper.h:182
ShaderBase(const ShaderBase< Uint8 > &s)
copy constructor
Definition: ShaderDrawHelper.h:343
ShaderBase(const ShaderBase &s)
copy constructor
Definition: ShaderDrawHelper.h:333
This is surface argument to ShaderDraw.
Definition: ShaderDrawHelper.h:226
void set_range(const GraphSubset &g)
set final drawing range.
ShaderBase(const ShaderBase &s)
copy constructor
Definition: ShaderDrawHelper.h:240
ShaderBase(const ShaderBase &s)
copy constructor
Definition: ShaderDrawHelper.h:153
This is empty argument to ShaderDraw.
Definition: ShaderDrawHelper.h:36
Element that is blit (rendered) onto the screen.
Definition: Surface.h:39
Definition: GraphSubset.h:31
This is surface argument to ShaderDraw.
Definition: ShaderDrawHelper.h:63
This is scalar argument to ShaderDraw.
Definition: ShaderDrawHelper.h:46
ShaderBase(std::vector< Uint8 > &f, int max_x, int max_y)
create surface using vector f as data source.
Definition: ShaderDrawHelper.h:275
ShaderBase(const Surface *s)
create surface using surface s as data source.
Definition: ShaderDrawHelper.h:359
Definition: ShaderDrawHelper.h:565
void mod_range(GraphSubset &g)
function used only when SurfaceType is used as source surface.
ShaderBase(const std::vector< Uint8 > &f, int max_x, int max_y)
create surface using vector f as data source.
Definition: ShaderDrawHelper.h:378