]> git.sesse.net Git - casparcg/commitdiff
2.0. image_mixer: Minor fixes.
authorRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 29 Jul 2011 21:43:35 +0000 (21:43 +0000)
committerRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 29 Jul 2011 21:43:35 +0000 (21:43 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1016 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/mixer/image/image_kernel.cpp
core/mixer/image/image_mixer.cpp

index ab335e4d1901a39b0ed73ab3533e8db3d4cca38c..aa5236c16189ffbf26a6d98531ff2c4e32617bf0 100644 (file)
 \r
 namespace caspar { namespace core {\r
        \r
+GLubyte upper_pattern[] = {\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00};\r
+               \r
+GLubyte lower_pattern[] = {\r
+       0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, \r
+       0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,\r
+       0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,\r
+       0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff};\r
+\r
 struct image_kernel::implementation : boost::noncopyable\r
 {      \r
        std::unique_ptr<shader> shader_;\r
@@ -63,7 +75,6 @@ struct image_kernel::implementation : boost::noncopyable
                        "uniform bool           has_layer_key;                                                                                                  \n"\r
                        "uniform int            blend_mode;                                                                                                             \n"\r
                        "uniform int            alpha_mode;                                                                                                             \n"\r
-                       "uniform int            interlace_mode;                                                                                                 \n"\r
                        "uniform int            pixel_format;                                                                                                   \n"\r
                        "                                                                                                                                                                       \n"\r
                        "uniform bool           levels;                                                                                                                 \n"\r
@@ -210,24 +221,6 @@ struct image_kernel::implementation : boost::noncopyable
                        "                                                                                                                                                                       \n"\r
                        "void main()                                                                                                                                            \n"\r
                        "{                                                                                                                                                                      \n"\r
-                       "   switch(interlace_mode)                                                                                                                      \n"\r
-                       "       {                                                                                                                                                               \n"\r
-                       "       case 1: // lower                                                                                                                                \n"\r
-                       "               {                                                                                                                                                       \n"\r
-                       "                       bool odd = mod(floor(gl_FragCoord.y), 2.0) > 0.5;                                               \n"\r
-                       "                       if(!odd)                                                                                                                                \n"\r
-                       "                               discard;                                                                                                                        \n"\r
-                       "                       break;                                                                                                                                  \n"\r
-                       "               }                                                                                                                                                       \n"\r
-                       "       case 2: //upper                                                                                                                                 \n"\r
-                       "               {                                                                                                                                                       \n"\r
-                       "                       bool odd = mod(floor(gl_FragCoord.y), 2.0) > 0.5;                                               \n"\r
-                       "                       if(odd)                                                                                                                                 \n"\r
-                       "                               discard;                                                                                                                        \n"\r
-                       "                       break;                                                                                                                                  \n"\r
-                       "               }                                                                                                                                                       \n"\r
-                       "       }                                                                                                                                                               \n"\r
-                       "                                                                                                                                                                       \n"\r
                        "       vec4 color = get_rgba_color();                                                                                                  \n"\r
                        "       if(has_local_key)                                                                                                                               \n"\r
                        "               color.a *= texture2D(local_key, gl_TexCoord[1].st).r;                                           \n"\r
@@ -251,16 +244,14 @@ struct image_kernel::implementation : boost::noncopyable
                          const std::shared_ptr<device_buffer>&                 layer_key)\r
        {\r
                GL(glEnable(GL_TEXTURE_2D));\r
+               GL(glEnable(GL_POLYGON_STIPPLE));\r
                        \r
-               // Setup depth for interlacing and explicit z-culling\r
-               double z = 0.0;\r
                if(transform.get_mode() == core::video_mode::upper)\r
-               {       \r
-                       GL(glEnable(GL_DEPTH_TEST));    \r
-                       z = 1.0;\r
-               }\r
+                       glPolygonStipple(upper_pattern);\r
                else if(transform.get_mode() == core::video_mode::lower)\r
-                       GL(glClear(GL_DEPTH_BUFFER_BIT));               \r
+                       glPolygonStipple(lower_pattern);\r
+               else\r
+                       GL(glDisable(GL_POLYGON_STIPPLE));\r
 \r
                // Bind textures\r
 \r
@@ -344,14 +335,14 @@ struct image_kernel::implementation : boost::noncopyable
                // Draw\r
 \r
                glBegin(GL_QUADS);\r
-                       glMultiTexCoord2d(GL_TEXTURE0, 0.0, 0.0); glMultiTexCoord2d(GL_TEXTURE1,  f_p[0]        ,  f_p[1]        );             glVertex3d( f_p[0]        *2.0-1.0,  f_p[1]        *2.0-1.0, z);\r
-                       glMultiTexCoord2d(GL_TEXTURE0, 1.0, 0.0); glMultiTexCoord2d(GL_TEXTURE1, (f_p[0]+f_s[0]),  f_p[1]        );             glVertex3d((f_p[0]+f_s[0])*2.0-1.0,  f_p[1]        *2.0-1.0, z);\r
-                       glMultiTexCoord2d(GL_TEXTURE0, 1.0, 1.0); glMultiTexCoord2d(GL_TEXTURE1, (f_p[0]+f_s[0]), (f_p[1]+f_s[1]));             glVertex3d((f_p[0]+f_s[0])*2.0-1.0, (f_p[1]+f_s[1])*2.0-1.0, z);\r
-                       glMultiTexCoord2d(GL_TEXTURE0, 0.0, 1.0); glMultiTexCoord2d(GL_TEXTURE1,  f_p[0]        , (f_p[1]+f_s[1]));             glVertex3d( f_p[0]        *2.0-1.0, (f_p[1]+f_s[1])*2.0-1.0, z);\r
+                       glMultiTexCoord2d(GL_TEXTURE0, 0.0, 0.0); glMultiTexCoord2d(GL_TEXTURE1,  f_p[0]        ,  f_p[1]        );             glVertex2d( f_p[0]        *2.0-1.0,  f_p[1]        *2.0-1.0);\r
+                       glMultiTexCoord2d(GL_TEXTURE0, 1.0, 0.0); glMultiTexCoord2d(GL_TEXTURE1, (f_p[0]+f_s[0]),  f_p[1]        );             glVertex2d((f_p[0]+f_s[0])*2.0-1.0,  f_p[1]        *2.0-1.0);\r
+                       glMultiTexCoord2d(GL_TEXTURE0, 1.0, 1.0); glMultiTexCoord2d(GL_TEXTURE1, (f_p[0]+f_s[0]), (f_p[1]+f_s[1]));             glVertex2d((f_p[0]+f_s[0])*2.0-1.0, (f_p[1]+f_s[1])*2.0-1.0);\r
+                       glMultiTexCoord2d(GL_TEXTURE0, 0.0, 1.0); glMultiTexCoord2d(GL_TEXTURE1,  f_p[0]        , (f_p[1]+f_s[1]));             glVertex2d( f_p[0]        *2.0-1.0, (f_p[1]+f_s[1])*2.0-1.0);\r
                glEnd();\r
 \r
                GL(glDisable(GL_SCISSOR_TEST)); \r
-               GL(glDisable(GL_DEPTH_TEST));   \r
+               GL(glDisable(GL_POLYGON_STIPPLE));\r
        }\r
 };\r
 \r
index f5b2f6304e43ddef2a64f02333921cbd859789ea..57a0070cc127ed286a09d966c8a45bd8571b2579 100644 (file)
@@ -39,6 +39,7 @@
 \r
 #include <boost/foreach.hpp>\r
 \r
+#include <algorithm>\r
 #include <array>\r
 #include <unordered_map>\r
 \r
@@ -116,7 +117,10 @@ public:
                if(layer.empty() || (!layer.back().empty() && layer.back().back().tag != frame.tag()))\r
                        layer.push(std::deque<render_item>());\r
                \r
-               layer.back().push_back(item);\r
+               auto& stream = layer.back();\r
+               \r
+               //if(std::find(stream.begin(), stream.end(), item) == stream.end())\r
+               stream.push_back(item);\r
        }\r
 \r
        void end()\r
@@ -196,14 +200,7 @@ public:
        void render(std::deque<render_item>& stream, bool local_key, bool layer_key)\r
        {\r
                CASPAR_ASSERT(!stream.empty());\r
-\r
-               while(stream.size() > 2)\r
-                       stream.pop_front();\r
-\r
-               // Kernel expects lower field first for early explicit z-culling\r
-               if(stream[0].transform.get_mode() == core::video_mode::upper && stream.size() == 2)\r
-                       std::swap(stream[0], stream[1]);                \r
-               \r
+                               \r
                if(stream.front().transform.get_is_key())\r
                {\r
                        stream_key_buffer_[1]->attach();\r