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
This commit is contained in:
parent
4f40fe126c
commit
9ca97fe70e
@ -39,6 +39,7 @@
|
|||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsHTMLAtoms.h"
|
#include "nsHTMLAtoms.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
|
||||||
static NS_DEFINE_IID(kScrollViewIID, NS_ISCROLLABLEVIEW_IID);
|
static NS_DEFINE_IID(kScrollViewIID, NS_ISCROLLABLEVIEW_IID);
|
||||||
|
|
||||||
@ -2278,108 +2279,7 @@ PRInt16 borderRadii[4],i;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DOTILE
|
aRenderingContext.DrawTile(image,x0,y0,x1,y1,tileWidth,tileHeight);
|
||||||
#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;y<y1;y+=tvrect.height){
|
|
||||||
for(x=x0;x<x1;x+=tvrect.width){
|
|
||||||
destRect.x = x;
|
|
||||||
destRect.y = y;
|
|
||||||
aRenderingContext.CopyOffScreenBits(ts,0,0,destRect,flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
aRenderingContext.DestroyDrawingSurface(ts);
|
|
||||||
} else {
|
|
||||||
// slow blitting, one tile at a time....
|
|
||||||
for(y=y0;y<y1;y+=tileHeight){
|
|
||||||
for(x=x0;x<x1;x+=tileWidth){
|
|
||||||
aRenderingContext.DrawImage(image,x,y,tileWidth,tileHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define NOTNOW
|
|
||||||
#ifdef NOTNOW
|
|
||||||
nscoord x,y;
|
|
||||||
for(y=y0;y<y1;y+=tileHeight){
|
|
||||||
for(x=x0;x<x1;x+=tileWidth){
|
|
||||||
aRenderingContext.DrawImage(image,x,y,tileWidth,tileHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Restore clipping
|
// Restore clipping
|
||||||
aRenderingContext.PopState(clipState);
|
aRenderingContext.PopState(clipState);
|
||||||
@ -2388,8 +2288,6 @@ PRInt16 borderRadii[4],i;
|
|||||||
// See if there's a background color specified. The background color
|
// See if there's a background color specified. The background color
|
||||||
// is rendered over the 'border' 'padding' and 'content' areas
|
// is rendered over the 'border' 'padding' and 'content' areas
|
||||||
if (!transparentBG) {
|
if (!transparentBG) {
|
||||||
|
|
||||||
|
|
||||||
// get the radius for our border
|
// get the radius for our border
|
||||||
aSpacing.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
aSpacing.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
||||||
aSpacing.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
aSpacing.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
||||||
@ -2413,7 +2311,6 @@ PRInt16 borderRadii[4],i;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// rounded version of the border
|
// rounded version of the border
|
||||||
for(i=0;i<4;i++){
|
for(i=0;i<4;i++){
|
||||||
if (borderRadii[i] > 0){
|
if (borderRadii[i] > 0){
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
#include "nsHTMLAtoms.h"
|
#include "nsHTMLAtoms.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
|
#include "nsCOMPtr.h"
|
||||||
|
|
||||||
static NS_DEFINE_IID(kScrollViewIID, NS_ISCROLLABLEVIEW_IID);
|
static NS_DEFINE_IID(kScrollViewIID, NS_ISCROLLABLEVIEW_IID);
|
||||||
|
|
||||||
@ -2278,108 +2279,7 @@ PRInt16 borderRadii[4],i;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DOTILE
|
aRenderingContext.DrawTile(image,x0,y0,x1,y1,tileWidth,tileHeight);
|
||||||
#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;y<y1;y+=tvrect.height){
|
|
||||||
for(x=x0;x<x1;x+=tvrect.width){
|
|
||||||
destRect.x = x;
|
|
||||||
destRect.y = y;
|
|
||||||
aRenderingContext.CopyOffScreenBits(ts,0,0,destRect,flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
aRenderingContext.DestroyDrawingSurface(ts);
|
|
||||||
} else {
|
|
||||||
// slow blitting, one tile at a time....
|
|
||||||
for(y=y0;y<y1;y+=tileHeight){
|
|
||||||
for(x=x0;x<x1;x+=tileWidth){
|
|
||||||
aRenderingContext.DrawImage(image,x,y,tileWidth,tileHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define NOTNOW
|
|
||||||
#ifdef NOTNOW
|
|
||||||
nscoord x,y;
|
|
||||||
for(y=y0;y<y1;y+=tileHeight){
|
|
||||||
for(x=x0;x<x1;x+=tileWidth){
|
|
||||||
aRenderingContext.DrawImage(image,x,y,tileWidth,tileHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Restore clipping
|
// Restore clipping
|
||||||
aRenderingContext.PopState(clipState);
|
aRenderingContext.PopState(clipState);
|
||||||
@ -2388,8 +2288,6 @@ PRInt16 borderRadii[4],i;
|
|||||||
// See if there's a background color specified. The background color
|
// See if there's a background color specified. The background color
|
||||||
// is rendered over the 'border' 'padding' and 'content' areas
|
// is rendered over the 'border' 'padding' and 'content' areas
|
||||||
if (!transparentBG) {
|
if (!transparentBG) {
|
||||||
|
|
||||||
|
|
||||||
// get the radius for our border
|
// get the radius for our border
|
||||||
aSpacing.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
aSpacing.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
||||||
aSpacing.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
aSpacing.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
||||||
@ -2413,7 +2311,6 @@ PRInt16 borderRadii[4],i;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// rounded version of the border
|
// rounded version of the border
|
||||||
for(i=0;i<4;i++){
|
for(i=0;i<4;i++){
|
||||||
if (borderRadii[i] > 0){
|
if (borderRadii[i] > 0){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user