diff --git a/src/stage/output/displayer.cpp b/src/stage/output/displayer.cpp index 54da1fde3..7ef3107ec 100644 --- a/src/stage/output/displayer.cpp +++ b/src/stage/output/displayer.cpp @@ -18,26 +18,23 @@ ** Implementation of a displayer object, intended for creating ** a video display in the UI. This class was created as part of ** an initial draft of the user interface. - ** @warning as of 2016 it is not clear, if this code will be + ** @todo as of 2016 it is not clear, if this code will be ** evolved into the actual display facility, or be - ** replaced and rewritten, when we're about to + ** replaced and rewritten, when we're about to ** create a functional video display connected - ** to the render engine. + ** to the render engine. + ** @todo 5/2025 used in an experiment for video output */ #include "stage/gtk-base.hpp" #include "stage/output/displayer.hpp" +#include + namespace stage { namespace output { - bool - Displayer::usable() - { - return false; - } - DisplayerInput Displayer::format() { @@ -46,28 +43,26 @@ namespace output { void Displayer::calculateVideoLayout( - int widget_width, int widget_height, - int image_width, int image_height, - int &video_x, int &video_y, int &video_width, int &video_height ) + int widgetWidth, int widgetHeight, + int &imgOrg_x, int &imgOrg_y, int &imgWidth, int &imgHeight ) { - REQUIRE (widget_width >= 0); - REQUIRE (widget_height >= 0); - REQUIRE (image_width >= 0); - REQUIRE (image_height >= 0); + REQUIRE (0 < widgetWidth ); + REQUIRE (0 < widgetHeight); + REQUIRE (0 < videoWidth ); + REQUIRE (0 < videoHeight ); - double ratio_width = ( double ) widget_width / ( double ) image_width; - double ratio_height = ( double ) widget_height / ( double ) image_height; - double ratio_constant = ratio_height < ratio_width ? - ratio_height : ratio_width; - video_width = ( int ) ( image_width * ratio_constant + 0.5 ); - video_height = ( int ) ( image_height * ratio_constant + 0.5 ); - video_x = ( widget_width - video_width ) / 2; - video_y = ( widget_height - video_height ) / 2; + auto ratioW = double(widgetWidth ) / videoWidth; + auto ratioH = double(widgetHeight) / videoHeight; + auto scale = std::min (ratioW, ratioH); + imgWidth = std::lround (scale * videoWidth); + imgHeight = std::lround (scale * videoHeight); + imgOrg_x = (widgetWidth - imgWidth) / 2; + imgOrg_y = (widgetHeight - imgHeight) / 2; - ENSURE (video_x >= 0 && video_x < widget_width); - ENSURE (video_y >= 0 && video_y < widget_height); - ENSURE (video_width <= widget_width); - ENSURE (video_width <= widget_width); + ENSURE (imgWidth <= widgetWidth); + ENSURE (imgWidth <= widgetWidth); + ENSURE (0 <= imgOrg_x and imgOrg_x < widgetWidth); + ENSURE (0 <= imgOrg_y and imgOrg_y < widgetHeight); } diff --git a/src/stage/output/displayer.hpp b/src/stage/output/displayer.hpp index 380bc85ab..52436073c 100644 --- a/src/stage/output/displayer.hpp +++ b/src/stage/output/displayer.hpp @@ -68,20 +68,20 @@ namespace output { : util::NonCopyable { protected: - const int videoWidth; - const int videoHeight; + const uint videoWidth; + const uint videoHeight; public: virtual ~Displayer() { } - Displayer(int w, int h) + Displayer(uint w, uint h) : videoWidth{w} , videoHeight{h} { } /** Indicates if this object can be used to render images on the running system. */ - virtual bool usable(); + virtual bool usable() =0; /** Indicates the format required by the abstract put method. * @todo this feature was seemingly never used... can it be relevant? can we handle different formats? @@ -99,21 +99,21 @@ namespace output { /** * Calculates the coordinates for placing a video image inside a widget * - * @param[in] widget_width The width of the display widget. - * @param[in] widget_height The height of the display widget. - * @param[in] image_width The width of the video image. - * @param[in] image_height The height of the video image. - * @param[out] video_x The x-coordinate of the top left - * corner of the scaled video image. - * @param[out] video_y The y-coordinate of the top left - * corner of the scaled video image. - * @param[out] video_width The width of the scale video image. - * @param[out] video_height The height of the scale video image. + * @param[in] widgetWidth available width for display in the widget. + * @param[in] widgetHeight available height for display in the widget. + * @param[out] imgOrg_x x-coordinate of the top left corner of the + * scaled video image to display. + * @param[out] imgOrg_y y-coordinate of the top left corner. + * @param[out] imgWidth width of the scale video image to display. + * @param[out] imgHeight height of the scale video image. */ - static void calculateVideoLayout( - int widget_width, int widget_height, - int image_width, int image_height, - int &video_x, int &video_y, int &video_width, int &video_height ); + void calculateVideoLayout(int widgetWidth + ,int widgetHeight + ,int& imgOrg_x + ,int& imgOrg_y + ,int& imgWidth + ,int& imgHeight + ); }; diff --git a/src/stage/output/null-displayer.cpp b/src/stage/output/null-displayer.cpp index 5cc9841e1..8a59da52a 100644 --- a/src/stage/output/null-displayer.cpp +++ b/src/stage/output/null-displayer.cpp @@ -27,7 +27,7 @@ namespace stage { namespace output { NullDisplayer::NullDisplayer (Gtk::Widget& drawing_area, - int width, int height) + uint width, uint height) : Displayer{width,height} , drawingArea_{drawing_area} { @@ -47,7 +47,6 @@ namespace output { calculateVideoLayout( drawingArea_.get_width(), drawingArea_.get_height(), - videoWidth, videoHeight, video_x, video_y, video_width, video_height); GdkWindow *window = drawingArea_.get_window()->gobj(); diff --git a/src/stage/output/null-displayer.hpp b/src/stage/output/null-displayer.hpp index be2a2f591..224d8d51d 100644 --- a/src/stage/output/null-displayer.hpp +++ b/src/stage/output/null-displayer.hpp @@ -42,7 +42,7 @@ class NullDisplayer { public: - NullDisplayer (Gtk::Widget& drawing_area, int width, int height ); + NullDisplayer (Gtk::Widget& drawing_area, uint width, uint height ); /** NULL-implementation: accept anything, do nothing */ void put (void* const image) override; diff --git a/src/stage/output/pixbuf-displayer.cpp b/src/stage/output/pixbuf-displayer.cpp index 8c3a96af3..af0692966 100644 --- a/src/stage/output/pixbuf-displayer.cpp +++ b/src/stage/output/pixbuf-displayer.cpp @@ -36,7 +36,7 @@ namespace stage { namespace output { PixbufDisplayer::PixbufDisplayer (Gtk::Image& drawing_area, - int width, int height) + uint width, uint height) : Displayer{width,height} , drawingArea_{drawing_area} { @@ -56,16 +56,15 @@ namespace output { void PixbufDisplayer::put (void* const image) { - int video_x = 0, - video_y = 0, + int orgX = 0, + orgY = 0, destWidth = 0, destHeight = 0; calculateVideoLayout( drawingArea_.get_width(), drawingArea_.get_height(), - videoWidth, videoHeight, - video_x, video_y, destWidth, destHeight); + orgX, orgY, destWidth, destHeight); GdkWindow *window = drawingArea_.get_window()->gobj(); REQUIRE (window != NULL); @@ -81,7 +80,7 @@ namespace output { GdkPixbuf *scaled_image = gdk_pixbuf_scale_simple( pixbuf, destWidth, destHeight, GDK_INTERP_NEAREST ); REQUIRE(scaled_image != NULL); - gdk_draw_pixbuf( window, gc, scaled_image, 0, 0, video_x, video_y, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0 ); + gdk_draw_pixbuf( window, gc, scaled_image, 0, 0, orgX, orgY, -1, -1, GDK_RGB_DITHER_NORMAL, 0, 0 ); g_object_unref( scaled_image ); g_object_unref( pixbuf ); diff --git a/src/stage/output/pixbuf-displayer.hpp b/src/stage/output/pixbuf-displayer.hpp index 3a1fa8352..7f3710e22 100644 --- a/src/stage/output/pixbuf-displayer.hpp +++ b/src/stage/output/pixbuf-displayer.hpp @@ -57,7 +57,7 @@ class PixbufDisplayer * @param[in] height The height of the video image in pixels. This * value must be greater than zero. */ - PixbufDisplayer (Gtk::Image& drawing_area, int width, int height ); + PixbufDisplayer (Gtk::Image& drawing_area, uint width, uint height ); /** * Put an image of a given width and height with the expected input diff --git a/src/stage/output/xv-displayer.cpp b/src/stage/output/xv-displayer.cpp index eed324566..231a7f14e 100644 --- a/src/stage/output/xv-displayer.cpp +++ b/src/stage/output/xv-displayer.cpp @@ -170,6 +170,8 @@ namespace output { { gotPort = false; } + if (not gotPort) + ERROR (stage, "unable to use XVideo for display."); } @@ -210,18 +212,17 @@ namespace output { { REQUIRE(display != NULL); - int video_x = 0, video_y = 0, video_width = 0, video_height = 0; + int org_x = 0, org_y = 0, destW = 0, destH = 0; calculateVideoLayout( drawingArea_.get_width(), drawingArea_.get_height(), - videoWidth, videoHeight, - video_x, video_y, video_width, video_height ); + org_x, org_y, destW, destH ); memcpy (xvImage->data, image, xvImage->data_size); XvShmPutImage (display, grabbedPort, window, gc, xvImage, 0, 0, videoWidth, videoHeight, - video_x, video_y, video_width, video_height, false); + org_x, org_y, destW, destH, false); } } diff --git a/src/stage/widget/video-display-widget.cpp b/src/stage/widget/video-display-widget.cpp index f4f69bad1..dd2d9291e 100644 --- a/src/stage/widget/video-display-widget.cpp +++ b/src/stage/widget/video-display-widget.cpp @@ -70,11 +70,11 @@ namespace widget { { REQUIRE (videoWidth > 0); REQUIRE (videoHeight > 0); - /* + displayer_ = make_unique (*this, videoWidth, videoHeight); if (displayer_->usable()) return; - */ + displayer_ = make_unique (*this, videoWidth, videoHeight); if (displayer_->usable()) return; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 3f0ba08f6..3dd9048a8 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -130027,15 +130027,38 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) Erfolg-1 : es wird irgendwas angezeigt

- - + - - + + + + + + + + + + + + + + + + + + + + + + + + + +