rust-windowing / winit-blit Goto Github PK
View Code? Open in Web Editor NEWBlit pixels directly onto Winit Windows. See https://github.com/rust-windowing/softbuffer for an up-to-date alternative
License: Apache License 2.0
Blit pixels directly onto Winit Windows. See https://github.com/rust-windowing/softbuffer for an up-to-date alternative
License: Apache License 2.0
The goal of this crate is to have a quick-and-dirty way to throw pixels into a buffer and display them on a window without a significant number of dependencies. Potentially, we'll be able to use this in the Winit examples to clear the screen quickly and get windows showing up with Wayland, but that would require that this work on all the platforms Winit supports.
@vbogaevsky @murarth @vberger @ryanisaacg @mtak- @goddessfreya - would any of you be able to throw together an implementation for the platform you've worked on in Winit? It's totally fine if you're unable or uninterested in working on this, and I have no desire to thrust work onto any of you that you don't want to do. However, you're the people I know I can ping, which seems like a good place to start for getting movement on this crate.
Anyhow, assorted implementation details:
raw-window-handle
. That works fine on Windows, but there may be some friction on other platforms - particularly X11, which uses a #[doc(hidden)]
API to load up Winit's X11 bindings. We should be able to resolve that problem by moving the X11-bindings-loading code into a separate crate that creates a lazy_static
bindings object, which both Winit and winit-blit can depend upon.
Let me know if there are any questions. Thanks!
I think it should be documented which color space the blitted pixels must be in. I'm assuming it's sRGB, but it should be explicitly mentioned.
Almost the crate I was looking for. Thanks a lot for (almost) publishing it. Does exactly what I needed it to do, but needs a bit of polish.
I noticed that it leaks GDI resources, and doesn't properly clean up the device contexts it uses. Both issues can be solved with little effort, and should really be considered in face of a programming language that puts so much emphasis on ownership.
I've implemented a test to verify the GDI leak, but didn't feel like pushing a pull request onto you. If you want to incorporate the test (as well as a fix), I'll happily prepare a pull request.
In PixelBuffer::blit_rect
the call to GetDC
isn't matched with a call to ReleaseDC
to free the GDI resources allocated by the system.
The issue can be observed by running either example, setting up Task Manager to display "GDI objects" from the "Details" tab, and resizing the example window. The GDI object count will continuously grow.
I have implemented both a test to observe the leak as well as a fix. Let me know if you want me to create a PR to merge the changes into this repository.
P.S.: There was another issue in blit_rect
, where the device context wasn't restored to its initial state prior to releasing control over it. While I fixed that, too, I wasn't able to come up with a test for that particular issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.