Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/native/sun/java2d/loops/vis_AlphaMacros.h
32288 views
/*1* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#if !defined(JAVA2D_NO_MLIB) || defined(MLIB_ADD_SUFF)2627#include <vis_proto.h>28#include <mlib_image.h>2930#include "java2d_Mlib.h"31#include "AlphaMacros.h"3233/***************************************************************/3435extern const mlib_u32 vis_mul8s_tbl[];36extern const mlib_u64 vis_div8_tbl[];37extern const mlib_u64 vis_div8pre_tbl[];3839/***************************************************************/4041void IntArgbToIntAbgrConvert_line(mlib_s32 *srcBase,42mlib_s32 *dstBase,43mlib_s32 width);4445/***************************************************************/4647#define BUFF_SIZE 2564849/***************************************************************/5051#define COPY_NA(src, dst, _size) { \52mlib_s32 cci, size = _size; \53if (size <= 16) { \54for (cci = 0; cci < size; cci++) { \55((mlib_u8*)dst)[cci] = ((mlib_u8*)src)[cci]; \56} \57} else { \58mlib_ImageCopy_na(src, dst, size); \59} \60}6162/***************************************************************/6364#define MUL8_INT(x, y) mul8_tbl[256*(y) + (x)]6566#define FMUL_16x16(x, y) \67vis_fpadd16(vis_fmul8sux16(x, y), vis_fmul8ulx16(x, y))6869/***************************************************************/7071#define MUL8_VIS(rr, alp) \72vis_fmul8x16al(rr, ((mlib_f32 *)vis_mul8s_tbl)[alp])7374#define DIV_ALPHA(rr, alp) { \75mlib_d64 d_div = ((mlib_d64*)vis_div8_tbl)[alp]; \76rr = FMUL_16x16(rr, d_div); \77}7879#define DIV_ALPHA_RGB(rr, alp) \80DIV_ALPHA(rr, alp)8182/***************************************************************/8384#define BLEND_VIS(rr, dstARGB, srcARGB, dstA, srcA) \85{ \86mlib_d64 t0, t1; \87\88t0 = MUL8_VIS(srcARGB, srcA); \89t1 = MUL8_VIS(dstARGB, dstA); \90rr = vis_fpadd16(t0, t1); \91\92dstA += srcA; \93DIV_ALPHA(rr, dstA); \94}9596#define BLEND_VIS_RGB(rr, dstARGB, srcARGB, dstA, srcA) \97BLEND_VIS(rr, dstARGB, srcARGB, dstA, srcA)9899/***************************************************************/100101#if 0102extern const mlib_u16 vis_div8_16_tbl[];103104#undef BLEND_VIS105#define BLEND_VIS(rr, dstARGB, srcARGB, dstA, srcA) \106{ \107mlib_d64 done = vis_to_double_dup(0x00FFFFFF); \108mlib_d64 t0, t1; \109mlib_f32 s0, s1; \110mlib_s32 resA; \111\112resA = dstA + srcA; \113t0 = vis_ld_u16((mlib_u16*)vis_div8_16_tbl + 256*srcA + resA); \114t1 = vis_ld_u16((mlib_u16*)vis_div8_16_tbl + 256*dstA + resA); \115dstA = resA; \116\117t0 = vis_fmul8x16al(srcARGB, vis_read_lo(t0)); \118t1 = vis_fmul8x16al(dstARGB, vis_read_lo(t1)); \119rr = vis_fpadd16(t0, t1); \120}121122#define BLEND_VIS_RGB(rr, dstARGB, srcARGB, dstA, srcA) \123{ \124mlib_d64 maskRGB = vis_to_double_dup(0x00FFFFFF); \125\126BLEND_VIS(rr, dstARGB, srcARGB, dstA, srcA) \127\128rr = vis_fand(rr, maskRGB); \129}130131#endif132133/***************************************************************/134135#define F32_FROM_U8x4(x0, x1, x2, x3) \136vis_to_float(((x0) << 24) | ((x1) << 16) | ((x2)<< 8) | ((x3)))137138/***************************************************************/139140#define D64_FROM_U8x8(dd, val) \141val &= 0xFF; \142val |= (val << 8); \143val |= (val << 16); \144dd = vis_to_double_dup(val)145146/***************************************************************/147148#define D64_FROM_U16x4(dd, val) \149val &= 0xFFFF; \150val |= (val << 16); \151dd = vis_to_double_dup(val)152153/***************************************************************/154155#define D64_FROM_F32x2(ff) \156vis_freg_pair(ff, ff)157158/***************************************************************/159160#if VIS >= 0x200161162#define ARGB2ABGR_FL(src) \163src = vis_read_hi(vis_bshuffle(vis_freg_pair(src, vis_fzeros()), 0));164165#define ARGB2ABGR_FL2(dst, src0, src1) \166dst = vis_freg_pair(src0, src1); \167dst = vis_bshuffle(dst, 0)168169#define ARGB2ABGR_DB(src) \170src = vis_bshuffle(src, 0);171172#else173174#define ARGB2ABGR_FL(src) { \175mlib_d64 t0, t1, t2, t3; \176t0 = vis_fpmerge(src, src); \177t1 = vis_fpmerge(vis_read_lo(t0), vis_read_hi(t0)); \178t2 = vis_fpmerge(vis_read_hi(t0), vis_read_lo(t0)); \179t3 = vis_fpmerge(vis_read_hi(t2), vis_read_lo(t1)); \180src = vis_read_hi(t3); \181}182183#define ARGB2ABGR_FL2(dst, src0, src1) { \184mlib_d64 t0, t1, t2; \185t0 = vis_fpmerge(src0, src1); \186t1 = vis_fpmerge(vis_read_lo(t0), vis_read_hi(t0)); \187t2 = vis_fpmerge(vis_read_hi(t0), vis_read_lo(t0)); \188dst = vis_fpmerge(vis_read_hi(t2), vis_read_lo(t1)); \189}190191#define ARGB2ABGR_DB(src) \192ARGB2ABGR_FL2(src, vis_read_hi(src), vis_read_lo(src))193194#endif195196/***************************************************************/197198#endif /* JAVA2D_NO_MLIB */199200201