📄 pixman-pict.c
字号:
/* -*- Mode: c; c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t; -*- *//* * Copyright © 2000 SuSE, Inc. * Copyright © 2007 Red Hat, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of SuSE not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. SuSE makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Keith Packard, SuSE, Inc. */#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <stdio.h>#include <stdlib.h>#include <string.h>#include "pixman-private.h"#include "pixman-mmx.h"#include "pixman-sse.h"#define FbFullMask(n) ((n) == 32 ? (uint32_t)-1 : ((((uint32_t) 1) << n) - 1))#undef READ#undef WRITE#define READ(img,x) (*(x))#define WRITE(img,ptr,v) ((*(ptr)) = (v))typedef void (* CompositeFunc) (pixman_op_t, pixman_image_t *, pixman_image_t *, pixman_image_t *, int16_t, int16_t, int16_t, int16_t, int16_t, int16_t, uint16_t, uint16_t);uint32_tfbOver (uint32_t x, uint32_t y){ uint16_t a = ~x >> 24; uint16_t t; uint32_t m,n,o,p; m = FbOverU(x,y,0,a,t); n = FbOverU(x,y,8,a,t); o = FbOverU(x,y,16,a,t); p = FbOverU(x,y,24,a,t); return m|n|o|p;}uint32_tfbOver24 (uint32_t x, uint32_t y){ uint16_t a = ~x >> 24; uint16_t t; uint32_t m,n,o; m = FbOverU(x,y,0,a,t); n = FbOverU(x,y,8,a,t); o = FbOverU(x,y,16,a,t); return m|n|o;}uint32_tfbIn (uint32_t x, uint8_t y){ uint16_t a = y; uint16_t t; uint32_t m,n,o,p; m = FbInU(x,0,a,t); n = FbInU(x,8,a,t); o = FbInU(x,16,a,t); p = FbInU(x,24,a,t); return m|n|o|p;}/* * Naming convention: * * opSRCxMASKxDST */static voidfbCompositeOver_x888x8x8888 (pixman_op_t op, pixman_image_t * pSrc, pixman_image_t * pMask, pixman_image_t * pDst, int16_t xSrc, int16_t ySrc, int16_t xMask, int16_t yMask, int16_t xDst, int16_t yDst, uint16_t width, uint16_t height){ uint32_t *src, *srcLine; uint32_t *dst, *dstLine; uint8_t *mask, *maskLine; int srcStride, maskStride, dstStride; uint8_t m; uint32_t s, d; uint16_t w; fbComposeGetStart (pDst, xDst, yDst, uint32_t, dstStride, dstLine, 1); fbComposeGetStart (pMask, xMask, yMask, uint8_t, maskStride, maskLine, 1); fbComposeGetStart (pSrc, xSrc, ySrc, uint32_t, srcStride, srcLine, 1); while (height--) { src = srcLine; srcLine += srcStride; dst = dstLine; dstLine += dstStride; mask = maskLine; maskLine += maskStride; w = width; while (w--) { m = READ(pMask, mask++); if (m) { s = READ(pSrc, src) | 0xff000000; if (m == 0xff) WRITE(pDst, dst, s); else { d = fbIn (s, m); WRITE(pDst, dst, fbOver (d, READ(pDst, dst))); } } src++; dst++; } }}static voidfbCompositeSolidMaskIn_nx8x8 (pixman_op_t op, pixman_image_t *iSrc, pixman_image_t *iMask, pixman_image_t *iDst, int16_t xSrc, int16_t ySrc, int16_t xMask, int16_t yMask, int16_t xDst, int16_t yDst, uint16_t width, uint16_t height){ uint32_t src, srca; uint8_t *dstLine, *dst, dstMask; uint8_t *maskLine, *mask, m; int dstStride, maskStride; uint16_t w; uint16_t t; fbComposeGetSolid(iSrc, src, iDst->bits.format); dstMask = FbFullMask (PIXMAN_FORMAT_DEPTH (iDst->bits.format)); srca = src >> 24; fbComposeGetStart (iDst, xDst, yDst, uint8_t, dstStride, dstLine, 1); fbComposeGetStart (iMask, xMask, yMask, uint8_t, maskStride, maskLine, 1); if (srca == 0xff) { while (height--) { dst = dstLine; dstLine += dstStride; mask = maskLine; maskLine += maskStride; w = width; while (w--) { m = *mask++; if (m == 0) { *dst = 0; } else if (m != 0xff) { *dst = FbIntMult(m, *dst, t); } dst++; } } } else { while (height--) { dst = dstLine; dstLine += dstStride; mask = maskLine; maskLine += maskStride; w = width; while (w--) { m = *mask++; m = FbIntMult(m, srca, t); if (m == 0) { *dst = 0; } else if (m != 0xff) { *dst = FbIntMult(m, *dst, t); } dst++; } } }}static voidfbCompositeSrcIn_8x8 (pixman_op_t op, pixman_image_t *iSrc, pixman_image_t *iMask, pixman_image_t *iDst, int16_t xSrc, int16_t ySrc, int16_t xMask, int16_t yMask, int16_t xDst, int16_t yDst, uint16_t width, uint16_t height){ uint8_t *dstLine, *dst; uint8_t *srcLine, *src; int dstStride, srcStride; uint16_t w; uint8_t s; uint16_t t; fbComposeGetStart (iSrc, xSrc, ySrc, uint8_t, srcStride, srcLine, 1); fbComposeGetStart (iDst, xDst, yDst, uint8_t, dstStride, dstLine, 1); while (height--) { dst = dstLine; dstLine += dstStride; src = srcLine; srcLine += srcStride; w = width; while (w--) { s = *src++; if (s == 0) { *dst = 0; } else if (s != 0xff) { *dst = FbIntMult(s, *dst, t); } dst++; } }}voidfbCompositeSolidMask_nx8x8888 (pixman_op_t op, pixman_image_t * pSrc, pixman_image_t * pMask, pixman_image_t * pDst, int16_t xSrc, int16_t ySrc, int16_t xMask, int16_t yMask, int16_t xDst, int16_t yDst, uint16_t width, uint16_t height){ uint32_t src, srca; uint32_t *dstLine, *dst, d, dstMask; uint8_t *maskLine, *mask, m; int dstStride, maskStride; uint16_t w; fbComposeGetSolid(pSrc, src, pDst->bits.format); dstMask = FbFullMask (PIXMAN_FORMAT_DEPTH (pDst->bits.format)); srca = src >> 24; if (src == 0) return; fbComposeGetStart (pDst, xDst, yDst, uint32_t, dstStride, dstLine, 1); fbComposeGetStart (pMask, xMask, yMask, uint8_t, maskStride, maskLine, 1); while (height--) { dst = dstLine; dstLine += dstStride; mask = maskLine; maskLine += maskStride; w = width; while (w--) { m = READ(pMask, mask++); if (m == 0xff) { if (srca == 0xff) WRITE(pDst, dst, src & dstMask); else WRITE(pDst, dst, fbOver (src, READ(pDst, dst)) & dstMask); } else if (m) { d = fbIn (src, m); WRITE(pDst, dst, fbOver (d, READ(pDst, dst)) & dstMask); } dst++; } }}voidfbCompositeSolidMask_nx8888x8888C (pixman_op_t op, pixman_image_t * pSrc, pixman_image_t * pMask, pixman_image_t * pDst, int16_t xSrc, int16_t ySrc, int16_t xMask, int16_t yMask, int16_t xDst, int16_t yDst, uint16_t width, uint16_t height){ uint32_t src, srca; uint32_t *dstLine, *dst, d, dstMask; uint32_t *maskLine, *mask, ma; int dstStride, maskStride; uint16_t w; uint32_t m, n, o, p; fbComposeGetSolid(pSrc, src, pDst->bits.format); dstMask = FbFullMask (PIXMAN_FORMAT_DEPTH (pDst->bits.format)); srca = src >> 24; if (src == 0) return; fbComposeGetStart (pDst, xDst, yDst, uint32_t, dstStride, dstLine, 1); fbComposeGetStart (pMask, xMask, yMask, uint32_t, maskStride, maskLine, 1); while (height--) { dst = dstLine; dstLine += dstStride; mask = maskLine; maskLine += maskStride; w = width; while (w--) { ma = READ(pMask, mask++); if (ma == 0xffffffff) { if (srca == 0xff) WRITE(pDst, dst, src & dstMask); else WRITE(pDst, dst, fbOver (src, READ(pDst, dst)) & dstMask); } else if (ma) { d = READ(pDst, dst);#define FbInOverC(src,srca,msk,dst,i,result) { \ uint16_t __a = FbGet8(msk,i); \ uint32_t __t, __ta; \ uint32_t __i; \ __t = FbIntMult (FbGet8(src,i), __a,__i); \ __ta = (uint8_t) ~FbIntMult (srca, __a,__i); \ __t = __t + FbIntMult(FbGet8(dst,i),__ta,__i); \ __t = (uint32_t) (uint8_t) (__t | (-(__t >> 8))); \ result = __t << (i); \} FbInOverC (src, srca, ma, d, 0, m); FbInOverC (src, srca, ma, d, 8, n); FbInOverC (src, srca, ma, d, 16, o); FbInOverC (src, srca, ma, d, 24, p); WRITE(pDst, dst, m|n|o|p); } dst++; } }}voidfbCompositeSolidMask_nx8x0888 (pixman_op_t op, pixman_image_t * pSrc, pixman_image_t * pMask, pixman_image_t * pDst, int16_t xSrc, int16_t ySrc, int16_t xMask, int16_t yMask, int16_t xDst, int16_t yDst, uint16_t width, uint16_t height){ uint32_t src, srca; uint8_t *dstLine, *dst; uint32_t d; uint8_t *maskLine, *mask, m; int dstStride, maskStride; uint16_t w; fbComposeGetSolid(pSrc, src, pDst->bits.format); srca = src >> 24; if (src == 0) return; fbComposeGetStart (pDst, xDst, yDst, uint8_t, dstStride, dstLine, 3); fbComposeGetStart (pMask, xMask, yMask, uint8_t, maskStride, maskLine, 1); while (height--) { dst = dstLine; dstLine += dstStride; mask = maskLine; maskLine += maskStride; w = width; while (w--) { m = READ(pMask, mask++); if (m == 0xff) { if (srca == 0xff) d = src; else { d = Fetch24(pDst, dst); d = fbOver24 (src, d); } Store24(pDst, dst,d); } else if (m) { d = fbOver24 (fbIn(src,m), Fetch24(pDst, dst)); Store24(pDst, dst, d); } dst += 3; } }}voidfbCompositeSolidMask_nx8x0565 (pixman_op_t op, pixman_image_t * pSrc, pixman_image_t * pMask, pixman_image_t * pDst, int16_t xSrc, int16_t ySrc, int16_t xMask, int16_t yMask, int16_t xDst, int16_t yDst, uint16_t width, uint16_t height){ uint32_t src, srca; uint16_t *dstLine, *dst; uint32_t d;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -