c++ - Switching *pointers instead of using BitBlt() in winAPI?
问题描述
As I read, BitBlt() function from winGDI from winAPI is the fastest to put some image on the screen. But "blitting" only copies a memory from one source to a destination.
So I was wondering, why we can't just have two bitmaps (buffers) and just switching the pointers that will point to the current buffer if it is complete. Like Double Buffering. It would be faster than mem copiyng.
Is it possible in winAPI?
解决方案
The BitBlt method in GDI is to copy the contents of the back buffer to the redirection surface. A more efficient method has been implemented in directx.
The runtime uses the bit-block transfer (bitblt) and flip presentation models to present graphics content on display monitors. The biggest difference between bitblt and flip presentation models is how back-buffer contents get to the Windows 8 DWM for composition. In the bitblt model, contents of the back buffer are copied into the redirection surface on each call to IDXGISwapChain1::Present1. In the flip model, all back buffers are shared with the Desktop Window Manager (DWM). Therefore, the DWM can compose straight from those back buffers without any additional copy operations. In general, the flip model is more efficient. The flip model also provides more features, such as enhanced present statistics.
If you have legacy components that use Windows Graphics Device Interface (GDI) to write to an HWND directly, use the bitblt model.
For more details, please refer: Comparing the DXGI flip model and the BitBlt model
This article also gives a detailed explanation.
推荐阅读
- numpy - 在 numpy 中创建倾斜/连续移位矩阵的最快方法
- r - 如何将此向量转换为数据框?
- javascript - 异步和承诺函数在我的 res.json 调用中不显示任何内容
- html - 如果包含的元素的大小太大,如何减少 div 的左边距?
- javascript - 根据 React 中的下拉菜单值在 iframe 之间切换
- java - 当我使用reference.removeValue 时,布尔变量总是返回true
- javascript - 验证对象是否有字符串
- python - 输入数组并将其循环到数据框 Pandas
- python - 在特定条件下复制一行
- javascript - 将两个 Observable 合并为一个相同类型的 Observable