code cleanups. begin work on using xshm

This commit is contained in:
pavlov%pavlov.net 1999-04-10 19:36:40 +00:00
Родитель f3ed4c1576
Коммит 95b8cdff6f
2 изменённых файлов: 102 добавлений и 68 удалений

Просмотреть файл

@ -17,6 +17,7 @@
*/
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gdk/gdkprivate.h>
#include "nsDrawingSurfaceGTK.h"
@ -155,7 +156,11 @@ NS_IMETHODIMP nsDrawingSurfaceGTK :: Lock(PRInt32 aX, PRInt32 aY,
*aBits = mImage->mem;
// int bytes_per_line = ((GdkImagePrivate*)mImage)->ximage->bytes_per_line;
#if 0
int bytes_per_line = ((GdkImagePrivate*)mImage)->ximage->bytes_per_line;
//
// All this code is a an attempt to set the stride width properly.
@ -167,45 +172,44 @@ NS_IMETHODIMP nsDrawingSurfaceGTK :: Lock(PRInt32 aX, PRInt32 aY,
*aWidthBytes = mImage->bpl;
*aStride = mImage->bpl;
// int width_in_pixels = *aWidthBytes << 8;
int width_in_pixels = *aWidthBytes << 8;
// int bitmap_pad = ((GdkImagePrivate*)mImage)->ximage->bitmap_pad;
// int depth = ((GdkImagePrivate*)mImage)->ximage->depth;
int bitmap_pad = ((GdkImagePrivate*)mImage)->ximage->bitmap_pad;
int depth = ((GdkImagePrivate*)mImage)->ximage->depth;
// #define RASWIDTH8(width, bpp) (width)
// #define RASWIDTH16(width, bpp) ((((width) * (bpp) + 15) >> 4) << 1)
// #define RASWIDTH32(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
#define RASWIDTH8(width, bpp) (width)
#define RASWIDTH16(width, bpp) ((((width) * (bpp) + 15) >> 4) << 1)
#define RASWIDTH32(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
// switch(bitmap_pad)
// {
// case 8:
// *aStride = RASWIDTH8(aWidth,bitmap_pad);
// break;
switch(bitmap_pad)
{
case 8:
*aStride = RASWIDTH8(aWidth,bitmap_pad);
break;
// case 16:
// // *aStride = bytes_per_line;
// *aStride = RASWIDTH16(aWidth,bitmap_pad);
// break;
case 16:
*aStride = bytes_per_line;
*aStride = RASWIDTH16(aWidth,bitmap_pad);
break;
// case 32:
// *aStride = bytes_per_line;
// // *aStride = RASWIDTH32(aWidth,bitmap_pad);
// break;
case 32:
*aStride = bytes_per_line;
*aStride = RASWIDTH32(aWidth,bitmap_pad);
break;
// default:
default:
// NS_ASSERTION(nsnull,"something got screwed");
// }
NS_ASSERTION(nsnull,"something got screwed");
}
// *aStride = (*aWidthBytes) + ((bitmap_pad >> 3) - 1);
*aStride = (*aWidthBytes) + ((bitmap_pad >> 3) - 1);
// ((GdkImagePrivate*)mImage)->ximage->bitmap_pad;
// *aWidthBytes = mImage->bpl;
((GdkImagePrivate*)mImage)->ximage->bitmap_pad;
*aWidthBytes = mImage->bpl;
#endif
return NS_OK;
}
@ -228,18 +232,31 @@ NS_IMETHODIMP nsDrawingSurfaceGTK :: Unlock(void)
mLockWidth, mLockHeight);
#endif
#if 0
gdk_gc_set_clip_origin(mGC, 0, 0);
gdk_gc_set_clip_mask(mGC, nsnull);
#if XSHM
if (gdk_get_use_xshm())
{
XShmPutImage(GDK_DISPLAY(),
GDK_WINDOW_XWINDOW(mPixmap),
GDK_GC_XGC(mGC),
GDK_IMAGE_XIMAGE(mImage),
0, 0,
mLockX, mLockY,
mLockWidth, mLockHeight,
False);
gdk_flush();
}
else
{
#endif
gdk_draw_image(mPixmap,
mGC,
mImage,
0, 0,
mLockX, mLockY,
mLockWidth, mLockHeight);
#ifdef XSHM
}
#endif
gdk_draw_image(mPixmap,
mGC,
mImage,
0, 0,
mLockX, mLockY,
mLockWidth, mLockHeight);
}
if (mImage)

Просмотреть файл

