⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qblackraster.c

📁 奇趣公司比较新的qt/emd版本
💻 C
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************** This file is part of the QtGui module of the Qt Toolkit.**** This file contains third party code which is not governed by the Qt** Commercial License Agreement. Please read the license headers below** for more information.** ** Further information about Qt licensing is available at:** http://www.trolltech.com/products/qt/licensing.html or by** contacting info@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************//***************************************************************************//*                                                                         *//*  qblackraster.c, derived from ftraster.c                                *//*                                                                         *//*    The FreeType glyph rasterizer (body).                                *//*                                                                         *//*  Copyright 1996-2001, 2002, 2003 by                                     *//*  David Turner, Robert Wilhelm, and Werner Lemberg.                      *//*                                                                         *//*  This file is part of the FreeType project, and may only be used,       *//*  modified, and distributed under the terms of the FreeType project      *//*  license, ../../3rdparty/freetype/docs/FTL.TXT.  By continuing to use,  *//*  modify, or distribute this file you indicate that you have read        *//*  the license and understand and accept it fully.                        *//*                                                                         *//***************************************************************************//*************************************************************************//*                                                                       *//* This is a rewrite of the FreeType 1.x scan-line converter             *//*                                                                       *//*************************************************************************//* #define Q_RASTER_DEBUG */#include <qglobal.h>#include <stdlib.h>typedef int QT_FT_Error;typedef int QT_FT_Int;typedef unsigned int QT_FT_UInt;#if defined(Q_WS_WIN64)typedef signed __int64	 QT_FT_F26Dot6;typedef signed __int64   QT_FT_Long;typedef unsigned __int64 QT_FT_ULong;#elsetypedef signed long		 QT_FT_F26Dot6;typedef signed long      QT_FT_Long;typedef unsigned long    QT_FT_ULong;#endif#define QT_FT_Int64  qint64#define QT_FT_Byte uchar#define QT_FT_TRACE1 if (0) printf#define QT_FT_TRACE6 if (0) printf#define Raster_Err_Ok 0#define Raster_Err_Cannot_Render_Glyph 1#define QT_FT_LOCAL_DEF(x) static x#define QT_FT_BEGIN_HEADER#define QT_FT_END_HEADER#include <private/qrasterdefs_p.h>#include <private/qblackraster_p.h>static QT_FT_Long QT_FT_MulDiv(QT_FT_Long  a, QT_FT_Long  b, QT_FT_Long  c){    QT_FT_Int   s;    QT_FT_Long  d;    s = 1;    if ( a < 0 ) { a = -a; s = -1; }    if ( b < 0 ) { b = -b; s = -s; }    if ( c < 0 ) { c = -c; s = -s; }    d = (QT_FT_Long)( c > 0 ? ( (QT_FT_Int64)a * b + ( c >> 1 ) ) / c                   : 0x7FFFFFFFL );    return ( s > 0 ) ? d : -d;}#include <string.h>#define QT_FT_MEM_ZERO(x, len) memset(x, 0, len);#include <stdio.h>#define MAX(x, y) (x > y ? x : y)#define MIN(x, y) (x < y ? x : y)#define MAX_SPANS 256/*************************************************************************//*                                                                       *//* A simple technical note on how the raster works                       *//* -----------------------------------------------                       *//*                                                                       *//*   Converting an outline into a bitmap is achieved in several steps:   *//*                                                                       *//*   1 - Decomposing the outline into successive `profiles'.  Each       *//*       profile is simply an array of scanline intersections on a given *//*       dimension.  A profile's main attributes are                     *//*                                                                       *//*       o its scanline position boundaries, i.e. `Ymin' and `Ymax'.     *//*                                                                       *//*       o an array of intersection coordinates for each scanline        *//*         between `Ymin' and `Ymax'.                                    *//*                                                                       *//*       o a direction, indicating whether it was built going `up' or    *//*         `down', as this is very important for filling rules.          *//*                                                                       *//*   2 - Sweeping the target map's scanlines in order to compute segment *//*       `spans' which are then filled.  Additionally, this pass         *//*       performs drop-out control.                                      *//*                                                                       *//*   The outline data is parsed during step 1 only.  The profiles are    *//*   built from the bottom of the render pool, used as a stack.  The     *//*   following graphics shows the profile list under construction:       *//*                                                                       *//*     ____________________________________________________________ _ _  *//*    |         |                   |         |                 |        *//*    | profile | coordinates for   | profile | coordinates for |-->     *//*    |    1    |  profile 1        |    2    |  profile 2      |-->     *//*    |_________|___________________|_________|_________________|__ _ _  *//*                                                                       *//*    ^                                                         ^        *//*    |                                                         |        *//*  start of render pool                                       top       *//*                                                                       *//*   The top of the profile stack is kept in the `top' variable.         *//*                                                                       *//*   As you can see, a profile record is pushed on top of the render     *//*   pool, which is then followed by its coordinates/intersections.  If  *//*   a change of direction is detected in the outline, a new profile is  *//*   generated until the end of the outline.                             *//*                                                                       *//*   Note that when all profiles have been generated, the function       *//*   Finalize_Profile_Table() is used to record, for each profile, its   *//*   bottom-most scanline as well as the scanline above its upmost       *//*   boundary.  These positions are called `y-turns' because they (sort  *//*   of) correspond to local extrema.  They are stored in a sorted list  *//*   built from the top of the render pool as a downwards stack:         *//*                                                                       *//*      _ _ _______________________________________                      *//*                            |                    |                     *//*                         <--| sorted list of     |                     *//*                         <--|  extrema scanlines |                     *//*      _ _ __________________|____________________|                     *//*                                                                       *//*                            ^                    ^                     *//*                            |                    |                     *//*                         maxBuff           sizeBuff = end of pool      *//*                                                                       *//*   This list is later used during the sweep phase in order to          *//*   optimize performance (see technical note on the sweep below).       *//*                                                                       *//*   Of course, the raster detects whether the two stacks collide and    *//*   handles the situation propertly.                                    *//*                                                                       *//*************************************************************************//*************************************************************************//*************************************************************************//**                                                                     **//**  CONFIGURATION MACROS                                               **//**                                                                     **//*************************************************************************//*************************************************************************//* define DEBUG_RASTER if you want to compile a debugging version */#define xxxDEBUG_RASTER/* The default render pool size in bytes */#define RASTER_RENDER_POOL  8192/* The size of the two-lines intermediate bitmap used *//* for anti-aliasing, in bytes.                       */#define RASTER_GRAY_LINES  2048/*************************************************************************//*************************************************************************//**                                                                     **//**  OTHER MACROS (do not change)                                       **//**                                                                     **//*************************************************************************//*************************************************************************//*************************************************************************//*                                                                       *//* The macro QT_FT_COMPONENT is used in trace mode.  It is an implicit      *//* parameter of the QT_FT_TRACE() and QT_FT_ERROR() macros, used to print/log  *//* messages during execution.                                            *//*                                                                       */#undef  QT_FT_COMPONENT#define QT_FT_COMPONENT  trace_raster/* This macro is used to indicate that a function parameter is unused. *//* Its purpose is simply to reduce compiler warnings.  Note also that  *//* simply defining it as `(void)x' doesn't avoid warnings with certain *//* ANSI compilers (e.g. LCC).                                          */#define QT_FT_UNUSED( x )  (x) = (x)/* Disable the tracing mechanism for simplicity -- developers can      *//* activate it easily by redefining these two macros.                  */#ifndef QT_FT_ERROR#define QT_FT_ERROR( x )  do ; while ( 0 )     /* nothing */#endif#ifndef QT_FT_TRACE#define QT_FT_TRACE( x )  do ; while ( 0 )     /* nothing */#endif#define Raster_Err_None          0#define Raster_Err_Not_Ini      -1#define Raster_Err_Overflow     -2#define Raster_Err_Neg_Height   -3#define Raster_Err_Invalid      -4#define Raster_Err_Unsupported  -5#define Raster_Err_OutOfMemory  -6#ifndef QT_FT_MEM_SET#define QT_FT_MEM_SET( d, s, c )  qt_ft_memset( d, s, c )#endif/* FMulDiv means `Fast MulDiv'; it is used in case where `b' is       *//* typically a small value and the result of a*b is known to fit into *//* 32 bits.                                                           */#define FMulDiv( a, b, c )  ( (a) * (b) / (c) )/* On the other hand, SMulDiv means `Slow MulDiv', and is used typically *//* for clipping computations.  It simply uses the QT_FT_MulDiv() function   *//* defined in `ftcalc.h'.                                                */#define SMulDiv  QT_FT_MulDiv/* The rasterizer is a very general purpose component; please leave *//* the following redefinitions there (you never know your target    *//* environment).                                                    */#ifndef TRUE#define TRUE   1#endif#ifndef FALSE#define FALSE  0#endif#ifndef NULL#define NULL  (void*)0#endif#ifndef SUCCESS#define SUCCESS  0#endif#ifndef FAILURE#define FAILURE  1#endif#define MaxBezier  32   /* The maximum number of stacked Bezier curves. */                        /* Setting this constant to more than 32 is a   */                        /* pure waste of space.                         */#define Pixel_Bits  6   /* fractional bits of *input* coordinates *//*************************************************************************//*************************************************************************//**                                                                     **//**  SIMPLE TYPE DECLARATIONS                                           **//**                                                                     **//*************************************************************************//*************************************************************************/typedef int             Int;typedef unsigned int    UInt;typedef short           Short;typedef unsigned short  UShort, *PUShort;#if defined(Q_WS_WIN64)typedef __int64          Long, *PLong;typedef unsigned __int64 ULong;#elsetypedef long             Long, *PLong;typedef unsigned long    ULong;#endiftypedef unsigned char   Byte, *PByte;typedef char            Bool;typedef union  Alignment_{    long    l;    void*   p;    void  (*f)(void);} Alignment, *PAlignment;typedef struct  TPoint_{    Long  x;    Long  y;} TPoint;typedef enum  TFlow_{    Flow_None = 0,    Flow_Up   = 1,    Flow_Down = -1} TFlow;/* States of each line, arc, and profile */typedef enum  TStates_{    Unknown_State,    Ascending_State,    Descending_State,    Flat_State} TStates;typedef struct TProfile_  TProfile;typedef TProfile*         PProfile;struct  TProfile_{    QT_FT_F26Dot6  X;           /* current coordinate during sweep        */    PProfile    link;        /* link to next profile - various purpose */    PLong       offset;      /* start of profile's data in render pool */    int         flow;        /* Profile orientation: Asc/Descending    */    long        height;      /* profile's height in scanlines          */    long        start;       /* profile's starting scanline            */    unsigned    countL;      /* number of lines to step before this    */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -