Bug 683745 - Fix OGL FPS Counter on Android; r=jrmuizel

This commit is contained in:
Benoit Girard 2011-08-31 15:58:19 -07:00
parent effa559b42
commit 645ee9b6d4
4 changed files with 12 additions and 15 deletions

View File

@ -46,6 +46,7 @@
#include "ColorLayerOGL.h"
#include "CanvasLayerOGL.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Preferences.h"
#include "LayerManagerOGLShaders.h"
@ -79,7 +80,6 @@ LayerManagerOGL::LayerManagerOGL(nsIWidget *aWidget)
, mBackBufferTexture(0)
, mBackBufferSize(-1, -1)
, mHasBGRA(0)
, mRenderFPS(false)
{
}
@ -334,7 +334,7 @@ LayerManagerOGL::Initialize(nsRefPtr<GLContext> aContext)
};
mGLContext->fBufferData(LOCAL_GL_ARRAY_BUFFER, sizeof(vertices), vertices, LOCAL_GL_STATIC_DRAW);
nsCOMPtr<nsIConsoleService>
nsCOMPtr<nsIConsoleService>
console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (console) {
@ -357,6 +357,8 @@ LayerManagerOGL::Initialize(nsRefPtr<GLContext> aContext)
console->LogStringMessage(msg.get());
}
Preferences::AddBoolVarCache(&sDrawFPS, "layers.acceleration.draw-fps");
reporter.SetSuccessful();
return true;
}
@ -538,6 +540,8 @@ LayerManagerOGL::RootLayer() const
return static_cast<LayerOGL*>(mRoot->ImplData());
}
PRBool LayerManagerOGL::sDrawFPS = PR_FALSE;
/* This function tries to stick to portable C89 as much as possible
* so that it can be easily copied into other applications */
void
@ -802,7 +806,7 @@ LayerManagerOGL::Render()
return;
}
if (mRenderFPS) {
if (sDrawFPS) {
mFPS.DrawFPS(mGLContext, GetCopy2DProgram());
}

View File

@ -407,8 +407,6 @@ public:
gfxMatrix& GetWorldTransform(void);
void WorldTransformRect(nsIntRect& aRect);
void SetRenderFPS(bool aRenderFPS) { mRenderFPS = aRenderFPS; };
private:
/** Widget associated with this layer manager */
nsIWidget *mWidget;
@ -505,7 +503,7 @@ private:
void DrawFPS(GLContext*, CopyProgram*);
} mFPS;
bool mRenderFPS;
static PRBool sDrawFPS;
};
/**

View File

@ -115,7 +115,6 @@ nsBaseWidget::nsBaseWidget()
, mZIndex(0)
, mSizeMode(nsSizeMode_Normal)
, mPopupLevel(ePopupLevelTop)
, mDrawFPS(PR_FALSE)
{
#ifdef NOISY_WIDGET_LEAKS
gNumWidgets++;
@ -816,11 +815,9 @@ nsBaseWidget::GetShouldAccelerate()
Preferences::GetBool("layers.acceleration.disabled", PR_FALSE);
PRBool forceAcceleration =
Preferences::GetBool("layers.acceleration.force-enabled", PR_FALSE);
mDrawFPS =
Preferences::GetBool("layers.acceleration.draw-fps", PR_FALSE);
const char *acceleratedEnv = PR_GetEnv("MOZ_ACCELERATED");
accelerateByDefault = accelerateByDefault ||
accelerateByDefault = accelerateByDefault ||
(acceleratedEnv && (*acceleratedEnv != '0'));
nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
@ -879,7 +876,6 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayersChild* aShadowManager,
* deal with it though!
*/
if (layerManager->Initialize()) {
layerManager->SetRenderFPS(mDrawFPS);
mLayerManager = layerManager;
}
}

View File

@ -264,7 +264,7 @@ protected:
BasicLayerManager* CreateBasicLayerManager();
protected:
protected:
void* mClientData;
ViewWrapper* mViewWrapperPtr;
EVENT_CALLBACK mEventCallback;
@ -289,12 +289,11 @@ protected:
PRInt32 mZIndex;
nsSizeMode mSizeMode;
nsPopupLevel mPopupLevel;
PRBool mDrawFPS;
// the last rolled up popup. Only set this when an nsAutoRollup is in scope,
// so it can be cleared automatically.
static nsIContent* mLastRollup;
#ifdef DEBUG
protected:
static nsAutoString debug_GuiEventToString(nsGUIEvent * aGuiEvent);
@ -312,7 +311,7 @@ protected:
nsGUIEvent * aGuiEvent,
const nsCAutoString & aWidgetName,
PRInt32 aWindowID);
static void debug_DumpPaintEvent(FILE * aFileOut,
nsIWidget * aWidget,
nsPaintEvent * aPaintEvent,