Allow setting width/height on FlatInput and YCbCrInput after instantiation.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 21 Nov 2015 20:32:29 +0000 (21:32 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 21 Nov 2015 20:32:29 +0000 (21:32 +0100)
flat_input.h
util.cpp
version.h
ycbcr_input.cpp
ycbcr_input.h

index 14f8df1..d8b62b7 100644 (file)
@@ -107,6 +107,20 @@ public:
 
        void invalidate_pixel_data();
 
+       // Note: Sets pitch to width, so even if your pitch is unchanged,
+       // you will need to re-set it after this call.
+       void set_width(unsigned width)
+       {
+               this->pitch = this->width = width;
+               invalidate_pixel_data();
+       }
+
+       void set_height(unsigned height)
+       {
+               this->height = height;
+               invalidate_pixel_data();
+       }
+
        void set_pitch(unsigned pitch) {
                this->pitch = pitch;
                invalidate_pixel_data();
index 9c077e9..d500399 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -334,11 +334,11 @@ void *get_gl_context_identifier()
 #elif defined(WIN32)
        return (void *)wglGetCurrentContext();
 #else
-       void *ret = (void *)glXGetCurrentContext();
+       void *ret = (void *)eglGetCurrentContext();
        if (ret != NULL) {
                return ret;
        }
-       return (void *)eglGetCurrentContext();
+       return (void *)glXGetCurrentContext();
 #endif
 }
 
index c23d0e2..87be640 100644 (file)
--- a/version.h
+++ b/version.h
@@ -5,6 +5,6 @@
 // changes, even within git versions. There is no specific version
 // documentation outside the regular changelogs, though.
 
-#define MOVIT_VERSION 11
+#define MOVIT_VERSION 12
 
 #endif // !defined(_MOVIT_VERSION_H)
index 4c824c6..071ce13 100644 (file)
@@ -30,15 +30,8 @@ YCbCrInput::YCbCrInput(const ImageFormat &image_format,
        pbos[0] = pbos[1] = pbos[2] = 0;
        texture_num[0] = texture_num[1] = texture_num[2] = 0;
 
-       assert(width % ycbcr_format.chroma_subsampling_x == 0);
-       pitch[0] = widths[0] = width;
-       pitch[1] = widths[1] = width / ycbcr_format.chroma_subsampling_x;
-       pitch[2] = widths[2] = width / ycbcr_format.chroma_subsampling_x;
-
-       assert(height % ycbcr_format.chroma_subsampling_y == 0);
-       heights[0] = height;
-       heights[1] = height / ycbcr_format.chroma_subsampling_y;
-       heights[2] = height / ycbcr_format.chroma_subsampling_y;
+       set_width(width);
+       set_height(height);
 
        pixel_data[0] = pixel_data[1] = pixel_data[2] = NULL;
        owns_texture[0] = owns_texture[1] = owns_texture[2] = false;
index 6f4b66d..3aed51b 100644 (file)
@@ -79,7 +79,32 @@ public:
 
        void invalidate_pixel_data();
 
-       void set_pitch(unsigned channel, unsigned pitch) {
+       // Note: Sets pitch to width, so even if your pitch is unchanged,
+       // you will need to re-set it after this call.
+       void set_width(unsigned width)
+       {
+               this->width = width;
+
+               assert(width % ycbcr_format.chroma_subsampling_x == 0);
+               pitch[0] = widths[0] = width;
+               pitch[1] = widths[1] = width / ycbcr_format.chroma_subsampling_x;
+               pitch[2] = widths[2] = width / ycbcr_format.chroma_subsampling_x;
+               invalidate_pixel_data();
+       }
+
+       void set_height(unsigned height)
+       {
+               this->height = height;
+
+               assert(height % ycbcr_format.chroma_subsampling_y == 0);
+               heights[0] = height;
+               heights[1] = height / ycbcr_format.chroma_subsampling_y;
+               heights[2] = height / ycbcr_format.chroma_subsampling_y;
+               invalidate_pixel_data();
+       }
+
+       void set_pitch(unsigned channel, unsigned pitch)
+       {
                assert(channel >= 0 && channel < num_channels);
                this->pitch[channel] = pitch;
                invalidate_pixel_data();