@ -417,7 +417,7 @@ NS_IMETHODIMP nsRenderingContextGTK::SetClipRect(const nsRect& aRect,
aClipEmpty = mClipRegion->IsEmpty();
mClipRegion->GetNativeRegion((void*&)rgn);
gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
::gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
return NS_OK;
}
@ -446,7 +446,7 @@ NS_IMETHODIMP nsRenderingContextGTK::SetClipRegion(const nsIRegion& aRegion,
aClipEmpty = mClipRegion->IsEmpty();
mClipRegion->GetNativeRegion((void*&)rgn);
gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
::gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
return NS_OK;
}
@ -519,8 +519,8 @@ NS_IMETHODIMP nsRenderingContextGTK::SetFont(nsIFontMetrics *aFontMetrics)
mFontMetrics->GetFontHandle(fontHandle);
mCurrentFont = (GdkFont *)fontHandle;
gdk_gc_set_font(mSurface->GetGC(),
mCurrentFont);
::gdk_gc_set_font(mSurface->GetGC(),
mCurrentFont);
}
return NS_OK;
@ -533,25 +533,34 @@ NS_IMETHODIMP nsRenderingContextGTK::SetLineStyle(nsLineStyle aLineStyle)
switch(aLineStyle)
{
case nsLineStyle_kSolid:
::gdk_gc_set_line_attributes(mSurface->GetGC(),
1, GDK_LINE_SOLID, (GdkCapStyle)0, (GdkJoinStyle)0);
{
::gdk_gc_set_line_attributes(mSurface->GetGC(),
1,
GDK_LINE_SOLID,
(GdkCapStyle)0,
(GdkJoinStyle)0);
}
break;
case nsLineStyle_kDashed: {
static char dashed[2] = {4,4};
case nsLineStyle_kDashed:
{
static char dashed[2] = {4,4};
::gdk_gc_set_dashes(mSurface->GetGC(),
0, dashed, 2);
} break;
::gdk_gc_set_dashes(mSurface->GetGC(),
0, dashed, 2);
}
break;
case nsLineStyle_kDotted: {
static char dotted[2] = {3,1};
case nsLineStyle_kDotted:
{
static char dotted[2] = {3,1};
::gdk_gc_set_dashes(mSurface->GetGC(),
0, dotted, 2);
}break;
::gdk_gc_set_dashes(mSurface->GetGC(),
0, dotted, 2);
}
break;
default:
default:
break;
}
@ -646,6 +655,7 @@ NS_IMETHODIMP nsRenderingContextGTK::DrawLine(nscoord aX0, nscoord aY0, nscoord
if (aX0 != aX1) {
aX1--;
}
::gdk_draw_line(mSurface->GetDrawable(),
mSurface->GetGC(),
aX0, aY0, aX1, aY1);
@ -703,7 +713,9 @@ NS_IMETHODIMP nsRenderingContextGTK::DrawRect(nscoord aX, nscoord aY, nscoord aW
::gdk_draw_rectangle(mSurface->GetDrawable(), mSurface->GetGC(),
FALSE,
x, y, w - 1, h - 1);
x, y,
w - 1,
h - 1);
return NS_OK;
}
@ -728,8 +740,6 @@ NS_IMETHODIMP nsRenderingContextGTK::FillRect(nscoord aX, nscoord aY, nscoord aW
mTMatrix->TransformCoord(&x,&y,&w,&h);
// gdk_gc_set_clip_region(mSurface->GetGC(), nsnull);
::gdk_draw_rectangle(mSurface->GetDrawable(), mSurface->GetGC(),
TRUE,
x, y, w, h);
@ -890,6 +900,9 @@ NS_IMETHODIMP nsRenderingContextGTK::FillArc(nscoord aX, nscoord aY,
return NS_OK;
}
#ifdef FONT_SWITCHING
NS_IMETHODIMP
@ -1376,8 +1389,8 @@ nsRenderingContextGTK::CopyOffScreenBits(nsDrawingSurface aSrcSurf,
const nsRect &aDestBounds,
PRUint32 aCopyFlags)
{
PRInt32 x = aSrcX;
PRInt32 y = aSrcY;
PRInt32 srcX = aSrcX;
PRInt32 srcY = aSrcY;
nsRect drect = aDestBounds;
nsDrawingSurfaceGTK *destsurf;
@ -1412,7 +1425,7 @@ nsRenderingContextGTK::CopyOffScreenBits(nsDrawingSurface aSrcSurf,
destsurf = mOffscreenSurface;
if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES)
mTMatrix->TransformCoord(&x, &y);
mTMatrix->TransformCoord(&srcX, &srcY);
if (aCopyFlags & NS_COPYBITS_XFORM_DEST_VALUES)
mTMatrix->TransformCoord(&drect.x, &drect.y, &drect.width, &drect.height);
@ -1420,12 +1433,16 @@ nsRenderingContextGTK::CopyOffScreenBits(nsDrawingSurface aSrcSurf,
//XXX flags are unused. that would seem to mean that there is
//inefficiency somewhere... MMP
::gdk_draw_pixmap(destsurf->GetDrawable(),
((nsDrawingSurfaceGTK *)aSrcSurf)->GetGC(),
((nsDrawingSurfaceGTK *)aSrcSurf)->GetDrawable(),
x, y,
drect.x, drect.y,
drect.width, drect.height);
// gdk_draw_pixmap and copy_area do the same thing internally.
// copy_area sounds better
::gdk_window_copy_area(destsurf->GetDrawable(),
((nsDrawingSurfaceGTK *)aSrcSurf)->GetGC(),
drect.x, drect.y,
((nsDrawingSurfaceGTK *)aSrcSurf)->GetDrawable(),
srcX, srcY,
drect.width, drect.height);
return NS_OK;
}