зеркало из https://github.com/mozilla/gecko-dev.git
code cleanups. begin work on using xshm
This commit is contained in:
Родитель
f3ed4c1576
Коммит
95b8cdff6f
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
#include <gdk/gdkprivate.h>
|
#include <gdk/gdkprivate.h>
|
||||||
#include "nsDrawingSurfaceGTK.h"
|
#include "nsDrawingSurfaceGTK.h"
|
||||||
|
|
||||||
|
@ -155,7 +156,11 @@ NS_IMETHODIMP nsDrawingSurfaceGTK :: Lock(PRInt32 aX, PRInt32 aY,
|
||||||
*aBits = mImage->mem;
|
*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.
|
// 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;
|
*aWidthBytes = mImage->bpl;
|
||||||
*aStride = 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 bitmap_pad = ((GdkImagePrivate*)mImage)->ximage->bitmap_pad;
|
||||||
// int depth = ((GdkImagePrivate*)mImage)->ximage->depth;
|
int depth = ((GdkImagePrivate*)mImage)->ximage->depth;
|
||||||
|
|
||||||
// #define RASWIDTH8(width, bpp) (width)
|
#define RASWIDTH8(width, bpp) (width)
|
||||||
// #define RASWIDTH16(width, bpp) ((((width) * (bpp) + 15) >> 4) << 1)
|
#define RASWIDTH16(width, bpp) ((((width) * (bpp) + 15) >> 4) << 1)
|
||||||
// #define RASWIDTH32(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
|
#define RASWIDTH32(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
|
||||||
|
|
||||||
// switch(bitmap_pad)
|
switch(bitmap_pad)
|
||||||
// {
|
{
|
||||||
// case 8:
|
case 8:
|
||||||
// *aStride = RASWIDTH8(aWidth,bitmap_pad);
|
*aStride = RASWIDTH8(aWidth,bitmap_pad);
|
||||||
// break;
|
break;
|
||||||
|
|
||||||
// case 16:
|
case 16:
|
||||||
// // *aStride = bytes_per_line;
|
*aStride = bytes_per_line;
|
||||||
// *aStride = RASWIDTH16(aWidth,bitmap_pad);
|
*aStride = RASWIDTH16(aWidth,bitmap_pad);
|
||||||
// break;
|
break;
|
||||||
|
|
||||||
// case 32:
|
case 32:
|
||||||
// *aStride = bytes_per_line;
|
*aStride = bytes_per_line;
|
||||||
// // *aStride = RASWIDTH32(aWidth,bitmap_pad);
|
*aStride = RASWIDTH32(aWidth,bitmap_pad);
|
||||||
// break;
|
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;
|
((GdkImagePrivate*)mImage)->ximage->bitmap_pad;
|
||||||
|
|
||||||
// *aWidthBytes = mImage->bpl;
|
|
||||||
|
|
||||||
|
*aWidthBytes = mImage->bpl;
|
||||||
|
#endif
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,18 +232,31 @@ NS_IMETHODIMP nsDrawingSurfaceGTK :: Unlock(void)
|
||||||
mLockWidth, mLockHeight);
|
mLockWidth, mLockHeight);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if XSHM
|
||||||
gdk_gc_set_clip_origin(mGC, 0, 0);
|
if (gdk_get_use_xshm())
|
||||||
gdk_gc_set_clip_mask(mGC, nsnull);
|
{
|
||||||
|
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
|
#endif
|
||||||
|
|
||||||
gdk_draw_image(mPixmap,
|
|
||||||
mGC,
|
|
||||||
mImage,
|
|
||||||
0, 0,
|
|
||||||
mLockX, mLockY,
|
|
||||||
mLockWidth, mLockHeight);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mImage)
|
if (mImage)
|
||||||
|
|
|
@ -417,7 +417,7 @@ NS_IMETHODIMP nsRenderingContextGTK::SetClipRect(const nsRect& aRect,
|
||||||
aClipEmpty = mClipRegion->IsEmpty();
|
aClipEmpty = mClipRegion->IsEmpty();
|
||||||
|
|
||||||
mClipRegion->GetNativeRegion((void*&)rgn);
|
mClipRegion->GetNativeRegion((void*&)rgn);
|
||||||
gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
|
::gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -446,7 +446,7 @@ NS_IMETHODIMP nsRenderingContextGTK::SetClipRegion(const nsIRegion& aRegion,
|
||||||
|
|
||||||
aClipEmpty = mClipRegion->IsEmpty();
|
aClipEmpty = mClipRegion->IsEmpty();
|
||||||
mClipRegion->GetNativeRegion((void*&)rgn);
|
mClipRegion->GetNativeRegion((void*&)rgn);
|
||||||
gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
|
::gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -519,8 +519,8 @@ NS_IMETHODIMP nsRenderingContextGTK::SetFont(nsIFontMetrics *aFontMetrics)
|
||||||
mFontMetrics->GetFontHandle(fontHandle);
|
mFontMetrics->GetFontHandle(fontHandle);
|
||||||
mCurrentFont = (GdkFont *)fontHandle;
|
mCurrentFont = (GdkFont *)fontHandle;
|
||||||
|
|
||||||
gdk_gc_set_font(mSurface->GetGC(),
|
::gdk_gc_set_font(mSurface->GetGC(),
|
||||||
mCurrentFont);
|
mCurrentFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -533,25 +533,34 @@ NS_IMETHODIMP nsRenderingContextGTK::SetLineStyle(nsLineStyle aLineStyle)
|
||||||
switch(aLineStyle)
|
switch(aLineStyle)
|
||||||
{
|
{
|
||||||
case nsLineStyle_kSolid:
|
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;
|
break;
|
||||||
|
|
||||||
case nsLineStyle_kDashed: {
|
case nsLineStyle_kDashed:
|
||||||
static char dashed[2] = {4,4};
|
{
|
||||||
|
static char dashed[2] = {4,4};
|
||||||
|
|
||||||
::gdk_gc_set_dashes(mSurface->GetGC(),
|
::gdk_gc_set_dashes(mSurface->GetGC(),
|
||||||
0, dashed, 2);
|
0, dashed, 2);
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case nsLineStyle_kDotted: {
|
case nsLineStyle_kDotted:
|
||||||
static char dotted[2] = {3,1};
|
{
|
||||||
|
static char dotted[2] = {3,1};
|
||||||
|
|
||||||
::gdk_gc_set_dashes(mSurface->GetGC(),
|
::gdk_gc_set_dashes(mSurface->GetGC(),
|
||||||
0, dotted, 2);
|
0, dotted, 2);
|
||||||
}break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -646,6 +655,7 @@ NS_IMETHODIMP nsRenderingContextGTK::DrawLine(nscoord aX0, nscoord aY0, nscoord
|
||||||
if (aX0 != aX1) {
|
if (aX0 != aX1) {
|
||||||
aX1--;
|
aX1--;
|
||||||
}
|
}
|
||||||
|
|
||||||
::gdk_draw_line(mSurface->GetDrawable(),
|
::gdk_draw_line(mSurface->GetDrawable(),
|
||||||
mSurface->GetGC(),
|
mSurface->GetGC(),
|
||||||
aX0, aY0, aX1, aY1);
|
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(),
|
::gdk_draw_rectangle(mSurface->GetDrawable(), mSurface->GetGC(),
|
||||||
FALSE,
|
FALSE,
|
||||||
x, y, w - 1, h - 1);
|
x, y,
|
||||||
|
w - 1,
|
||||||
|
h - 1);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -728,8 +740,6 @@ NS_IMETHODIMP nsRenderingContextGTK::FillRect(nscoord aX, nscoord aY, nscoord aW
|
||||||
|
|
||||||
mTMatrix->TransformCoord(&x,&y,&w,&h);
|
mTMatrix->TransformCoord(&x,&y,&w,&h);
|
||||||
|
|
||||||
// gdk_gc_set_clip_region(mSurface->GetGC(), nsnull);
|
|
||||||
|
|
||||||
::gdk_draw_rectangle(mSurface->GetDrawable(), mSurface->GetGC(),
|
::gdk_draw_rectangle(mSurface->GetDrawable(), mSurface->GetGC(),
|
||||||
TRUE,
|
TRUE,
|
||||||
x, y, w, h);
|
x, y, w, h);
|
||||||
|
@ -890,6 +900,9 @@ NS_IMETHODIMP nsRenderingContextGTK::FillArc(nscoord aX, nscoord aY,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef FONT_SWITCHING
|
#ifdef FONT_SWITCHING
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -1376,8 +1389,8 @@ nsRenderingContextGTK::CopyOffScreenBits(nsDrawingSurface aSrcSurf,
|
||||||
const nsRect &aDestBounds,
|
const nsRect &aDestBounds,
|
||||||
PRUint32 aCopyFlags)
|
PRUint32 aCopyFlags)
|
||||||
{
|
{
|
||||||
PRInt32 x = aSrcX;
|
PRInt32 srcX = aSrcX;
|
||||||
PRInt32 y = aSrcY;
|
PRInt32 srcY = aSrcY;
|
||||||
nsRect drect = aDestBounds;
|
nsRect drect = aDestBounds;
|
||||||
nsDrawingSurfaceGTK *destsurf;
|
nsDrawingSurfaceGTK *destsurf;
|
||||||
|
|
||||||
|
@ -1412,7 +1425,7 @@ nsRenderingContextGTK::CopyOffScreenBits(nsDrawingSurface aSrcSurf,
|
||||||
destsurf = mOffscreenSurface;
|
destsurf = mOffscreenSurface;
|
||||||
|
|
||||||
if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES)
|
if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES)
|
||||||
mTMatrix->TransformCoord(&x, &y);
|
mTMatrix->TransformCoord(&srcX, &srcY);
|
||||||
|
|
||||||
if (aCopyFlags & NS_COPYBITS_XFORM_DEST_VALUES)
|
if (aCopyFlags & NS_COPYBITS_XFORM_DEST_VALUES)
|
||||||
mTMatrix->TransformCoord(&drect.x, &drect.y, &drect.width, &drect.height);
|
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
|
//XXX flags are unused. that would seem to mean that there is
|
||||||
//inefficiency somewhere... MMP
|
//inefficiency somewhere... MMP
|
||||||
|
|
||||||
::gdk_draw_pixmap(destsurf->GetDrawable(),
|
|
||||||
((nsDrawingSurfaceGTK *)aSrcSurf)->GetGC(),
|
// gdk_draw_pixmap and copy_area do the same thing internally.
|
||||||
((nsDrawingSurfaceGTK *)aSrcSurf)->GetDrawable(),
|
// copy_area sounds better
|
||||||
x, y,
|
::gdk_window_copy_area(destsurf->GetDrawable(),
|
||||||
drect.x, drect.y,
|
((nsDrawingSurfaceGTK *)aSrcSurf)->GetGC(),
|
||||||
drect.width, drect.height);
|
drect.x, drect.y,
|
||||||
|
((nsDrawingSurfaceGTK *)aSrcSurf)->GetDrawable(),
|
||||||
|
srcX, srcY,
|
||||||
|
drect.width, drect.height);
|
||||||
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче