mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 19:37:15 +00:00
Bug 200657 BeOS Locking needs to be rewritten in GFX
patch by sergei_d@fi.tartu.ee r=thesuckiestemail
This commit is contained in:
parent
203c40b9da
commit
6b2e92407d
@ -19,7 +19,7 @@
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s): Sergei Dolgov
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -65,7 +65,10 @@ nsDrawingSurfaceBeOS :: ~nsDrawingSurfaceBeOS()
|
||||
if(mBitmap)
|
||||
{
|
||||
// Deleting mBitmap will also remove and delete any child views
|
||||
mBitmap->Unlock();
|
||||
delete mBitmap;
|
||||
mView = NULL;
|
||||
mBitmap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +115,6 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: Lock(PRInt32 aX, PRInt32 aY,
|
||||
|
||||
// Obtain an ximage from the pixmap. ( I think this copy the bitmap )
|
||||
// FIX ME !!!! We need to copy the part locked into the mImage
|
||||
mView->LockLooper();
|
||||
|
||||
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
|
||||
// MOZ_TIMER_STOP(mLockTime);
|
||||
@ -147,7 +149,7 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: Unlock(void)
|
||||
|
||||
// FIX ME!!!
|
||||
// Destroy mImage
|
||||
mView->UnlockLooper();
|
||||
|
||||
|
||||
mLocked = PR_FALSE;
|
||||
|
||||
@ -190,19 +192,16 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView)
|
||||
if(aView->LockLooper())
|
||||
{
|
||||
//remember dimensions
|
||||
mWidth=nscoord(aView->Bounds().Width()+1);
|
||||
mHeight=nscoord(aView->Bounds().Height()+1);
|
||||
BRect r = aView->Bounds();
|
||||
mWidth = nscoord(r.IntegerWidth() + 1);
|
||||
mHeight = nscoord(r.IntegerHeight() + 1);
|
||||
|
||||
mView = aView;
|
||||
|
||||
aView->UnlockLooper();
|
||||
}
|
||||
|
||||
// XXX was i smoking crack when i wrote this comment?
|
||||
// this is definatly going to be on the screen, as it will be the window of a
|
||||
// widget or something.
|
||||
// onscreen View, attached to BWindow, acquired via GetNativeData() call in nsRendering
|
||||
mIsOffscreen = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -216,10 +215,12 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView, PRUint32 aWidth,
|
||||
mHeight=aHeight;
|
||||
mFlags = aFlags;
|
||||
|
||||
// we can draw on this offscreen because it has no parent
|
||||
//creating offscreen backbuffer surface
|
||||
mIsOffscreen = PR_TRUE;
|
||||
|
||||
//TODO: Maybe we should reuse BView by resizing it,
|
||||
//and also reuse BBitmap if new size is = < of current size
|
||||
BRect r(0,0, mWidth-1, mHeight-1);
|
||||
//creating auxiliary BView to draw on offscreen BBitmap
|
||||
mView = new BView(r, "", 0, 0);
|
||||
if (!mView)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -228,6 +229,7 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView, PRUint32 aWidth,
|
||||
// (aWidth > 0) && (aHeight > 0))
|
||||
if(aWidth > 0 && aHeight > 0)
|
||||
{
|
||||
///creating offscreen BBitmap
|
||||
mBitmap = new BBitmap(r, B_RGBA32, true);
|
||||
if (!mBitmap)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -240,6 +242,11 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView, PRUint32 aWidth,
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//NB! Locking bitmap for lifetime to avoid unneccessary locking at each
|
||||
//drawing primitive call. Locking is quite time-expensive.
|
||||
//To avoid it, we call surface->LockDrawable() instead LockLooper()
|
||||
mBitmap->Lock();
|
||||
//Setting ViewColor transparent noticeably decreases AppServer load in DrawBitmp()
|
||||
//Applicable here, because Mozilla paints backgrounds explicitly, with images or filling areas.
|
||||
mView->SetViewColor(B_TRANSPARENT_32_BIT);
|
||||
@ -257,10 +264,9 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: AcquireView(BView **aView)
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: AcquireBitmap(BBitmap **aBitmap)
|
||||
{
|
||||
if(mBitmap && mBitmap->Lock())
|
||||
if(mBitmap && mView)
|
||||
{
|
||||
mView->Sync();
|
||||
mBitmap->Unlock();
|
||||
}
|
||||
*aBitmap = mBitmap;
|
||||
|
||||
@ -276,3 +282,19 @@ NS_IMETHODIMP nsDrawingSurfaceBeOS :: ReleaseBitmap(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool nsDrawingSurfaceBeOS :: LockDrawable()
|
||||
{
|
||||
//TODO: try to avoid exta locking also for onscreen BView.
|
||||
//Perhaps it needs synchronization with widget through nsToolkit and lock counting.
|
||||
bool rv = true;
|
||||
if (!mBitmap)
|
||||
rv = mView->LockLooper();
|
||||
return rv;
|
||||
}
|
||||
|
||||
void nsDrawingSurfaceBeOS :: UnlockDrawable()
|
||||
{
|
||||
if (!mBitmap)
|
||||
mView->UnlockLooper();
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s): Sergei Dolgov
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -80,6 +80,8 @@ public:
|
||||
NS_IMETHOD ReleaseBitmap(void);
|
||||
|
||||
void GetSize(PRUint32 *aWidth, PRUint32 *aHeight) { *aWidth = mWidth; *aHeight = mHeight; }
|
||||
bool LockDrawable();
|
||||
void UnlockDrawable();
|
||||
|
||||
private:
|
||||
BView *mView;
|
||||
|
@ -25,6 +25,7 @@
|
||||
* Christian M Hoffman <chrmhoffmann@web.de>
|
||||
* Makoto hamanaka <VYA04230@nifty.com>
|
||||
* Paul Ashford <arougthopher@lizardland.net>
|
||||
* Sergei Dolgov <sergei_d@fi.tartu.ee>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -61,7 +62,6 @@
|
||||
#undef REALLY_NOISY_FONTS
|
||||
|
||||
nsFontMetricsBeOS::nsFontMetricsBeOS()
|
||||
:mEmulateBold(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
@ -205,13 +205,10 @@ NS_IMETHODIMP nsFontMetricsBeOS::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
face |= B_STRIKEOUT_FACE;
|
||||
|
||||
mFontHandle.SetFace( face );
|
||||
// emulate italic and bold if the selected family has no such style
|
||||
// emulate italic the selected family has no such style
|
||||
if (aFont.style == NS_FONT_STYLE_ITALIC
|
||||
&& !(mFontHandle.Face() & B_ITALIC_FACE))
|
||||
mFontHandle.SetShear(105.0);
|
||||
if ( aFont.weight > NS_FONT_WEIGHT_NORMAL
|
||||
&& !(mFontHandle.Face() & B_BOLD_FACE))
|
||||
mEmulateBold = PR_TRUE;
|
||||
|
||||
mFontHandle.SetSize( rounded * app2dev );
|
||||
fflush(stdout);
|
||||
|
@ -91,7 +91,6 @@ public:
|
||||
NS_IMETHOD GetSpaceWidth(nscoord &aSpaceWidth);
|
||||
|
||||
static nsresult FamilyExists(const nsString& aFontName);
|
||||
inline PRBool GetEmulateBold() { return mEmulateBold; }
|
||||
static int FontMatchesGenericType(font_family family, uint32 flags, const char* aGeneric, const char* aLangGroup);
|
||||
nsCOMPtr<nsIAtom> mLangGroup;
|
||||
static int MatchesLangGroup(font_family family, const char* aLangGroup);
|
||||
@ -122,8 +121,6 @@ protected:
|
||||
PRUint16 mPixelSize;
|
||||
PRUint8 mStretchIndex;
|
||||
PRUint8 mStyleIndex;
|
||||
|
||||
PRBool mEmulateBold;
|
||||
};
|
||||
|
||||
class nsFontEnumeratorBeOS : public nsIFontEnumerator
|
||||
|
@ -224,8 +224,8 @@ NS_IMETHODIMP nsImageBeOS::Draw(nsIRenderingContext &aContext, nsIDrawingSurface
|
||||
BRect(dstX, dstY, dstMostX - 1, dstMostY - 1));
|
||||
}
|
||||
// view was locked by LockAndUpdateView() before it was aquired. So unlock.
|
||||
view->UnlockLooper();
|
||||
}
|
||||
((nsRenderingContextBeOS&)aContext).UnlockView();
|
||||
beosdrawing->ReleaseView();
|
||||
}
|
||||
|
||||
@ -291,8 +291,8 @@ NS_IMETHODIMP nsImageBeOS::Draw(nsIRenderingContext &aContext, nsIDrawingSurface
|
||||
view->DrawBitmap(mImage, BRect(validX, validY, validMostX - 1, validMostY - 1),
|
||||
BRect(aX + validX, aY + validY, aX + validMostX - 1, aY + validMostY - 1));
|
||||
}
|
||||
view->UnlockLooper();
|
||||
}
|
||||
((nsRenderingContextBeOS&)aContext).UnlockView();
|
||||
beosdrawing->ReleaseView();
|
||||
}
|
||||
|
||||
@ -352,7 +352,7 @@ NS_IMETHODIMP nsImageBeOS::DrawTile(nsIRenderingContext &aContext, nsIDrawingSur
|
||||
if (!tmpbmp || tmpbitlength == 0)
|
||||
{
|
||||
// Failed. Cleaning things a bit.
|
||||
view->UnlockLooper();
|
||||
((nsRenderingContextBeOS&)aContext).UnlockView();
|
||||
if(tmpbmp)
|
||||
delete tmpbmp;
|
||||
beosdrawing->ReleaseView();
|
||||
@ -406,13 +406,14 @@ NS_IMETHODIMP nsImageBeOS::DrawTile(nsIRenderingContext &aContext, nsIDrawingSur
|
||||
view->DrawBitmap(tmpbmp, BPoint(aTileRect.x , aTileRect.y ));
|
||||
view->SetDrawingMode(B_OP_COPY);
|
||||
view->Sync(); // useful in multilayered pages with animation
|
||||
view->UnlockLooper();
|
||||
|
||||
if (tmpbmp)
|
||||
{
|
||||
delete tmpbmp;
|
||||
tmpbmp = 0;
|
||||
}
|
||||
}
|
||||
((nsRenderingContextBeOS&)aContext).UnlockView();
|
||||
beosdrawing->ReleaseView();
|
||||
}
|
||||
mFlags = 0;
|
||||
|
@ -20,7 +20,7 @@
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Daniel Switkin and Mathias Agopian
|
||||
* Daniel Switkin, Mathias Agopian and Sergei Dolgov
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: 4; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
@ -176,17 +176,7 @@ public:
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags);
|
||||
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 *ngd);
|
||||
|
||||
void CreateClipRegion() {
|
||||
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
|
||||
if (mClipRegion) return;
|
||||
PRUint32 w, h;
|
||||
mSurface->GetSize(&w, &h);
|
||||
mClipRegion = do_CreateInstance(kRegionCID);
|
||||
if (mClipRegion) {
|
||||
mClipRegion->Init();
|
||||
mClipRegion->SetTo(0, 0, w, h);
|
||||
}
|
||||
}
|
||||
void CreateClipRegion();
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
/**
|
||||
@ -207,17 +197,18 @@ public:
|
||||
//LockAndUpdateView() - method, similar to UpdateGC (from gtk gfx).
|
||||
//Acquires "fresh" drawable mView (BView) from drawing surface, locks it (BeOS specifics),
|
||||
//updates font, color and sets clipping region.
|
||||
//In if() statement actually replaces (mView && mView->LockLooper);
|
||||
//Each LockAndUpdateView() statement must have UnlockLooper() counterpart somewhere,
|
||||
//if returned true.
|
||||
bool LockAndUpdateView();
|
||||
//Each LockAndUpdateView() statement must have UnlockView() counterpart somewhere,
|
||||
//if returned true.
|
||||
void UnlockView();
|
||||
|
||||
protected:
|
||||
NS_IMETHOD CommonInit();
|
||||
|
||||
// ConditionRect is used to fix coordinate overflow problems for
|
||||
// rectangles after they are transformed to screen coordinates
|
||||
void ConditionRect(nscoord &x, nscoord &y, nscoord &w, nscoord &h) {
|
||||
void ConditionRect(nscoord &x, nscoord &y, nscoord &w, nscoord &h)
|
||||
{
|
||||
if (y < -32766) y = -32766;
|
||||
if (y + h > 32766) h = 32766 - y;
|
||||
if (x < -32766) x = -32766;
|
||||
@ -232,6 +223,7 @@ protected:
|
||||
nsVoidArray *mStateCache;
|
||||
BView *mView;
|
||||
nscolor mCurrentColor;
|
||||
rgb_color mRGB_color;
|
||||
BFont *mCurrentFont;
|
||||
nsLineStyle mCurrentLineStyle;
|
||||
float mP2T;
|
||||
|
Loading…
x
Reference in New Issue
Block a user