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

View File

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

View File

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

View File

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