Files
TheRock/rocm-systems/projects/rocprofiler-systems/external/onetbb/examples/common/gui/convideo.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

149 lines
3.4 KiB
C++

/*
Copyright (c) 2005-2022 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <cassert>
#include <stdio.h>
#include "video.hpp"
unsigned int *g_pImg = nullptr;
int g_sizex, g_sizey;
static video *g_video = nullptr;
static int g_fps = 0;
#if _WIN32 || _WIN64
static DWORD g_msec = 0;
#ifdef _WINDOWS
HINSTANCE video::win_hInstance = 0;
int video::win_iCmdShow = 0;
void video::win_set_class(WNDCLASSEX &wcex) {}
void video::win_load_accelerators(int idc) {}
#endif //_WINDOWS
#else
#include <sched.h>
#include <sys/time.h>
struct timeval g_time;
#endif //_WIN32||_WIN64
#define CALC_FPS_ENABLED ((WINAPI_FAMILY != WINAPI_FAMILY_APP) && (!__ANDROID__))
video::video()
// OpenGL* RGBA byte order for little-endian CPU
: depth(24),
red_shift(0),
green_shift(8),
blue_shift(16),
red_mask(0xff),
green_mask(0xff00),
blue_mask(0xff0000) {
assert(g_video == nullptr);
g_video = this;
title = "Video";
updating = calc_fps = false;
}
bool video::init_window(int x, int y) {
g_sizex = x;
g_sizey = y;
g_pImg = new unsigned int[x * y];
running = true;
return false;
}
bool video::init_console() {
running = true;
return true;
}
void video::terminate() {
#if CALC_FPS_ENABLED
if (calc_fps) {
double fps = g_fps;
#if _WIN32 || _WIN64
fps /= (GetTickCount() - g_msec) / 1000.0;
#else
struct timezone tz;
struct timeval end_time;
gettimeofday(&end_time, &tz);
fps /= (end_time.tv_sec + 1.0 * end_time.tv_usec / 1000000.0) -
(g_time.tv_sec + 1.0 * g_time.tv_usec / 1000000.0);
#endif
printf("%s: %.1f fps\n", title, fps);
}
#endif
g_video = nullptr;
running = false;
delete[] g_pImg;
g_pImg = nullptr;
}
video::~video() {
if (g_video)
terminate();
}
//! Count and display FPS count in titlebar
bool video::next_frame() {
#if CALC_FPS_ENABLED
if (calc_fps) {
if (!g_fps) {
#if _WIN32 || _WIN64
g_msec = GetTickCount();
#else
struct timezone tz;
gettimeofday(&g_time, &tz);
#endif
}
g_fps++;
}
#endif
return running;
}
//! Do standard loop
void video::main_loop() {
on_process();
}
//! Change window title
void video::show_title() {}
///////////////////////////////////////////// public methods of video class ///////////////////////
drawing_area::drawing_area(int x, int y, int sizex, int sizey)
: base_index(y * g_sizex + x),
max_index(g_sizex * g_sizey),
index_stride(g_sizex),
pixel_depth(24),
ptr32(g_pImg),
start_x(x),
start_y(y),
size_x(sizex),
size_y(sizey) {
assert(x < g_sizex);
assert(y < g_sizey);
assert(x + sizex <= g_sizex);
assert(y + sizey <= g_sizey);
index = base_index; // current index
}
void drawing_area::update() {}