Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenstretchblt.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Win32k subsystem 00003 * LICENSE: See COPYING in the top level directory 00004 * FILE: subsystems/win32/win32k/dib/stretchblt.c 00005 * PURPOSE: StretchBlt implementation suitable for all bit depths 00006 * PROGRAMMERS: Magnus Olsen 00007 * Evgeniy Boltik 00008 * Gregor Schneider 00009 */ 00010 00011 #include <win32k.h> 00012 00013 #define NDEBUG 00014 #include <debug.h> 00015 00016 BOOLEAN DIB_XXBPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, SURFOBJ *MaskSurf, 00017 SURFOBJ *PatternSurface, 00018 RECTL *DestRect, RECTL *SourceRect, 00019 POINTL *MaskOrigin, BRUSHOBJ *Brush, 00020 POINTL *BrushOrigin, XLATEOBJ *ColorTranslation, 00021 ROP4 ROP) 00022 { 00023 LONG sx = 0; 00024 LONG sy = 0; 00025 LONG DesX; 00026 LONG DesY; 00027 00028 LONG DstHeight; 00029 LONG DstWidth; 00030 LONG SrcHeight; 00031 LONG SrcWidth; 00032 00033 ULONG Color; 00034 ULONG Dest, Source = 0, Pattern = 0; 00035 ULONG xxBPPMask; 00036 BOOLEAN CanDraw; 00037 00038 PFN_DIB_GetPixel fnSource_GetPixel = NULL; 00039 PFN_DIB_GetPixel fnDest_GetPixel = NULL; 00040 PFN_DIB_PutPixel fnDest_PutPixel = NULL; 00041 PFN_DIB_GetPixel fnPattern_GetPixel = NULL; 00042 PFN_DIB_GetPixel fnMask_GetPixel = NULL; 00043 00044 LONG PatternX = 0, PatternY = 0; 00045 00046 BOOL UsesSource = ROP4_USES_SOURCE(ROP); 00047 BOOL UsesPattern = ROP4_USES_PATTERN(ROP); 00048 00049 ASSERT(IS_VALID_ROP4(ROP)); 00050 00051 fnDest_GetPixel = DibFunctionsForBitmapFormat[DestSurf->iBitmapFormat].DIB_GetPixel; 00052 fnDest_PutPixel = DibFunctionsForBitmapFormat[DestSurf->iBitmapFormat].DIB_PutPixel; 00053 00054 DPRINT("Dest BPP: %u, dstRect: (%d,%d)-(%d,%d)\n", 00055 BitsPerFormat(DestSurf->iBitmapFormat), DestRect->left, DestRect->top, DestRect->right, DestRect->bottom); 00056 00057 if (UsesSource) 00058 { 00059 fnSource_GetPixel = DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat].DIB_GetPixel; 00060 DPRINT("Source BPP: %u, srcRect: (%d,%d)-(%d,%d)\n", 00061 BitsPerFormat(SourceSurf->iBitmapFormat), SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom); 00062 } 00063 00064 if (MaskSurf) 00065 { 00066 fnMask_GetPixel = DibFunctionsForBitmapFormat[MaskSurf->iBitmapFormat].DIB_GetPixel; 00067 } 00068 00069 DstHeight = DestRect->bottom - DestRect->top; 00070 DstWidth = DestRect->right - DestRect->left; 00071 SrcHeight = SourceRect->bottom - SourceRect->top; 00072 SrcWidth = SourceRect->right - SourceRect->left; 00073 00074 /* FIXME: MaskOrigin? */ 00075 00076 switch(DestSurf->iBitmapFormat) 00077 { 00078 case BMF_1BPP: xxBPPMask = 0x1; break; 00079 case BMF_4BPP: xxBPPMask = 0xF; break; 00080 case BMF_8BPP: xxBPPMask = 0xFF; break; 00081 case BMF_16BPP: xxBPPMask = 0xFFFF; break; 00082 case BMF_24BPP: xxBPPMask = 0xFFFFFF; break; 00083 default: 00084 xxBPPMask = 0xFFFFFFFF; 00085 } 00086 00087 if (UsesPattern) 00088 { 00089 if (PatternSurface) 00090 { 00091 PatternY = (DestRect->top - BrushOrigin->y) % PatternSurface->sizlBitmap.cy; 00092 if (PatternY < 0) 00093 { 00094 PatternY += PatternSurface->sizlBitmap.cy; 00095 } 00096 fnPattern_GetPixel = DibFunctionsForBitmapFormat[PatternSurface->iBitmapFormat].DIB_GetPixel; 00097 } 00098 else 00099 { 00100 if (Brush) 00101 Pattern = Brush->iSolidColor; 00102 } 00103 } 00104 00105 00106 for (DesY = DestRect->top; DesY < DestRect->bottom; DesY++) 00107 { 00108 if (PatternSurface) 00109 { 00110 PatternX = (DestRect->left - BrushOrigin->x) % PatternSurface->sizlBitmap.cx; 00111 if (PatternX < 0) 00112 { 00113 PatternX += PatternSurface->sizlBitmap.cx; 00114 } 00115 } 00116 if (UsesSource) 00117 sy = SourceRect->top+(DesY - DestRect->top) * SrcHeight / DstHeight; 00118 00119 for (DesX = DestRect->left; DesX < DestRect->right; DesX++) 00120 { 00121 CanDraw = TRUE; 00122 00123 if (fnMask_GetPixel) 00124 { 00125 sx = SourceRect->left+(DesX - DestRect->left) * SrcWidth / DstWidth; 00126 if (sx < 0 || sy < 0 || 00127 MaskSurf->sizlBitmap.cx < sx || MaskSurf->sizlBitmap.cy < sy || 00128 fnMask_GetPixel(MaskSurf, sx, sy) != 0) 00129 { 00130 CanDraw = FALSE; 00131 } 00132 } 00133 00134 if (UsesSource && CanDraw) 00135 { 00136 sx = SourceRect->left+(DesX - DestRect->left) * SrcWidth / DstWidth; 00137 if (sx >= 0 && sy >= 0 && 00138 SourceSurf->sizlBitmap.cx > sx && SourceSurf->sizlBitmap.cy > sy) 00139 { 00140 Source = XLATEOBJ_iXlate(ColorTranslation, fnSource_GetPixel(SourceSurf, sx, sy)); 00141 } 00142 else 00143 { 00144 Source = 0; 00145 CanDraw = ((ROP & 0xFF) != R3_OPINDEX_SRCCOPY); 00146 } 00147 } 00148 00149 if (CanDraw) 00150 { 00151 if (UsesPattern && PatternSurface) 00152 { 00153 Pattern = fnPattern_GetPixel(PatternSurface, PatternX, PatternY); 00154 PatternX++; 00155 PatternX %= PatternSurface->sizlBitmap.cx; 00156 } 00157 00158 Dest = fnDest_GetPixel(DestSurf, DesX, DesY); 00159 Color = DIB_DoRop(ROP, Dest, Source, Pattern) & xxBPPMask; 00160 00161 fnDest_PutPixel(DestSurf, DesX, DesY, Color); 00162 } 00163 } 00164 00165 if (PatternSurface) 00166 { 00167 PatternY++; 00168 PatternY %= PatternSurface->sizlBitmap.cy; 00169 } 00170 } 00171 00172 return TRUE; 00173 } 00174 00175 /* EOF */ Generated on Sun May 27 2012 04:38:16 for ReactOS by
1.7.6.1
|