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)
{ {
} }
@ -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,8 +815,6 @@ 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 ||
@ -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

@ -289,7 +289,6 @@ 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.