Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/native/sun/java2d/loops/vis_ThreeByteBgr.c
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_AlphaMacros.h"2829/***************************************************************/3031#define GBR_PIXEL(i) \320xFF000000 | (src[3*i + 2] << 16) | (src[3*i + 1] << 8) | src[3*i]3334/***************************************************************/3536#define BGR_TO_ARGB { \37mlib_d64 sda, sdb, sdc, sdd, sde, sdf; \38mlib_d64 s_1, s_2, s_3, a13, b13, a02, b02; \39\40sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1)); \41sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2)); \42sdc = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2)); \43\44sdd = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb)); \45sde = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdc)); \46sdf = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc)); \47\48s_3 = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde)); \49s_2 = vis_fpmerge(vis_read_lo(sdd), vis_read_hi(sdf)); \50s_1 = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sdf)); \51\52a13 = vis_fpmerge(vis_read_hi(s_1), vis_read_hi(s_3)); \53b13 = vis_fpmerge(vis_read_lo(s_1), vis_read_lo(s_3)); \54a02 = vis_fpmerge(vis_read_hi(s_0), vis_read_hi(s_2)); \55b02 = vis_fpmerge(vis_read_lo(s_0), vis_read_lo(s_2)); \56\57dd0 = vis_fpmerge(vis_read_hi(a02), vis_read_hi(a13)); \58dd1 = vis_fpmerge(vis_read_lo(a02), vis_read_lo(a13)); \59dd2 = vis_fpmerge(vis_read_hi(b02), vis_read_hi(b13)); \60dd3 = vis_fpmerge(vis_read_lo(b02), vis_read_lo(b13)); \61}6263/***************************************************************/6465void ADD_SUFF(ThreeByteBgrToIntArgbConvert)(BLIT_PARAMS)66{67mlib_s32 dstScan = pDstInfo->scanStride;68mlib_s32 srcScan = pSrcInfo->scanStride;69mlib_d64 *sp;70mlib_d64 s_0;71mlib_d64 s0, s1, s2, s3, sd0, sd1, sd2, dd0, dd1, dd2, dd3;72mlib_s32 i, i0, j;7374if (width < 16) {75for (j = 0; j < height; j++) {76mlib_u8 *src = srcBase;77mlib_s32 *dst = dstBase;7879for (i = 0; i < width; i++) {80dst[i] = GBR_PIXEL(i);81}8283PTR_ADD(dstBase, dstScan);84PTR_ADD(srcBase, srcScan);85}86return;87}8889if (srcScan == 3*width && dstScan == 4*width) {90width *= height;91height = 1;92}9394s_0 = vis_fone();9596for (j = 0; j < height; j++) {97mlib_u8 *src = srcBase;98mlib_f32 *dst = dstBase;99100i = i0 = 0;101102if ((mlib_s32)dst & 7) {103((mlib_s32*)dst)[i] = GBR_PIXEL(i);104i0 = 1;105}106107sp = vis_alignaddr(src, 3*i0);108s3 = *sp++;109110#pragma pipeloop(0)111for (i = i0; i <= (mlib_s32)width - 8; i += 8) {112s0 = s3;113s1 = *sp++;114s2 = *sp++;115s3 = *sp++;116sd0 = vis_faligndata(s0, s1);117sd1 = vis_faligndata(s1, s2);118sd2 = vis_faligndata(s2, s3);119120BGR_TO_ARGB121122*(mlib_d64*)(dst + i ) = dd0;123*(mlib_d64*)(dst + i + 2) = dd1;124*(mlib_d64*)(dst + i + 4) = dd2;125*(mlib_d64*)(dst + i + 6) = dd3;126}127128for (; i < width; i++) {129((mlib_s32*)dst)[i] = GBR_PIXEL(i);130}131132PTR_ADD(dstBase, dstScan);133PTR_ADD(srcBase, srcScan);134}135}136137/***************************************************************/138139void ADD_SUFF(ThreeByteBgrToIntArgbScaleConvert)(SCALE_PARAMS)140{141mlib_s32 dstScan = pDstInfo->scanStride;142mlib_s32 srcScan = pSrcInfo->scanStride;143mlib_d64 dd, maskFF;144mlib_s32 i, i0, i1, j;145146if (width < 16) {147for (j = 0; j < height; j++) {148mlib_u8 *src = srcBase;149mlib_s32 *dst = dstBase;150mlib_s32 *dst_end = dst + width;151mlib_s32 tmpsxloc = sxloc;152153PTR_ADD(src, (syloc >> shift) * srcScan);154155for (; dst < dst_end; dst++) {156i = tmpsxloc >> shift;157tmpsxloc += sxinc;158*(mlib_s32*)dst = GBR_PIXEL(i);159}160161PTR_ADD(dstBase, dstScan);162syloc += syinc;163}164return;165}166167maskFF = vis_fone();168169vis_alignaddr(NULL, 7);170171for (j = 0; j < height; j++) {172mlib_u8 *src = srcBase;173mlib_f32 *dst = dstBase;174mlib_f32 *dst_end = dst + width;175mlib_s32 tmpsxloc = sxloc;176177PTR_ADD(src, (syloc >> shift) * srcScan);178179if ((mlib_s32)dst & 7) {180i = tmpsxloc >> shift;181tmpsxloc += sxinc;182*(mlib_s32*)dst = GBR_PIXEL(i);183dst++;184}185186#pragma pipeloop(0)187for (; dst <= dst_end - 2; dst += 2) {188i0 = tmpsxloc >> shift;189i1 = (tmpsxloc + sxinc) >> shift;190tmpsxloc += 2*sxinc;191192dd = vis_faligndata(vis_ld_u8(src + 3*i1 ), dd);193dd = vis_faligndata(vis_ld_u8(src + 3*i1 + 1), dd);194dd = vis_faligndata(vis_ld_u8(src + 3*i1 + 2), dd);195dd = vis_faligndata(maskFF, dd);196dd = vis_faligndata(vis_ld_u8(src + 3*i0 ), dd);197dd = vis_faligndata(vis_ld_u8(src + 3*i0 + 1), dd);198dd = vis_faligndata(vis_ld_u8(src + 3*i0 + 2), dd);199dd = vis_faligndata(maskFF, dd);200201*(mlib_d64*)dst = dd;202}203204for (; dst < dst_end; dst++) {205i = tmpsxloc >> shift;206tmpsxloc += sxinc;207*(mlib_s32*)dst = GBR_PIXEL(i);208}209210PTR_ADD(dstBase, dstScan);211syloc += syinc;212}213}214215/***************************************************************/216217#endif218219220