1 2 3#ifdef HAVE_XORG_CONFIG_H 4#include <xorg-config.h> 5#endif 6 7#include "xaa.h" 8#include "xaalocal.h" 9#include "xaacexp.h" 10#include "xf86.h" 11 12/* Not used anymore because the algorithm isn't correct. It doesn't 13 handle overlapping characters properly */ 14 15#ifdef TRIPLE_BITS 16#define NonTEGlyphFunc EXPNAME(XAANonTEGlyphScanlineFunc3) 17#else 18#define NonTEGlyphFunc EXPNAME(XAANonTEGlyphScanlineFunc) 19#endif 20 21/******************************************************************** 22 23 Here we have NonTEGlyphRenders for a bunch of different color 24 expansion types. The driver may provide its own renderer, but 25 this is the default one which renders using lower-level primitives 26 exported by the chipset driver. 27 28********************************************************************/ 29 30/* Since the dimensions of the text string and the backing rectangle 31 do not always coincide, it is possible that wBack or wText 32 may be 0! The NonTEGlyphRender must always check for this. */ 33 34/* This gets built for MSBFIRST or LSBFIRST with FIXEDBASE or not, 35 with TRIPLE_BITS or not. A total of 8 versions */ 36 37/* if the backing rectangle and text are of the same dimensions 38 then we can draw in one pass */ 39 40void 41#ifdef TRIPLE_BITS 42EXPNAME(XAANonTEGlyphRenderer3)( 43#else 44EXPNAME(XAANonTEGlyphRenderer)( 45#endif 46 ScrnInfoPtr pScrn, 47 int xText, int wText, 48 int y, int h, int skipleft, int startline, 49 NonTEGlyphInfo *glyphp, 50 int fg, int rop, 51 unsigned int planemask ) 52{ 53 XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); 54 CARD32* base = (CARD32*)infoRec->ColorExpandBase; 55#ifdef TRIPLE_BITS 56 int dwords = ((3 * wText + 31) >> 5) * h; 57#else 58 int dwords = ((wText + 31) >> 5) * h; 59#endif 60 61 (*infoRec->SetupForCPUToScreenColorExpandFill)( 62 pScrn, fg, -1, rop, planemask); 63 (*infoRec->SubsequentCPUToScreenColorExpandFill)( 64 pScrn, xText, y, wText, h, 0); 65 66#ifndef FIXEDBASE 67#ifdef TRIPLE_BITS 68 if((((3 * wText + 31) >> 5) * h) <= infoRec->ColorExpandRange) 69#else 70 if((((wText + 31) >> 5) * h) <= infoRec->ColorExpandRange) 71#endif 72 while(h--) 73 base = NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft); 74 else 75#endif 76 while(h--) 77 NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft); 78 79 if((infoRec->CPUToScreenColorExpandFillFlags & CPU_TRANSFER_PAD_QWORD) && 80 (dwords & 1)) { 81 base = (CARD32*)infoRec->ColorExpandBase; 82 base[0] = 0x00000000; 83 } 84 85 if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND) 86 (*infoRec->Sync)(pScrn); 87 else SET_SYNC_FLAG(infoRec); 88} 89 90#ifndef FIXEDBASE 91/* Scanline version of above gets built for LSBFIRST and MSBFIRST */ 92 93void 94#ifdef TRIPLE_BITS 95EXPNAME(XAANonTEGlyphRendererScanline3)( 96#else 97EXPNAME(XAANonTEGlyphRendererScanline)( 98#endif 99 ScrnInfoPtr pScrn, 100 int xText, int wText, 101 int y, int h, int skipleft, int startline, 102 NonTEGlyphInfo *glyphp, 103 int fg, int rop, 104 unsigned int planemask ) 105{ 106 XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); 107 int bufferNo = 0; 108 CARD32* base; 109 110 (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)( 111 pScrn, fg, -1, rop, planemask); 112 (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)( 113 pScrn, xText, y, wText, h, 0); 114 115 while(h--) { 116 base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo]; 117 NonTEGlyphFunc(base, glyphp, startline++, wText, skipleft); 118 (*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++); 119 if(bufferNo >= infoRec->NumScanlineColorExpandBuffers) 120 bufferNo = 0; 121 } 122 123 SET_SYNC_FLAG(infoRec); 124} 125 126#endif 127 128/******************************************************************** 129 130 Generic NonTE scanline rendering code. 131 132********************************************************************/ 133 134 135CARD32* 136NonTEGlyphFunc( 137 CARD32 *base, 138 NonTEGlyphInfo *glyphp, 139 int line, int TotalWidth, int skipleft ) 140{ 141 CARD32 bits = 0; 142 int shift = glyphp->width; 143 144 if(skipleft) { 145 if((line >= glyphp->firstline) && (line <= glyphp->lastline)) 146 bits = SHIFT_R(glyphp->bitsp[line], skipleft); 147 shift -= skipleft; 148 } else if((line >= glyphp->firstline) && (line <= glyphp->lastline)) 149 bits = glyphp->bitsp[line]; 150 151 152 while(TotalWidth > 32) { 153 while(shift < 32) { 154 glyphp++; 155 if((line >= glyphp->firstline) && (line <= glyphp->lastline)) 156 bits |= SHIFT_L(glyphp->bitsp[line],shift); 157 shift += glyphp->width; 158 } 159#ifdef TRIPLE_BITS 160 WRITE_BITS3(bits); 161#else 162 WRITE_BITS(bits); 163#endif 164 shift &= 31; 165 if(shift && 166 (line >= glyphp->firstline) && (line <= glyphp->lastline)) 167 bits = SHIFT_R(glyphp->bitsp[line], glyphp->width - shift); 168 else bits = 0; 169 TotalWidth -= 32; 170 } 171 172 if(TotalWidth) { 173 TotalWidth -= shift; 174 while(TotalWidth > 0) { 175 glyphp++; 176 if((line >= glyphp->firstline) && (line <= glyphp->lastline)) 177 bits |= SHIFT_L(glyphp->bitsp[line], shift); 178 shift += glyphp->width; 179 TotalWidth -= glyphp->width; 180 } 181#ifdef TRIPLE_BITS 182 if (shift >= 22) { 183 WRITE_BITS3(bits); 184 } else if (shift >= 11) { 185 WRITE_BITS2(bits); 186 } else { 187 WRITE_BITS1(bits); 188 } 189#else 190 WRITE_BITS(bits); 191#endif 192 } 193 194 195 return base; 196} 197 198 199 200 201