crosvm/gpu_display/examples/simple_open.rs
Dennis Kempin 78f62a44e7 Update copyright header check to cover all files
generated files and a list of excluded files are skipped.
Others are fixed to include the missing header.

BUG=b:246579983
TEST=./tools/health-check --all copyright_header

Change-Id: I13e9bf79df18789f1ed4b83fc47c0c2e080d70a8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894240
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-13 18:41:29 +00:00

32 lines
963 B
Rust

// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use gpu_display::GpuDisplay;
use gpu_display::SurfaceType;
fn main() {
let mut disp = GpuDisplay::open_x(None::<&str>).unwrap();
let surface_id = disp
.create_surface(None, 1280, 1024, SurfaceType::Scanout)
.unwrap();
let mem = disp.framebuffer(surface_id).unwrap();
for y in 0..1024 {
let mut row = [0u32; 1280];
for (x, item) in row.iter_mut().enumerate() {
let b = ((x as f32 / 1280.0) * 256.0) as u32;
let g = ((y as f32 / 1024.0) * 256.0) as u32;
*item = b | (g << 8);
}
mem.as_volatile_slice()
.offset(1280 * 4 * y)
.unwrap()
.copy_from(&row);
}
disp.flip(surface_id);
while !disp.close_requested(surface_id) {
disp.dispatch_events().unwrap();
}
}