2013-01-19 02:32:58 +04:00
|
|
|
/* prim_internal.h
|
|
|
|
* vi:ts=4 sw=4
|
|
|
|
*
|
|
|
|
* (c) Copyright 2012 Hewlett-Packard Development Company, L.P.
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License. You may obtain
|
|
|
|
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
|
|
* or implied. See the License for the specific language governing
|
|
|
|
* permissions and limitations under the License. Algorithms used by
|
|
|
|
* this code may be covered by patents by HP, Microsoft, or other parties.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
# pragma once
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PRIM_INTERNAL_H_INCLUDED__
|
|
|
|
#define __PRIM_INTERNAL_H_INCLUDED__
|
|
|
|
|
|
|
|
#ifndef CMAKE_BUILD_TYPE
|
|
|
|
#define CMAKE_BUILD_TYPE Release
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <freerdp/primitives.h>
|
2016-08-10 10:12:55 +03:00
|
|
|
#include <freerdp/api.h>
|
2013-01-19 02:32:58 +04:00
|
|
|
|
2017-02-03 13:56:44 +03:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define PRIM_ALIGN_128 __attribute__((aligned(16)))
|
|
|
|
#else
|
|
|
|
#ifdef _WIN32
|
|
|
|
#define PRIM_ALIGN_128 __declspec(align(16))
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2013-01-19 02:32:58 +04:00
|
|
|
/* Use lddqu for unaligned; load for 16-byte aligned. */
|
|
|
|
#define LOAD_SI128(_ptr_) \
|
|
|
|
(((ULONG_PTR) (_ptr_) & 0x0f) \
|
2016-04-05 18:07:45 +03:00
|
|
|
? _mm_lddqu_si128((__m128i *) (_ptr_)) \
|
|
|
|
: _mm_load_si128((__m128i *) (_ptr_)))
|
2013-01-19 02:32:58 +04:00
|
|
|
|
2016-11-25 14:00:41 +03:00
|
|
|
static INLINE BYTE* writePixelBGRX(BYTE* dst, DWORD formatSize, UINT32 format,
|
|
|
|
BYTE R, BYTE G, BYTE B, BYTE A)
|
|
|
|
{
|
|
|
|
*dst++ = B;
|
|
|
|
*dst++ = G;
|
|
|
|
*dst++ = R;
|
|
|
|
*dst++ = A;
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE BYTE* writePixelRGBX(BYTE* dst, DWORD formatSize, UINT32 format,
|
|
|
|
BYTE R, BYTE G, BYTE B, BYTE A)
|
|
|
|
{
|
|
|
|
*dst++ = R;
|
|
|
|
*dst++ = G;
|
|
|
|
*dst++ = B;
|
|
|
|
*dst++ = A;
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE BYTE* writePixelXBGR(BYTE* dst, DWORD formatSize, UINT32 format,
|
|
|
|
BYTE R, BYTE G, BYTE B, BYTE A)
|
|
|
|
{
|
|
|
|
*dst++ = A;
|
|
|
|
*dst++ = B;
|
|
|
|
*dst++ = G;
|
|
|
|
*dst++ = R;
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE BYTE* writePixelXRGB(BYTE* dst, DWORD formatSize, UINT32 format,
|
|
|
|
BYTE R, BYTE G, BYTE B, BYTE A)
|
|
|
|
{
|
|
|
|
*dst++ = A;
|
|
|
|
*dst++ = R;
|
|
|
|
*dst++ = G;
|
|
|
|
*dst++ = B;
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE BYTE* writePixelGeneric(BYTE* dst, DWORD formatSize, UINT32 format,
|
|
|
|
BYTE R, BYTE G, BYTE B, BYTE A)
|
|
|
|
{
|
|
|
|
UINT32 color = GetColor(format, R, G, B, A);
|
|
|
|
WriteColor(dst, format, color);
|
|
|
|
return dst + formatSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef BYTE* (*fkt_writePixel)(BYTE*, DWORD, UINT32, BYTE, BYTE, BYTE, BYTE);
|
|
|
|
|
|
|
|
static INLINE fkt_writePixel getPixelWriteFunction(DWORD format)
|
|
|
|
{
|
|
|
|
switch (format)
|
|
|
|
{
|
2017-01-12 17:30:06 +03:00
|
|
|
case PIXEL_FORMAT_ARGB32:
|
|
|
|
case PIXEL_FORMAT_XRGB32:
|
|
|
|
return writePixelXRGB;
|
2016-11-25 14:00:41 +03:00
|
|
|
|
2017-01-12 17:30:06 +03:00
|
|
|
case PIXEL_FORMAT_ABGR32:
|
|
|
|
case PIXEL_FORMAT_XBGR32:
|
|
|
|
return writePixelXBGR;
|
2016-11-25 14:00:41 +03:00
|
|
|
|
2017-01-12 17:30:06 +03:00
|
|
|
case PIXEL_FORMAT_RGBA32:
|
|
|
|
case PIXEL_FORMAT_RGBX32:
|
|
|
|
return writePixelRGBX;
|
2016-11-25 14:00:41 +03:00
|
|
|
|
2017-01-12 17:30:06 +03:00
|
|
|
case PIXEL_FORMAT_BGRA32:
|
|
|
|
case PIXEL_FORMAT_BGRX32:
|
|
|
|
return writePixelBGRX;
|
2016-11-25 14:00:41 +03:00
|
|
|
|
2017-01-12 17:30:06 +03:00
|
|
|
default:
|
|
|
|
return writePixelGeneric;
|
2016-11-25 14:00:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-12 17:30:06 +03:00
|
|
|
static INLINE BYTE CLIP(INT32 X)
|
|
|
|
{
|
|
|
|
if (X > 255L)
|
|
|
|
return 255L;
|
|
|
|
|
|
|
|
if (X < 0L)
|
|
|
|
return 0L;
|
|
|
|
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2013-01-19 02:32:58 +04:00
|
|
|
/* Function prototypes for all the init/deinit routines. */
|
2016-08-10 10:12:55 +03:00
|
|
|
FREERDP_LOCAL void primitives_init_copy(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_set(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_add(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_andor(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_shift(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_sign(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_alphaComp(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_colors(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_YCoCg(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_YUV(primitives_t* prims);
|
|
|
|
|
|
|
|
FREERDP_LOCAL void primitives_init_copy_opt(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_set_opt(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_add_opt(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_andor_opt(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_shift_opt(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_sign_opt(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_alphaComp_opt(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_colors_opt(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_YCoCg_opt(primitives_t* prims);
|
|
|
|
FREERDP_LOCAL void primitives_init_YUV_opt(primitives_t* prims);
|
2014-07-03 00:30:04 +04:00
|
|
|
|
2013-01-19 02:32:58 +04:00
|
|
|
#endif /* !__PRIM_INTERNAL_H_INCLUDED__ */
|