X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fimage_input.cpp;h=afb87c57a6aa32577ee9473f9c87be89c6b70058;hb=5a34f92eb0bf5fe911cb6ca72a18ad03ce9898ac;hp=c8b10371b4d381eec9535246f1e216ba6b6f3bb6;hpb=45a94bcaba587f636c1aa40485d02c5619109b20;p=nageru diff --git a/nageru/image_input.cpp b/nageru/image_input.cpp index c8b1037..afb87c5 100644 --- a/nageru/image_input.cpp +++ b/nageru/image_input.cpp @@ -41,6 +41,11 @@ struct SwsContext; using namespace std; +ImageInput::ImageInput() + : sRGBSwitchingFlatInput({movit::COLORSPACE_sRGB, movit::GAMMA_sRGB}, movit::FORMAT_RGBA_POSTMULTIPLIED_ALPHA, + GL_UNSIGNED_BYTE, 1280, 720) // Resolution will be overwritten. +{} + ImageInput::ImageInput(const string &filename) : sRGBSwitchingFlatInput({movit::COLORSPACE_sRGB, movit::GAMMA_sRGB}, movit::FORMAT_RGBA_POSTMULTIPLIED_ALPHA, GL_UNSIGNED_BYTE, 1280, 720), // Resolution will be overwritten. @@ -66,6 +71,7 @@ void ImageInput::set_gl_state(GLuint glsl_program_num, const string& prefix, uns // is mostly there to save startup time, not RAM). { lock_guard lock(all_images_lock); + assert(all_images.count(pathname)); if (all_images[pathname] != current_image) { current_image = all_images[pathname]; set_texture_num(*current_image->tex); @@ -222,7 +228,7 @@ shared_ptr ImageInput::load_image_raw(const string &pat glBindTexture(GL_TEXTURE_2D, 0); check_error(); - shared_ptr image(new Image{unsigned(frame->width), unsigned(frame->height), RefCountedTexture(new GLuint(tex)), last_modified}); + shared_ptr image(new Image{unsigned(frame->width), unsigned(frame->height), UniqueTexture(new GLuint(tex)), last_modified}); return image; } @@ -288,6 +294,15 @@ void ImageInput::update_thread_func(QSurface *surface) } } +void ImageInput::switch_image(const string &pathname) +{ +#ifndef NDEBUG + lock_guard lock(all_images_lock); + assert(all_images.count(pathname)); +#endif + this->pathname = pathname; +} + void ImageInput::start_update_thread(QSurface *surface) { update_thread = thread(update_thread_func, surface);