This project is in the process of migrating to chromium version
120
(branch 6099), please choose the appropriate branch for your needs and make sure chromium switches to the corresponding branch as well (you will need to runglcient sync
to sync the code after the switch). If you are interested in this, please feel free to contact me in the Discussions channel. I have built a WeChat group, used to facilitate technical discussions, if you are interested, welcome to add my WeChat, I will pull you into the discussion group. WeChat:
This project is used to demonstrate how to use some basic mechanisms in chromium, including asynchronous multitasking, mojo, multi-process, viz, cc, gl etc.
Tips:
- If you are new to chromium, it is recommended to study these demos in order.
- These demos are ONLY tested on Linux and Android. The list of supported demos for each platform can be found in the BUILD.gn file.
- The label in front of the demo list below indicates the highest supported chromium version of the demo, e.g.
M120
means chromium 120 is supported, demos without labels mean that they are only verified on chromium 80.- Feel free to submit new demos for PR or migrate these demos to other chromium versions.
- Due to limited resources, the project updates its kernel once a year, approximately every 10 versions.
Demo list:
- [M120]
demo_exe
: The simplest demo to demonstrate gn and create your own exe; - [M120]
demo_log
: Demo log library; - [M120]
demo_tracing_console
: Demonstrate using Trace to output to the console; - [M120]
demo_task_thread_pool
: Demonstrate the use of thread pool ThreadPool; - [M120]
demo_task_executor
: Demonstrate using the message loop SingleThreadTaskExecutor; - [M120]
demo_task_thread
: Demonstrates the use of a task in a new thread; - [M120]
demo_callback
: Demo Bind&Callback related content; - [M120]
demo_linktest
: Demonstrates incorrect use of gn causing link errors; - [M120]
demo_mojo_single_process
: Demonstrate the use of themojo
library in a single process; - [M120]
demo_mojo_multiple_process
: Demonstrate the use of themojo
library in multiple processes; - [M120]
demo_mojo_multiple_process_binding
: Demonstrate using the binding layer of themojo
library in multiple processes; - [M91]
demo_services
: Demonstrate the use of servcies and multi-process architecture based onmojo
; - [M120]
demo_ipc
: Demonstrate the use of IPC interface based onmojo
; - [M91]
demo_mojo_v8
: Demonstrate the use of js to access the mojo interface; - [M120]
demo_memory
: Demonstrate the use of SharedMemory; - [M120]
demo_tracing_perfetto
: Demonstrate the output of Trace as Json format (used to interface with perfetto); - [M120]
demo_tracing_perfetto_content
: Demonstrate how the content module is connected to perfetto; - [M120]
demo_resources
: Demo resources related content, including grit, l10n, pak, etc.; - [M120]
demo_gl
: Demonstrate using//ui/gl
for GPU rendering; - [M120]
demo_viz_gui
: Demonstrate usingviz
to display the GUI interface; - [M120]
demo_viz_offscreen
: Demonstrate usingviz
for off-screen rendering; demo_viz_gui_gpu
: Demonstrate the use ofviz
for hardware accelerated rendering;demo_viz_layer
: Demonstrate the use ofviz
for interactive rendering;demo_viz_layer_offscreen
, demonstrate using VIZ'sCopyOutput
interface for off-screen rendering;- [M120]
demo_cc_gui
: Demonstrate usingcc
to display GUI interface; - [M120]
demo_cc_offscreen
: Demonstrate usingcc
for off-screen rendering; - [M120]
demo_views
: Demonstrate the use of//ui/views
to create UI; demo_apk
: Demonstrate the creation of Android applications, the use of base::android::* and JNI;demo_android_skia
: Demonstrate the use of Skia for software rendering and hardware rendering on Android;- [M120]
demo_skia
: Demonstrate the use of Skia for software rendering and hardware rendering on Linux; demo_x11
: Demonstrate using X11 to create transparent windows;demo_x11_glx
: Demonstrate the use of glx in a transparent window;demo_x11_egl
: Demonstrate the use of egl in a transparent window;- [M120]
demo_gin
: Demonstrate the use of gin to create a javascript runtime; demo_shell
: Demonstrate the use of content api to create a streamlined browser that supports Linux and Android;
Documents:
Public documents are in the docs directory, and other documents are in the corresponding directory of the code.
-
Go to the
src
directory of chromium and switch to a supported branch, such as120.0.6099.40
for version 120 or91.0.4472.144
for version 91 (the last version number does not matter). And rungclient sync
to synchronize the code. -
Run the following command to clone this repository to the
src/demo
directory and switch to the corresponding branch, e.g.c/120.0.6099
for version 120 orc/91.0.4472
for version 91.git clone <address of current repository> demo git checkout <the branch>
-
Find the
out/Default/args.gn
file in your compilation output directory and add the following parameters:# add extra deps to gn root root_extra_deps = ["//demo"] # disable warnings as errors treat_warnings_as_errors = false # If you want to compile the demo of android platform, you need to add the following parameters # target_os="android" # target_cpu="arm64" # Other architectures can be selected as needed x86, x64, arm, mipsel
-
Run
ninja -C out/Default <name in demo list>
to generate the required demo (see BUILD.gn), for example using the namedemo_exe
to generate the demo_exe program. Or usedemo
to generate all programs.
REPEAT: These demos are ONLY tested on Linux and Android.
- Add v8 related demo to demonstrate how to inject js objects/methods into v8;
- Improve the documentation of the process initialization part (docs/startup.md);
- Improve the documentation of the UI part (docs/ui.md);
- Improve the documentation of the content module (docs/content.md);
- Improve the documentation of demo_shell (demo_shell/README.md);
- Add demo to demonstrate how to create aar component;
- Add demo to demonstrate how to use aura to create UI interface;
- Add demo to demonstrate how to use PlatformWindow to create UI interface;
- Add demo to demonstrate how to implement off-screen rendering of web pages;
- Add a demo to demonstrate how to inject new JS objects into Blink;
- Add a demo to demonstrate the principle of
navigator.mediaDevices.getUserMedia()
; - Add a demo to demonstrate the principle of
tab capture api
;
- Add demo_task_thread, which demonstrates the use of a task in a new thread;
Migrate some demos to M120, the upgrade is described below:
ThreadTaskRunnerHandle
was replaced bySingleThreadTaskRunner
;- The
TRACE_*
macro enables the perfetto client library by default; - mojo enables ipcz by default, and parameters must be passed for multi-process initialization;
- The gl initialization interface supports selecting GPU;
- The
SharedQuadState::SetAll
interface supports setting fast_rounded_corner; viz::TransferableResource
supports a clearer distinction between single-plane and multi-plane resources;- In order to reduce the number of viz PostTasks,
CompositorFrameSinkClient::OnBeginFrame
merges the functions ofReclaimResources
andDidReceiveCompositorFrameAck
; - Deleted the
SkEncodeImage
interface and replaced it withSkXXXEncoder::Encode
; - Skia moved the DDL-related interfaces to chromium private and renamed them. The public DDL interface will no longer be provided in the future. After the change, only ganesh supports DrawDDL, and graphite does not.
- Add demo_linktest, demonstrates incorrect use of gn causing link errors;
- Migrate demo_skia to M110;
- Migrate demo_views to M110;
- Migrate demo_cc_offscreen to M110;
- Migrate demo_gin to M110;
- Migrate demo_viz_gui to M110;
- Update 110 branch to 5481;
- Migrate some demo to M110;
- Add demo_gin,demonstrate how to use gin to create a javascript runtime;
- Add demo_mojo_v8,demonstrate how to use js in the render process to access the mojo interface provided by the browser process;
- Migrate demo_views to M91;
- Migrate demo_cc_offscreen to M91;
- Migrate demo_viz_offscreen to M91;
- Migrate demo_ipc to M91;
- Migrate demo_services to M91;
- Migrate demo_gl to M91;
- Migrate below demos to M91:
- demo_resources
- Migrate below demos to M91:
- demo_memory
- Migrate below demos to M91:
- demo_exe
- demo_tracing_perfetto
- demo_tracing_perfetto_content
- demo_messageloop
- demo_tasks
- demo_mojo_single_process
- demo_mojo_multiple_process
- demo_mojo_multiple_process_binding
- Rename below demos:
- demo_messageloop to demo_task_executor
- demo_tasks to demo_task_thread_pool
- Add demo_gl, the demo uses the
//ui/gl
module to call GL for rendering;
- demo_viz_layer_offscreen supports off-screen rendering using the SkiaOutputDeviceOffscreen interface;
- Add demo_viz_layer_offscreen to demonstrate using VIZ's CopyOutput interface for off-screen rendering;
- Add demo_viz_layer, demonstrate the use of VIZ for handwriting writing, and support the use of command lines to switch between software and hardware rendering;
- Add demo_viz_gui_gpu to demonstrate the use of VIZ for hardware accelerated rendering and VIZ Client nesting;
- Add demo_x11_glx and demo_x11_egl;
- Add demo_x11 to demonstrate the use of X11 to create transparent windows;
- Update demo_skia, use software rendering by default, support transparent windows, GL rendering supports GL_RGB565 pixel format;
- Add demo_skia to demonstrate the software/hardware rendering using Skia in Linux;
- Update demo_android_skia, add multi-thread rendering and frame rate synchronization;
- Add demo_android_skia to demonstrate the use of Skia in Android for software/hardware rendering;
- Add demo_tracing_perfetto_content to demonstrate how the content module saves trace to a file, which can be used for chrome://tracing;
- Add demo_tracing documentation demo_tracing;
- Move demo_tracing to demo_tracing folder and rename it to demo_tracing_console, add Flush function;
- Add demo_tracing_perfetto to demonstrate the integration and use of trace and perfetto;
- Add demo_cc_gui to demonstrate using
cc
to display GUI interface;
- Added TRACE.txt of demo_cc to help understand the runtime behavior of cc;
- Add demo_cc_offscreen, demonstrate the use of
cc
for off-screen rendering;
- Add demo_viz_offscreen, demonstrate using
viz
for off-screen rendering; - Modify demo_viz to demo_viz_gui, the function is unchanged;
- Add demo_viz, demonstrate using
viz
module; - Add documentation for
viz
: viz
- Add demo_views, demonstrate using
//ui/views
to develop UI;
- demo_apk supports JNI to call instance method of C++ class;
- Add document: [browser startup process brief description] (./docs/startup.md)
- demo_apk supports JNI;
- Add document: demo_apk
- Add demo_tracing to demonstrate the use of trace;
- Add demo_apk to demonstrate how to use gn to create Android applications;
- Add demo_shell to demonstrate how to use the Content API to create a streamlined browser;
Add the following demo and related documents:
- demo_exe: the simplest demo, demonstrate gn and create your own exe;
- demo_log: demonstrate the use of log library;
- demo_tracing: demonstrate the use of Trace;
- demo_tasks: demonstrate the use of thread pool ThreadPool;
- demo_messageloop: demonstrate the use of message loop MessageLoop;
- demo_mojo_single_process: demonstrate the use of mojo library in a single process;
- demo_mojo_multiple_process: demonstrate the use of the mojo library in multiple processes;
- demo_mojo_multiple_process_binding: demonstrate the use of the binding layer of the mojo library in multiple processes;
- demo_services: demonstrate the use of mojo-based servcies and multi-process architecture;
- demo_ipc: demonstrate the use of mojo-based IPC interface;
- demo_memory: demonstrate the use of SharedMemory;
Thanks goes to these wonderful people (emoji key):
ManonLoki 🤔 💻 |
ligaojin 💻 |
Drecc 💻 |
hc-tec 💻 |
QZQ 💻 |
Midori 💻 📖 |
chenguang shao 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!