Merge branch 'master' into blender2.8

This commit is contained in:
Campbell Barton 2018-05-07 17:54:10 +02:00
commit f62b826533
8 changed files with 40 additions and 27 deletions

View File

@ -31,6 +31,7 @@ extern "C" {
#include "DNA_customdata_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_math_base.h"
#include "BKE_customdata.h"
}

View File

@ -224,29 +224,6 @@ extern "C" {
b = tmp; \
} (void)0
#define FTOCHAR(val) ((CHECK_TYPE_INLINE(val, float)), \
(char)(((val) <= 0.0f) ? 0 : (((val) > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * (val)) + 0.5f))))
#define FTOUSHORT(val) ((CHECK_TYPE_INLINE(val, float)), \
(unsigned short)((val >= 1.0f - 0.5f / 65535) ? 65535 : (val <= 0.0f) ? 0 : (val * 65535.0f + 0.5f)))
#define USHORTTOUCHAR(val) ((unsigned char)(((val) >= 65535 - 128) ? 255 : ((val) + 128) >> 8))
#define F3TOCHAR3(v2, v1) { \
(v1)[0] = FTOCHAR((v2[0])); \
(v1)[1] = FTOCHAR((v2[1])); \
(v1)[2] = FTOCHAR((v2[2])); \
} (void)0
#define F3TOCHAR4(v2, v1) { \
(v1)[0] = FTOCHAR((v2[0])); \
(v1)[1] = FTOCHAR((v2[1])); \
(v1)[2] = FTOCHAR((v2[2])); \
(v1)[3] = 255; \
} (void)0
#define F4TOCHAR4(v2, v1) { \
(v1)[0] = FTOCHAR((v2[0])); \
(v1)[1] = FTOCHAR((v2[1])); \
(v1)[2] = FTOCHAR((v2[2])); \
(v1)[3] = FTOCHAR((v2[3])); \
} (void)0
#define VECCOPY(v1, v2) { \
*(v1) = *(v2); \
*(v1 + 1) = *(v2 + 1); \

View File

@ -513,6 +513,38 @@ MALWAYS_INLINE __m128 _bli_math_blend_sse(const __m128 mask,
return _mm_or_ps(_mm_and_ps(mask, a), _mm_andnot_ps(mask, b));
}
/* Low level conversion functions */
/* TODO: name sensibly. */
MINLINE unsigned char FTOCHAR(float val)
{
return (unsigned char)(((val <= 0.0f) ? 0 : ((val > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * val) + 0.5f))));
}
#define FTOCHAR(val) ((CHECK_TYPE_INLINE(val, float)), FTOCHAR(val))
MINLINE unsigned short FTOUSHORT(float val)
{
return (unsigned short)((val >= 1.0f - 0.5f / 65535) ? 65535 : (val <= 0.0f) ? 0 : (val * 65535.0f + 0.5f));
}
#define FTOUSHORT(val) ((CHECK_TYPE_INLINE(val, float)), FTOUSHORT(val))
MINLINE unsigned char USHORTTOUCHAR(unsigned short val)
{
return (unsigned char)(((val) >= 65535 - 128) ? 255 : ((val) + 128) >> 8);
}
#define USHORTTOUCHAR(val) ((CHECK_TYPE_INLINE(val, unsigned short)), USHORTTOUCHAR(val))
#define F3TOCHAR3(v2, v1) { \
(v1)[0] = FTOCHAR((v2[0])); \
(v1)[1] = FTOCHAR((v2[1])); \
(v1)[2] = FTOCHAR((v2[2])); \
} ((void)0)
#define F4TOCHAR4(v2, v1) { \
(v1)[0] = FTOCHAR((v2[0])); \
(v1)[1] = FTOCHAR((v2[1])); \
(v1)[2] = FTOCHAR((v2[2])); \
(v1)[3] = FTOCHAR((v2[3])); \
} ((void)0)
#endif /* __SSE2__ */
#endif /* __MATH_BASE_INLINE_C__ */

View File

@ -105,7 +105,7 @@ void PreviewOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
color[3] = 1.0f;
this->m_input->readSampled(color, rx, ry, COM_PS_NEAREST);
IMB_colormanagement_processor_apply_v4(cm_processor, color);
F4TOCHAR4(color, this->m_outputBuffer + offset);
rgba_float_to_uchar(this->m_outputBuffer + offset, color);
offset += 4;
}
}

View File

@ -34,6 +34,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
#include "BLI_math_base.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"

View File

@ -332,9 +332,9 @@ MINLINE void premul_ushort_to_straight_uchar(unsigned char *result, const unsign
else {
unsigned short alpha = color[3] / 256;
result[0] = USHORTTOUCHAR(color[0] / alpha * 256);
result[1] = USHORTTOUCHAR(color[1] / alpha * 256);
result[2] = USHORTTOUCHAR(color[2] / alpha * 256);
result[0] = USHORTTOUCHAR((ushort)(color[0] / alpha * 256));
result[1] = USHORTTOUCHAR((ushort)(color[1] / alpha * 256));
result[2] = USHORTTOUCHAR((ushort)(color[2] / alpha * 256));
result[3] = USHORTTOUCHAR(color[3]);
}
}

View File

@ -33,6 +33,7 @@
#include "DNA_object_types.h"
#include "BLI_utildefines.h"
#include "BLI_math_base.h"
#include "BKE_icons.h"
#include "BKE_object.h"

View File

@ -30,6 +30,7 @@
#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
#include "BLI_math_base.h"
#include "BKE_context.h"
#include "BKE_image.h"