]> git.sesse.net Git - nageru/blobdiff - nageru/image_input.cpp
Rework the chain concept.
[nageru] / nageru / image_input.cpp
index c8b10371b4d381eec9535246f1e216ba6b6f3bb6..6a2c5abc846b913123ef00647373bd6267ee1d4b 100644 (file)
@@ -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<mutex> 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);
@@ -288,6 +294,15 @@ void ImageInput::update_thread_func(QSurface *surface)
        }
 }
 
+void ImageInput::switch_image(const string &pathname)
+{
+#ifndef NDEBUG
+       lock_guard<mutex> 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);