From 4a38970b4e8cd4bce1dd9eabd56a45635501bbc3 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 2 Dec 2018 21:20:25 +0100 Subject: [PATCH] Unify context.cpp from Nageru and Futatabi. --- futatabi/main.cpp | 2 +- futatabi/meson.build | 2 +- futatabi/player.cpp | 2 +- futatabi/video_stream.cpp | 2 +- nageru/analyzer.cpp | 2 +- nageru/context.cpp | 50 -------------------------------- nageru/decklink_output.h | 2 +- nageru/glwidget.cpp | 2 +- nageru/main.cpp | 3 +- nageru/meson.build | 2 +- nageru/mixer.cpp | 2 +- nageru/quicksync_encoder.cpp | 2 +- {futatabi => shared}/context.cpp | 0 {futatabi => shared}/context.h | 0 shared/meson.build | 6 ++-- 15 files changed, 15 insertions(+), 64 deletions(-) delete mode 100644 nageru/context.cpp rename {futatabi => shared}/context.cpp (100%) rename {futatabi => shared}/context.h (100%) diff --git a/futatabi/main.cpp b/futatabi/main.cpp index 58a131a..b885c81 100644 --- a/futatabi/main.cpp +++ b/futatabi/main.cpp @@ -20,7 +20,7 @@ extern "C" { } #include "clip_list.h" -#include "context.h" +#include "shared/context.h" #include "defs.h" #include "disk_space_estimator.h" #include "shared/ffmpeg_raii.h" diff --git a/futatabi/meson.build b/futatabi/meson.build index 04e003a..3f82d8d 100644 --- a/futatabi/meson.build +++ b/futatabi/meson.build @@ -34,7 +34,7 @@ moc_files = qt5.preprocess( srcs = ['flow.cpp', 'gpu_timers.cpp'] # All the other files. -srcs += ['main.cpp', 'player.cpp', 'httpd.cpp', 'video_stream.cpp', 'context.cpp', 'chroma_subsampler.cpp'] +srcs += ['main.cpp', 'player.cpp', 'httpd.cpp', 'video_stream.cpp', 'chroma_subsampler.cpp'] srcs += ['vaapi_jpeg_decoder.cpp', 'db.cpp', 'disk_space_estimator.cpp', 'ycbcr_converter.cpp', 'flags.cpp'] srcs += ['mainwindow.cpp', 'jpeg_frame_view.cpp', 'clip_list.cpp', 'frame_on_disk.cpp'] srcs += moc_files diff --git a/futatabi/player.cpp b/futatabi/player.cpp index 99edd86..816f72d 100644 --- a/futatabi/player.cpp +++ b/futatabi/player.cpp @@ -1,7 +1,7 @@ #include "player.h" #include "clip_list.h" -#include "context.h" +#include "shared/context.h" #include "defs.h" #include "shared/ffmpeg_raii.h" #include "frame_on_disk.h" diff --git a/futatabi/video_stream.cpp b/futatabi/video_stream.cpp index 3df272a..52612e2 100644 --- a/futatabi/video_stream.cpp +++ b/futatabi/video_stream.cpp @@ -6,7 +6,7 @@ extern "C" { } #include "chroma_subsampler.h" -#include "context.h" +#include "shared/context.h" #include "flags.h" #include "flow.h" #include "httpd.h" diff --git a/nageru/analyzer.cpp b/nageru/analyzer.cpp index b24b46a..bdb80bc 100644 --- a/nageru/analyzer.cpp +++ b/nageru/analyzer.cpp @@ -9,7 +9,7 @@ #include #include -#include "context.h" +#include "shared/context.h" #include "flags.h" #include "mixer.h" #include "ui_analyzer.h" diff --git a/nageru/context.cpp b/nageru/context.cpp deleted file mode 100644 index eb62183..0000000 --- a/nageru/context.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include - -#include - -#include -#include -#include -#include -#include - -QGLWidget *global_share_widget = nullptr; -bool using_egl = false; - -using namespace std; - -QSurface *create_surface(const QSurfaceFormat &format) -{ - QOffscreenSurface *surface = new QOffscreenSurface; - surface->setFormat(format); - surface->create(); - if (!surface->isValid()) { - fprintf(stderr, "ERROR: surface not valid!\n"); - exit(1); - } - return surface; -} - -QSurface *create_surface_with_same_format(const QSurface *surface) -{ - return create_surface(surface->format()); -} - -QOpenGLContext *create_context(const QSurface *surface) -{ - QOpenGLContext *context = new QOpenGLContext; - context->setShareContext(global_share_widget->context()->contextHandle()); - context->setFormat(surface->format()); - context->create(); - return context; -} - -bool make_current(QOpenGLContext *context, QSurface *surface) -{ - return context->makeCurrent(surface); -} - -void delete_context(QOpenGLContext *context) -{ - delete context; -} diff --git a/nageru/decklink_output.h b/nageru/decklink_output.h index 29ea29c..90b89a2 100644 --- a/nageru/decklink_output.h +++ b/nageru/decklink_output.h @@ -17,7 +17,7 @@ #include "DeckLinkAPITypes.h" #include "LinuxCOM.h" -#include "context.h" +#include "shared/context.h" #include "print_latency.h" #include "quittable_sleeper.h" #include "ref_counted_frame.h" diff --git a/nageru/glwidget.cpp b/nageru/glwidget.cpp index 8316824..e6c2c58 100644 --- a/nageru/glwidget.cpp +++ b/nageru/glwidget.cpp @@ -20,7 +20,7 @@ #include #include "audio_mixer.h" -#include "context.h" +#include "shared/context.h" #include "context_menus.h" #include "flags.h" #include "mainwindow.h" diff --git a/nageru/main.cpp b/nageru/main.cpp index c1a52c0..d5654a5 100644 --- a/nageru/main.cpp +++ b/nageru/main.cpp @@ -24,7 +24,7 @@ extern "C" { #ifdef HAVE_CEF #include "nageru_cef_app.h" #endif -#include "context.h" +#include "shared/context.h" #include "flags.h" #include "image_input.h" #include "mainwindow.h" @@ -68,7 +68,6 @@ int main(int argc, char *argv[]) // We normally use EGL for zerocopy, but if we use VA against DRM // instead of against X11, we turn it off, and then don't need EGL. setenv("QT_XCB_GL_INTEGRATION", "xcb_egl", 0); - using_egl = true; } setlinebuf(stdout); #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100) diff --git a/nageru/meson.build b/nageru/meson.build index 6b5b7c6..1fb60e6 100644 --- a/nageru/meson.build +++ b/nageru/meson.build @@ -161,7 +161,7 @@ nageru_link_with += audio # Mixer objects. srcs += ['chroma_subsampler.cpp', 'v210_converter.cpp', 'mixer.cpp', 'pbo_frame_allocator.cpp', - 'context.cpp', 'theme.cpp', 'image_input.cpp', 'alsa_output.cpp', + 'theme.cpp', 'image_input.cpp', 'alsa_output.cpp', 'disk_space_estimator.cpp', 'timecode_renderer.cpp', 'tweaked_inputs.cpp'] # Streaming and encoding objects (largely the set that is shared between Nageru and Kaeru). diff --git a/nageru/mixer.cpp b/nageru/mixer.cpp index 2f6a8eb..3a5783b 100644 --- a/nageru/mixer.cpp +++ b/nageru/mixer.cpp @@ -37,7 +37,7 @@ #include "cef_capture.h" #endif #include "chroma_subsampler.h" -#include "context.h" +#include "shared/context.h" #include "decklink_capture.h" #include "decklink_output.h" #include "defs.h" diff --git a/nageru/quicksync_encoder.cpp b/nageru/quicksync_encoder.cpp index 58f4172..ded20f6 100644 --- a/nageru/quicksync_encoder.cpp +++ b/nageru/quicksync_encoder.cpp @@ -45,7 +45,7 @@ extern "C" { } // namespace #include "audio_encoder.h" -#include "context.h" +#include "shared/context.h" #include "defs.h" #include "disk_space_estimator.h" #include "shared/ffmpeg_raii.h" diff --git a/futatabi/context.cpp b/shared/context.cpp similarity index 100% rename from futatabi/context.cpp rename to shared/context.cpp diff --git a/futatabi/context.h b/shared/context.h similarity index 100% rename from futatabi/context.h rename to shared/context.h diff --git a/shared/meson.build b/shared/meson.build index 2afff9e..8d1b203 100644 --- a/shared/meson.build +++ b/shared/meson.build @@ -1,6 +1,8 @@ +qt5 = import('qt5') +qt5deps = dependency('qt5', modules: ['OpenGL']) -srcs = ['memcpy_interleaved.cpp', 'metacube2.cpp', 'ffmpeg_raii.cpp', 'mux.cpp', 'metrics.cpp'] -shared = static_library('shared', srcs, include_directories: top_include) +srcs = ['memcpy_interleaved.cpp', 'metacube2.cpp', 'ffmpeg_raii.cpp', 'mux.cpp', 'metrics.cpp', 'context.cpp'] +shared = static_library('shared', srcs, include_directories: top_include, dependencies: qt5deps) shareddep = declare_dependency( include_directories: top_include, link_with: shared) -- 2.39.2