Merge branch 'master' into blender2.8
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 16 Jul 2018 12:36:59 +0000 (14:36 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 16 Jul 2018 12:36:59 +0000 (14:36 +0200)
build_files/buildbot/slave_compile.py
intern/cycles/render/image.cpp
intern/cycles/util/util_half.h
intern/cycles/util/util_image.h
intern/cycles/util/util_image_impl.h
source/blender/windowmanager/intern/wm_playanim.c

index 59b35a535aa864fd4f6bb311b0290993a41cf9cd..a77f237e978ddc5e799e604b33be885c8db5a882 100644 (file)
@@ -77,7 +77,7 @@ if 'cmake' in builder:
         # cmake_extra_options.append('-DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-hack/nvcc')
 
     elif builder.startswith('win'):
-        if builder.endswith('_vc2017'):
+        if builder.endswith('_vs2017'):
             if builder.startswith('win64'):
                 cmake_options.extend(['-G', 'Visual Studio 15 2017 Win64'])
             elif builder.startswith('win32'):
index fa280fec01ff038711d011135f8c650e144833c8..28ef026135a4eaec53516dea8180b90c625ee0ed 100644 (file)
@@ -33,15 +33,15 @@ CCL_NAMESPACE_BEGIN
 /* Some helpers to silence warning in templated function. */
 static bool isfinite(uchar /*value*/)
 {
-       return false;
+       return true;
 }
 static bool isfinite(half /*value*/)
 {
-       return false;
+       return true;
 }
 static bool isfinite(uint16_t  /*value*/)
 {
-       return false;
+       return true;
 }
 
 ImageManager::ImageManager(const DeviceInfo& info)
@@ -508,7 +508,6 @@ bool ImageManager::file_load_image(Image *img,
                                    int texture_limit,
                                    device_vector<DeviceType>& tex_img)
 {
-       const StorageType alpha_one = (FileFormat == TypeDesc::UINT8)? 255 : 1;
        ImageInput *in = NULL;
        if(!file_load_image_generic(img, &in)) {
                return false;
@@ -601,13 +600,19 @@ bool ImageManager::file_load_image(Image *img,
                        type == IMAGE_DATA_TYPE_BYTE4 ||
                                        type == IMAGE_DATA_TYPE_USHORT4);
        if(is_rgba) {
+               const StorageType one = util_image_cast_from_float<StorageType>(1.0f);
+
                if(cmyk) {
                        /* CMYK */
                        for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) {
-                               pixels[i*4+2] = (pixels[i*4+2]*pixels[i*4+3])/255;
-                               pixels[i*4+1] = (pixels[i*4+1]*pixels[i*4+3])/255;
-                               pixels[i*4+0] = (pixels[i*4+0]*pixels[i*4+3])/255;
-                               pixels[i*4+3] = alpha_one;
+                               float c = util_image_cast_to_float(pixels[i*4+0]);
+                               float m = util_image_cast_to_float(pixels[i*4+1]);
+                               float y = util_image_cast_to_float(pixels[i*4+2]);
+                               float k = util_image_cast_to_float(pixels[i*4+3]);
+                               pixels[i*4+0] = util_image_cast_from_float<StorageType>((1.0f - c) * (1.0f - k));
+                               pixels[i*4+1] = util_image_cast_from_float<StorageType>((1.0f - m) * (1.0f - k));
+                               pixels[i*4+2] = util_image_cast_from_float<StorageType>((1.0f - y) * (1.0f - k));
+                               pixels[i*4+3] = one;
                        }
                }
                else if(components == 2) {
@@ -622,7 +627,7 @@ bool ImageManager::file_load_image(Image *img,
                else if(components == 3) {
                        /* RGB */
                        for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) {
-                               pixels[i*4+3] = alpha_one;
+                               pixels[i*4+3] = one;
                                pixels[i*4+2] = pixels[i*3+2];
                                pixels[i*4+1] = pixels[i*3+1];
                                pixels[i*4+0] = pixels[i*3+0];
@@ -631,7 +636,7 @@ bool ImageManager::file_load_image(Image *img,
                else if(components == 1) {
                        /* grayscale */
                        for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) {
-                               pixels[i*4+3] = alpha_one;
+                               pixels[i*4+3] = one;
                                pixels[i*4+2] = pixels[i];
                                pixels[i*4+1] = pixels[i];
                                pixels[i*4+0] = pixels[i];
@@ -639,7 +644,7 @@ bool ImageManager::file_load_image(Image *img,
                }
                if(img->use_alpha == false) {
                        for(size_t i = num_pixels-1, pixel = 0; pixel < num_pixels; pixel++, i--) {
-                               pixels[i*4+3] = alpha_one;
+                               pixels[i*4+3] = one;
                        }
                }
        }
@@ -871,7 +876,7 @@ void ImageManager::device_load_image(Device *device,
                        thread_scoped_lock device_lock(device_mutex);
                        uint16_t *pixels = (uint16_t*)tex_img->alloc(1, 1);
 
-                       pixels[0] = TEX_IMAGE_MISSING_R;
+                       pixels[0] = (TEX_IMAGE_MISSING_R * 65535);
                }
 
                img->mem = tex_img;
@@ -893,10 +898,10 @@ void ImageManager::device_load_image(Device *device,
                        thread_scoped_lock device_lock(device_mutex);
                        uint16_t *pixels = (uint16_t*)tex_img->alloc(1, 1);
 
-                       pixels[0] = TEX_IMAGE_MISSING_R;
-                       pixels[1] = TEX_IMAGE_MISSING_G;
-                       pixels[2] = TEX_IMAGE_MISSING_B;
-                       pixels[3] = TEX_IMAGE_MISSING_A;
+                       pixels[0] = (TEX_IMAGE_MISSING_R * 65535);
+                       pixels[1] = (TEX_IMAGE_MISSING_G * 65535);
+                       pixels[2] = (TEX_IMAGE_MISSING_B * 65535);
+                       pixels[3] = (TEX_IMAGE_MISSING_A * 65535);
                }
 
                img->mem = tex_img;
index 58f3f903619feea256138b904e2fd7acfef818d0..53b7f2472bdad0e264410eefe323e9b47d0a664e 100644 (file)
@@ -42,7 +42,7 @@ public:
        half() : v(0) {}
        half(const unsigned short& i) : v(i) {}
        operator unsigned short() { return v; }
-       half & operator =(const unsigned short& i) { v = i; return *this; }
+       half& operator =(const unsigned short& i) { v = i; return *this; }
 private:
        unsigned short v;
 };
index 18876841b5bbdb3bf4ea5afe1723ec086c5b425d..85bdb0d80505b2e128962b34f5c29bebcd7cd285 100644 (file)
@@ -38,6 +38,68 @@ void util_image_resize_pixels(const vector<T>& input_pixels,
                               size_t *output_height,
                               size_t *output_depth);
 
+/* Cast input pixel from unknown storage to float. */
+template<typename T>
+inline float util_image_cast_to_float(T value);
+
+template<>
+inline float util_image_cast_to_float(float value)
+{
+       return value;
+}
+template<>
+inline float util_image_cast_to_float(uchar value)
+{
+       return (float)value / 255.0f;
+}
+template<>
+inline float util_image_cast_to_float(uint16_t value)
+{
+       return (float)value / 65535.0f;
+}
+template<>
+inline float util_image_cast_to_float(half value)
+{
+       return half_to_float(value);
+}
+
+/* Cast float value to output pixel type. */
+template<typename T>
+inline T util_image_cast_from_float(float value);
+
+template<>
+inline float util_image_cast_from_float(float value)
+{
+       return value;
+}
+template<>
+inline uchar util_image_cast_from_float(float value)
+{
+       if(value < 0.0f) {
+               return 0;
+       }
+       else if(value > (1.0f - 0.5f / 255.0f)) {
+               return 255;
+       }
+       return (uchar)((255.0f * value) + 0.5f);
+}
+template<>
+inline uint16_t util_image_cast_from_float(float value)
+{
+       if(value < 0.0f) {
+               return 0;
+       }
+       else if(value > (1.0f - 0.5f / 65535.0f)) {
+               return 65535;
+       }
+       return (uint16_t)((65535.0f * value) + 0.5f);
+}
+template<>
+inline half util_image_cast_from_float(float value)
+{
+       return float_to_half(value);
+}
+
 CCL_NAMESPACE_END
 
 #endif /* __UTIL_IMAGE_H__ */
index fb953a43ab29728fc493f85f45981ec6d0267a20..5bc1c72759556ab3d92b553307e97559a46ad1aa 100644 (file)
@@ -38,68 +38,6 @@ const T *util_image_read(const vector<T>& pixels,
        return &pixels[index];
 }
 
-/* Cast input pixel from unknown storage to float. */
-template<typename T>
-inline float cast_to_float(T value);
-
-template<>
-inline float cast_to_float(float value)
-{
-       return value;
-}
-template<>
-inline float cast_to_float(uchar value)
-{
-       return (float)value / 255.0f;
-}
-template<>
-inline float cast_to_float(uint16_t value)
-{
-       return (float)value / 65535.0f;
-}
-template<>
-inline float cast_to_float(half value)
-{
-       return half_to_float(value);
-}
-
-/* Cast float value to output pixel type. */
-template<typename T>
-inline T cast_from_float(float value);
-
-template<>
-inline float cast_from_float(float value)
-{
-       return value;
-}
-template<>
-inline uchar cast_from_float(float value)
-{
-       if(value < 0.0f) {
-               return 0;
-       }
-       else if(value > (1.0f - 0.5f / 255.0f)) {
-               return 255;
-       }
-       return (uchar)((255.0f * value) + 0.5f);
-}
-template<>
-inline uint16_t cast_from_float(float value)
-{
-       if(value < 0.0f) {
-               return 0;
-       }
-       else if(value >(1.0f - 0.5f / 65535.0f)) {
-               return 65535;
-       }
-       return (uchar)((65535.0f * value) + 0.5f);
-}
-template<>
-inline half cast_from_float(float value)
-{
-       return float_to_half(value);
-}
-
 template<typename T>
 void util_image_downscale_sample(const vector<T>& pixels,
                                  const size_t width,
@@ -133,7 +71,7 @@ void util_image_downscale_sample(const vector<T>& pixels,
                                                                 components,
                                                                 nx, ny, nz);
                                for(size_t k = 0; k < components; ++k) {
-                                       accum[k] += cast_to_float(pixel[k]);
+                                       accum[k] += util_image_cast_to_float(pixel[k]);
                                }
                                ++count;
                        }
@@ -142,7 +80,7 @@ void util_image_downscale_sample(const vector<T>& pixels,
        if(count != 0) {
                const float inv_count = 1.0f / (float)count;
                for(size_t k = 0; k < components; ++k) {
-                       result[k] = cast_from_float<T>(accum[k] * inv_count);
+                       result[k] = util_image_cast_from_float<T>(accum[k] * inv_count);
                }
        }
        else {
index 7ddc87a2524b3db5d456da010d3a59140eac93a6..d1a7f4ffea1214fd50a8915bbdb97c1cf46c6f54 100644 (file)
 /** \file blender/windowmanager/intern/wm_playanim.c
  *  \ingroup wm
  *
+ * Animation player for image sequences & video's with sound support.
+ * Launched in a separate process from Blender's #RENDER_OT_play_rendered_anim
+ *
  * \note This file uses ghost directly and none of the WM definitions.
- *       this could be made into its own module, alongside creator/
+ * this could be made into its own module, alongside creator.
  */
 
 #include <sys/types.h>