29 #include YFM_YSLib_Service_YGDI
30 #include YFM_YSLib_Service_YBlit
31 #include YFM_YSLib_Service_YPixel
33 using namespace ystdex;
61 if(!clip.IsUnstrictlyEmpty() &&
Clip(clip, bounds))
62 return clip.GetPoint() - bounds.GetPoint();
63 clip.GetSizeRef() = {};
70 const Size& ds(pc.Target.GetSize());
72 if(GetHorizontalOf(m) < ds.Width &&
GetVerticalOf(m) < ds.Height)
74 const auto& pt(pc.Location);
75 const Point dp(max<int>(m.
Left, pt.X), max<int>(m.
Top, pt.Y));
76 const Point sp(dp - pt);
77 const auto scx(min<int>(ss.
Width, ds.Width - m.
Right - dp.
X) - sp.
X),
80 if(scx > 0 && scy > 0)
82 pc.ClipArea &=
Rect(dp, scx, scy);
83 return pc.ClipArea.GetPoint() - pt;
86 pc.ClipArea.GetSizeRef() = {};
97 std::copy_n(i,
GetAreaOf(GetSize()), pBuffer);
106 if(
const auto p = buf.GetBufferPtr())
129 unique_ptr<PixelType[]> p_new(
YB_LIKELY(area != 0) ?
new PixelType[area]
131 unique_ptr<PixelType[]> p_old(
pBuffer);
135 catch(std::bad_alloc&)
168 if(
const auto p = buf.GetBufferPtr())
171 std::copy_n(buf.GetBufferAlphaPtr(),
GetAreaOf(GetSize()),
176 : CompactPixmap(std::move(buf)), pBufferAlpha(buf.GetBufferAlphaPtr())
178 buf.pBufferAlpha = {};
188 unique_ptr<PixelType[]> p_new(
YB_LIKELY(area != 0) ?
new PixelType[area]
190 unique_ptr<AlphaType[]> p_new_alpha(
YB_LIKELY(area != 0)
192 unique_ptr<PixelType[]> p_old(pBuffer);
193 unique_ptr<AlphaType[]> p_old_alpha(pBufferAlpha);
195 pBuffer = p_new.release();
196 pBufferAlpha = p_new_alpha.release();
198 catch(std::bad_alloc&)
200 throw LoggedEvent(
"CompactPixmapEx allocation failed.",
Alert);
202 YAssert(
bool(pBuffer) == (area != 0),
"Buffer corruptied.");
203 YAssert(
bool(pBufferAlpha) == (area != 0),
"Buffer corruptied.");
221 if(~rot & 1 && dst &&
bool(g))
225 ds, g.GetSize(), dp, sp, sc);
228 ds, g.GetSize(), dp, sp, sc);
237 if(~rot & 1 && dst &&
bool(buf))
241 IteratorPair(buf.GetBufferPtr(), buf.GetBufferAlphaPtr()), ds,
242 buf.GetSize(), dp, sp, sc);
245 IteratorPair(buf.GetBufferPtr(), buf.GetBufferAlphaPtr()), ds,
246 buf.GetSize(), dp, sp, sc);
256 if(~rot & 1 && dst &&
bool(buf))
260 IteratorPair(buf.GetBufferPtr(), buf.GetBufferAlphaPtr()), ds,
261 buf.GetSize(), dp, sp, sc);
264 IteratorPair(buf.GetBufferPtr(), buf.GetBufferAlphaPtr()), ds,
265 buf.GetSize(), dp, sp, sc);
h void SetSize(const Size &) override
重新设置缓冲区大小。
bool Clip(Rect &x, const Rect &y)
剪切操作:取标准矩形交集并判断是否严格非空。
YF_API Padding FetchMargin(const Rect &, const Size &)
取内边界相对于外边界的边距。
SDst GetVerticalOf(const Padding &m)
取竖直边距和。
BitmapPtr pBuffer
显示缓冲区指针。
_tOut ClearPixel(_tOut dst, size_t n) ynothrow
清除指定位置的 n 个连续像素。
YF_API void ClearImage(const Graphics &)
清除图形接口上下文缓冲区。
yconstfn auto GetAreaOf(const Size &s) ynothrow-> decltype(s.Width *s.Height)
取面积。
YF_API Point ClipBounds(Rect &, const Rect &)
根据指定源的边界优化绘制上下文的剪切区域。
std::uint16_t SDst
屏幕坐标距离。
virtual void ClearImage() const
清除缓冲区。
void SetSizeSwap()
交换宽和高;同时清除缓冲区。
CompactPixmapEx(ConstBitmapPtr, SDst, SDst)
构造:使用指定位图指针和大小。
ystdex::pair_iterator< ConstBitmapPtr, const AlphaType * > IteratorPair
Alpha 光栅化源迭代器对。
void swap(any &x, any &y)
交换对象。
sizeof(AlphaType)*GetAreaOf(GetSize())) using CompactPixmap void SetSize(const Size &) override
重新设置缓冲区大小。
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
*this void SetContent(ConstBitmapPtr, SDst, SDst)
设置内容。
Rect operator+(const Rect &r, const Padding &m)
YF_API Point ClipMargin(PaintContext &, const Padding &, const Size &)
根据指定边距和源的大小优化绘制上下文的剪切区域。
YF_API bool CopyTo(BitmapPtr, const CompactPixmapEx &, const Size &, const Point &, const Point &, const Size &, Rotation=RDeg0)
位图缓冲区向指针指定的缓冲区复制。
const PixelType * ConstBitmapPtr
CompactPixmap(unique_ptr< PixelType[]>, const Size &) ynothrow
构造:使用指定位图指针和大小。
#define YAssert(_expr, _msg)
YF_API bool BlitTo(BitmapPtr, const CompactPixmapEx &, const Size &, const Point &, const Point &, const Size &, Rotation=RDeg0)
贴图:位图缓冲区向指针指定的缓冲区以贴图算法复制。