Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

python - How do virtual machines render GUI?

So I have been doing a lot of reading about execution environments (Python's, JVM...) and I am starting to implement one on my own. It is a register-based environment written in C. I have a basic byte code format defined and the execution is going pretty smooth so far. My question is how does VEs render GUIs. In a more detailed description about my work so far, my VE has a screen buffer (experimenting with it). Every time I poke it, I output the screen buffer completely to know the output.

So far so good with basic calculations and stuff but I hit a bump when I wanted to understand how to render GUIs. I am nowhere with this. Any help would be appreciated. Even if I am thinking completely wrong about this, any pointers as a start in the right direction would be really great. Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

All GUI toolkits on Python are a wrapper around C/C++ code. On Java there a some "pure" Java toolkits like Swing, but a the lowest level they depend on C code to do the drawing and handle user input. There's no special support for things like graphics in the Java VM.

As for how the GUI gets rendered at the lowest level, it depends. On Windows, user mode software isn't allowed direct access the video hardware. Ultimately any C/C++ GUI code has to go through either GDI or Direct3D to do the rendering. The kernel mode GDI code is able to do all the rendering itself by writing to the framebuffer, but also supports acceleration by passing operations to display driver. On the other hand, the Direct3D kernel code passes pretty much everything to the driver which in turn passes everything on to the GPU. Almost all of the kernel mode code is written in C, while code running on the GPU is a mixture of hand coded assembly from and code written in higher level shading languages.

Note that GPU assembly language is very different from Intel x86 assembly language, and varies considerably between manufacturers and GPU generations.

I'm not sure what current practice is on Linux and other Unix type operating systems, but it used to be common to give the X server, which is a user mode process, direct access to the framebuffer. C code in the X server was ultimately responsible for rendering. Presumably this has changed at least somewhat now that GPU acceleration is more common.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...