From 9ca97fe70eea968df02a497b51e54a19a66ad35f Mon Sep 17 00:00:00 2001 From: "dcone%netscape.com" Date: Tue, 4 Apr 2000 13:38:36 +0000 Subject: [PATCH] Took out the code to do the Tiling.. a method in nsRenderingContext will now do this. This gives each platform the option of tiling.. and optimizing for speed. Windows will now be very fast for small tiles that are transparent. git-svn-id: svn://10.0.0.236/trunk@65189 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSRendering.cpp | 147 +++--------------- .../layout/html/style/src/nsCSSRendering.cpp | 147 +++--------------- 2 files changed, 44 insertions(+), 250 deletions(-) diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index 434fb793be6..0f3456850f1 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -39,6 +39,7 @@ #include "nsIContent.h" #include "nsHTMLAtoms.h" #include "nsIDocument.h" +#include "nsCOMPtr.h" static NS_DEFINE_IID(kScrollViewIID, NS_ISCROLLABLEVIEW_IID); @@ -2278,108 +2279,7 @@ PRInt16 borderRadii[4],i; } } -#define DOTILE -#ifdef DOTILE - nsIDrawingSurface *theSurface,*ts=nsnull; - nsRect srcRect,destRect,vrect,tvrect; - nscoord x,y; - PRInt32 flag = NS_COPYBITS_TO_BACK_BUFFER | NS_COPYBITS_XFORM_DEST_VALUES; - PRUint32 dsFlag = 0; - float t2p,app2dev; - PRBool clip,hasMask; - nsTransform2D *theTransform; - nsIDeviceContext *theDevContext; - - - aRenderingContext.GetDrawingSurface((void**)&theSurface); - aPresContext->GetVisibleArea(srcRect); - tvrect.SetRect(0,0,x1-x0,y1-y0); - aPresContext->GetTwipsToPixels(&t2p); - - // check to see if the background image has a mask - hasMask = image->GetHasAlphaMask(); - - if(!hasMask && ((tileWidth<(tvrect.width/16)) || (tileHeight<(tvrect.height/16)))) { - //tvrect.width /=4; - //tvrect.height /=4; - - tvrect.width = ((tvrect.width)/tileWidth); //total x number of tiles - tvrect.width *=tileWidth; - - tvrect.height = ((tvrect.height)/tileHeight); //total y number of tiles - tvrect.height *=tileHeight; - - // create a new drawing surface... using pixels as the size - vrect.height = (nscoord)(tvrect.height * t2p); - vrect.width = (nscoord)(tvrect.width * t2p); - aRenderingContext.CreateDrawingSurface(&vrect,dsFlag,(nsDrawingSurface&)ts); - } - - // did we need to create an offscreen drawing surface because the image was so small - if(!hasMask && (nsnull != ts) ) { - aRenderingContext.SelectOffScreenDrawingSurface(ts); - - // create a bigger tile in our new drawingsurface - // XXX pushing state to fix clipping problem, need to look into why the clip is set here - aRenderingContext.PushState(); - aRenderingContext.GetCurrentTransform(theTransform); - aRenderingContext.GetDeviceContext(theDevContext); - theDevContext->GetAppUnitsToDevUnits(app2dev); - NS_RELEASE(theDevContext); - theTransform->SetToIdentity(); - theTransform->AddScale(app2dev, app2dev); - - // XXX this #ifdef needs to go away when we are sure that this works on windows and mac -#ifdef XP_UNIX - srcRect.SetRect(0,0,tvrect.width,tvrect.height); - aRenderingContext.SetClipRect(srcRect, nsClipCombine_kReplace, clip); -#endif - - // copy the initial image to our buffer, this takes twips and converts to pixels.. - // which is what the image is in - aRenderingContext.DrawImage(image,0,0,tileWidth,tileHeight); - - // duplicate the image in the upperleft corner to fill up the nsDrawingSurface - srcRect.SetRect(0,0,tileWidth,tileHeight); - TileImage(aRenderingContext,ts,srcRect,tvrect.width,tvrect.height); - - // setting back the clip from the background clip push - aRenderingContext.PopState(clip); - - // set back to the old drawingsurface - aRenderingContext.SelectOffScreenDrawingSurface((void**)theSurface); - - // now duplicate our tile into the background - destRect = srcRect; - for(y=y0;yGetVisibleArea(srcRect); - tvrect.SetRect(0,0,x1-x0,y1-y0); - aPresContext->GetTwipsToPixels(&t2p); - - // check to see if the background image has a mask - hasMask = image->GetHasAlphaMask(); - - if(!hasMask && ((tileWidth<(tvrect.width/16)) || (tileHeight<(tvrect.height/16)))) { - //tvrect.width /=4; - //tvrect.height /=4; - - tvrect.width = ((tvrect.width)/tileWidth); //total x number of tiles - tvrect.width *=tileWidth; - - tvrect.height = ((tvrect.height)/tileHeight); //total y number of tiles - tvrect.height *=tileHeight; - - // create a new drawing surface... using pixels as the size - vrect.height = (nscoord)(tvrect.height * t2p); - vrect.width = (nscoord)(tvrect.width * t2p); - aRenderingContext.CreateDrawingSurface(&vrect,dsFlag,(nsDrawingSurface&)ts); - } - - // did we need to create an offscreen drawing surface because the image was so small - if(!hasMask && (nsnull != ts) ) { - aRenderingContext.SelectOffScreenDrawingSurface(ts); - - // create a bigger tile in our new drawingsurface - // XXX pushing state to fix clipping problem, need to look into why the clip is set here - aRenderingContext.PushState(); - aRenderingContext.GetCurrentTransform(theTransform); - aRenderingContext.GetDeviceContext(theDevContext); - theDevContext->GetAppUnitsToDevUnits(app2dev); - NS_RELEASE(theDevContext); - theTransform->SetToIdentity(); - theTransform->AddScale(app2dev, app2dev); - - // XXX this #ifdef needs to go away when we are sure that this works on windows and mac -#ifdef XP_UNIX - srcRect.SetRect(0,0,tvrect.width,tvrect.height); - aRenderingContext.SetClipRect(srcRect, nsClipCombine_kReplace, clip); -#endif - - // copy the initial image to our buffer, this takes twips and converts to pixels.. - // which is what the image is in - aRenderingContext.DrawImage(image,0,0,tileWidth,tileHeight); - - // duplicate the image in the upperleft corner to fill up the nsDrawingSurface - srcRect.SetRect(0,0,tileWidth,tileHeight); - TileImage(aRenderingContext,ts,srcRect,tvrect.width,tvrect.height); - - // setting back the clip from the background clip push - aRenderingContext.PopState(clip); - - // set back to the old drawingsurface - aRenderingContext.SelectOffScreenDrawingSurface((void**)theSurface); - - // now duplicate our tile into the background - destRect = srcRect; - for(y=y0;y