28 #ifndef YSL_INC_Service_yblit_h_
29 #define YSL_INC_Service_yblit_h_ 1
32 #include YFM_YSLib_Core_YGDIBase
33 #include YFM_YSLib_Core_YCoreUtilities
50 template<
typename _tPixel>
68 template<
typename _tOut>
88 template<
typename _tOut,
class _fTransformPixel>
90 operator()(_tOut dst,
size_t n, _fTransformPixel tp)
const
95 "Invalid iterator found.");
96 for(
const auto e(dst + n); dst != e; ++dst)
113 template<
typename _tOut,
class _fTransformPixel>
120 "Invalid iterator found.");
153 return d < 0 ? 0 : d;
159 return d < 0 ? 0 : d + delta - 1;
184 template<
bool _bDec,
typename _tScalar,
typename _tDiff,
typename _tOut,
185 typename _tIn,
typename _fBlitLoop>
187 BlitScan(_fBlitLoop loop, _tOut dst, _tIn src, _tScalar d_width,
188 _tScalar s_width, _tDiff delta_x, _tDiff delta_y)
190 loop(dst, src, delta_x, delta_y, (_bDec ? -1 : 1) * d_width - delta_x,
228 template<
bool _bSwapLR,
bool _bSwapUD,
typename _tOut,
typename _tIn,
231 Blit(_fBlitLoop loop, _tOut dst, _tIn src,
const Size& ds,
const Size& ss,
234 SDst min_x, min_y, delta_x, delta_y;
236 if(
BlitBounds(dp, sp, ds, ss, sc, min_x, min_y, delta_x, delta_y))
237 BlitScan<_bSwapLR != _bSwapUD>(loop, dst + BlitScaleComponent<_bSwapUD>(
238 dp.
Y - (sp.
Y < 0 ? sp.
Y : 0), delta_y) * ds.
Width
239 + BlitScaleComponent<_bSwapLR>(dp.
X - (sp.
X < 0 ? sp.
X : 0),
251 template<
bool _bPositiveScan>
255 template<
typename _tOut,
typename _tIn,
typename _fBlitScanner>
257 operator()(_fBlitScanner scanner, _tOut dst_iter, _tIn src_iter,
262 scanner(dst_iter, src_iter, delta_x);
264 ystdex::delta_assign<_bPositiveScan>(dst_iter, dst_inc);
291 template<
bool _bSwapLR,
bool _bSwapUD,
typename _tOut,
typename _tIn,
292 typename _fBlitScanner>
297 using namespace std::placeholders;
300 ), scanner, _1, _2, _3, _4, _5, _6), dst, src, ds, ss, dp, sp, sc);
311 template<
bool _bPositiveScan>
314 template<
typename _tOut,
typename _tIn,
typename _fPixelShader>
316 operator()(_fPixelShader shader, _tOut& dst_iter, _tIn& src_iter,
319 for(
SDst x(0); x < delta_x; ++x)
321 shader(dst_iter, src_iter);
323 ystdex::xcrease<_bPositiveScan>(dst_iter);
351 template<
bool _bSwapLR,
bool _bSwapUD,
typename _tOut,
typename _tIn,
352 typename _fPixelShader>
357 BlitLines<_bSwapLR, _bSwapUD, _tOut, _tIn>(
358 [shader](_tOut& dst_iter, _tIn& src_iter,
SDst delta_x){
360 }, dst, src, ds, ss, dp, sp, sc);
377 template<
typename _tOut,
class _fTransformPixel,
class _fTransformLine>
380 _fTransformPixel tp, _fTransformLine tl)
382 Blit<false, false>([&](_tOut dst_iter, _tOut,
SDst delta_x,
386 tl(dst_iter, delta_x, tp);
387 dst_iter += dst_inc + delta_x;
389 }, dst, dst, ds, ds, dp, dp, sc);
391 template<
typename _tOut,
class _fTransformPixel,
class _fTransformLine>
396 operator()<_tOut, _fTransformPixel, _fTransformLine>(dst, ds,
397 r.GetPoint(), r.GetSize(), tp, tl);
399 template<
typename _tOut,
class _fTransformPixel,
class _fTransformLine>
402 SDst w,
SDst h, _fTransformPixel tp, _fTransformLine tl)
404 operator()<_tOut, _fTransformPixel, _fTransformLine>(dst, {dw, dh},
405 {x, y}, {w, h}, tp, tl);
422 template<
typename _tOut>
433 template<
typename _tPixel,
typename _tOut>
443 template<
typename _tPixel,
typename _tOut>
456 template<
typename _tPixel,
typename _tOut>
464 template<
typename _tPixel,
typename _tOut>
471 template<
typename _tPixel,
typename _tOut>
489 template<
bool _bPositiveScan>
492 template<
typename _tOut,
typename _tIn>
496 std::copy_n(src_iter, delta_x, dst_iter);
497 yunseq(src_iter += delta_x, dst_iter += delta_x);
505 template<
typename _tOut,
typename _tIn>
510 *dst_iter-- = *src_iter++;
527 template<
class _fTransformPixel>
544 template<
class _fTransformPixel>
548 return TransformRect<_fTransformPixel>(
g, r.GetPoint(), r.GetSize(), tp);
PixelFiller(_tPixel c)
构造:使用指定颜色。
void Blit(_fBlitLoop loop, _tOut dst, _tIn src, const Size &ds, const Size &ss, const Point &dp, const Point &sp, const Size &sc)
贴图函数模板。
void operator()(_tOut dst, SDst dw, SDst dh, SPos x, SPos y, SDst w, SDst h, _fTransformPixel tp, _fTransformLine tl)
void FillVerticalLine(_tOut dst, size_t n, SDst dw, _tPixel c)
使用 n 个指定像素竖直填充指定位置。
_tOut ClearPixel(_tOut dst, size_t n) ynothrow
清除指定位置的 n 个连续像素。
YF_API void ClearImage(const Graphics &)
清除图形接口上下文缓冲区。
void BlitLines(_fBlitScanner scanner, _tOut dst, _tIn src, const Size &ds, const Size &ss, const Point &dp, const Point &sp, const Size &sc)
扫描线贴图函数模板。
void BlitScan(_fBlitLoop loop, _tOut dst, _tIn src, _tScalar d_width, _tScalar s_width, _tDiff delta_x, _tDiff delta_y)
贴图扫描函数模板。
void ClearSequence(_tOut dst, size_t n) ynothrow
清除指定的连续对象。
void operator()(_tOut &dst_iter, _tIn &src_iter, SDst delta_x) const
void operator()(_fPixelShader shader, _tOut &dst_iter, _tIn &src_iter, SDst delta_x)
std::uint16_t SDst
屏幕坐标距离。
void operator()(_tOut &dst_iter, _tIn &src_iter, SDst delta_x) const
YF_API bool BlitBounds(const Point &, const Point &, const Size &, const Size &, const Size &, SDst &, SDst &, SDst &, SDst &)
贴图边界计算器。
void operator()(_tOut dst, const Size &ds, const Rect &r, _fTransformPixel tp, _fTransformLine tl)
void operator()(_fBlitScanner scanner, _tOut dst_iter, _tIn src_iter, SDst delta_x, SDst delta_y, SPos dst_inc, SPos src_inc) const
#define yunseq
无序列依赖表达式组求值。
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
void FillRectRaw(_tOut dst, const Size &ds, const Point &sp, const Size &sc, _tPixel c)
使用指定像素填充指定的标准矩形区域。
void operator()(_tOut dst, size_t n, SDst dw, _fTransformPixel tp) const
渲染竖直线上的像素。
#define yconstfn
指定编译时常量函数。
YF_API void Fill(const Graphics &, Color)
使用指定颜色填充图形接口上下文缓冲区。
yconstfn size_t BlitScaleComponent(SPos d, SDst)
贴图偏移分量计算器。
bool is_undereferenceable(const any_input_iterator< _type, _tDifference, _tPointer, _tReference > &i)
void operator()(_tOut dst)
像素填充函数。
void operator()(_tOut dst, size_t n, _fTransformPixel tp) const
渲染连续像素。
void FillPixel(_tOut dst, size_t n, _tPixel c)
使用 n 个指定像素连续填充指定位置。
void BlitPixels(_fPixelShader shader, _tOut dst, _tIn src, const Size &ds, const Size &ss, const Point &dp, const Point &sp, const Size &sc)
像素贴图函数模板。
bool TransformRect(const Graphics &g, const Point &pt, const Size &s, _fTransformPixel tp)
以像素为单位变换标准矩形。
YF_API void CopyBuffer(const Graphics &, const Graphics &)
以第一个参数作为目标,复制第二个参数的缓冲区内容。
void operator()(_tOut dst, const Size &ds, const Point &dp, const Size &sc, _fTransformPixel tp, _fTransformLine tl)
渲染标准矩形内的像素。
#define YAssert(_expr, _msg)
yconstfn size_t BlitScaleComponent< true >(SPos d, SDst delta)