From: Steinar H. Gunderson Date: Sun, 19 May 2019 08:37:18 +0000 (+0200) Subject: Fix ImageInput sRGB behavior. X-Git-Tag: 1.9.0~39 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=45a94bcaba587f636c1aa40485d02c5619109b20 Fix ImageInput sRGB behavior. After we made the different ImageInput instances share OpenGL textures, some of them would assume they could output sRGB. Fix by the same way we've done video textures, ie., use sRGBSwitchingInput. --- diff --git a/nageru/image_input.cpp b/nageru/image_input.cpp index 779f7ec..c8b1037 100644 --- a/nageru/image_input.cpp +++ b/nageru/image_input.cpp @@ -42,8 +42,8 @@ struct SwsContext; using namespace std; ImageInput::ImageInput(const string &filename) - : movit::FlatInput({movit::COLORSPACE_sRGB, movit::GAMMA_sRGB}, movit::FORMAT_RGBA_POSTMULTIPLIED_ALPHA, - GL_UNSIGNED_BYTE, 1280, 720), // Resolution will be overwritten. + : sRGBSwitchingFlatInput({movit::COLORSPACE_sRGB, movit::GAMMA_sRGB}, movit::FORMAT_RGBA_POSTMULTIPLIED_ALPHA, + GL_UNSIGNED_BYTE, 1280, 720), // Resolution will be overwritten. pathname(search_for_file_or_die(filename)), current_image(load_image(filename, pathname)) { @@ -71,7 +71,7 @@ void ImageInput::set_gl_state(GLuint glsl_program_num, const string& prefix, uns set_texture_num(*current_image->tex); } } - movit::FlatInput::set_gl_state(glsl_program_num, prefix, sampler_num); + sRGBSwitchingFlatInput::set_gl_state(glsl_program_num, prefix, sampler_num); } shared_ptr ImageInput::load_image(const string &filename, const string &pathname) @@ -212,7 +212,7 @@ shared_ptr ImageInput::load_image_raw(const string &pat check_error(); glPixelStorei(GL_UNPACK_ROW_LENGTH, linesizes[0] / 4); check_error(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, frame->width, frame->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data.get()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, frame->width, frame->height, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, image_data.get()); check_error(); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); check_error(); diff --git a/nageru/image_input.h b/nageru/image_input.h index f7289f3..32fd529 100644 --- a/nageru/image_input.h +++ b/nageru/image_input.h @@ -14,13 +14,14 @@ #include #include "ref_counted_texture.h" +#include "tweaked_inputs.h" class QSurface; // An output that takes its input from a static image, loaded with ffmpeg. // comes from a single 2D array with chunky pixels. The image is refreshed // from disk about every second. -class ImageInput : public movit::FlatInput { +class ImageInput : public sRGBSwitchingFlatInput { public: // NOTE: You will need to call start_update_thread() yourself, once per program. ImageInput(const std::string &filename);