mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-09 04:25:38 +00:00
Remove FPSState. (bug 1352151 part 3, r=mattwoodrow)
--HG-- extra : rebase_source : 27454cb163e79a26842963d0cf468aec617254d3
This commit is contained in:
parent
432eda07ae
commit
dd464dcc40
@ -356,95 +356,5 @@ FPSCounter::WriteFrameTimeStamps()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
FPSState::FPSState()
|
||||
: mCompositionFps("Compositor")
|
||||
, mTransactionFps("LayerTransactions")
|
||||
{
|
||||
}
|
||||
|
||||
// Size of the builtin font.
|
||||
static const float FontHeight = 7.f;
|
||||
static const float FontWidth = 4.f;
|
||||
|
||||
// Scale the font when drawing it to the viewport for better readability.
|
||||
static const float FontScaleX = 2.f;
|
||||
static const float FontScaleY = 3.f;
|
||||
|
||||
static void DrawDigits(unsigned int aValue,
|
||||
int aOffsetX, int aOffsetY,
|
||||
Compositor* aCompositor,
|
||||
EffectChain& aEffectChain)
|
||||
{
|
||||
if (aValue > 999) {
|
||||
aValue = 999;
|
||||
}
|
||||
|
||||
unsigned int divisor = 100;
|
||||
float textureWidth = FontWidth * 10;
|
||||
gfx::Float opacity = 1;
|
||||
gfx::Matrix4x4 transform;
|
||||
transform.PreScale(FontScaleX, FontScaleY, 1);
|
||||
|
||||
for (size_t n = 0; n < 3; ++n) {
|
||||
unsigned int digit = aValue % (divisor * 10) / divisor;
|
||||
divisor /= 10;
|
||||
|
||||
RefPtr<TexturedEffect> texturedEffect = static_cast<TexturedEffect*>(aEffectChain.mPrimaryEffect.get());
|
||||
texturedEffect->mTextureCoords = Rect(float(digit * FontWidth) / textureWidth, 0, FontWidth / textureWidth, 1.0f);
|
||||
|
||||
Rect drawRect = Rect(aOffsetX + n * FontWidth, aOffsetY, FontWidth, FontHeight);
|
||||
IntRect clipRect = IntRect(0, 0, 300, 100);
|
||||
aCompositor->DrawQuad(drawRect, clipRect, aEffectChain, opacity, transform);
|
||||
}
|
||||
}
|
||||
|
||||
void FPSState::DrawFPS(TimeStamp aNow,
|
||||
int aOffsetX, int aOffsetY,
|
||||
unsigned int aFillRatio,
|
||||
Compositor* aCompositor)
|
||||
{
|
||||
if (!mFPSTextureSource) {
|
||||
const char *text =
|
||||
" "
|
||||
" XXX XX XXX XXX X X XXX XXX XXX XXX XXX"
|
||||
" X X X X X X X X X X X X X X"
|
||||
" X X X XXX XXX XXX XXX XXX X XXX XXX"
|
||||
" X X X X X X X X X X X X X"
|
||||
" XXX XXX XXX XXX X XXX XXX X XXX X"
|
||||
" ";
|
||||
|
||||
// Convert the text encoding above to RGBA.
|
||||
int w = FontWidth * 10;
|
||||
int h = FontHeight;
|
||||
uint32_t* buf = (uint32_t *) malloc(w * h * sizeof(uint32_t));
|
||||
for (int i = 0; i < h; i++) {
|
||||
for (int j = 0; j < w; j++) {
|
||||
uint32_t purple = 0xfff000ff;
|
||||
uint32_t white = 0xffffffff;
|
||||
buf[i * w + j] = (text[i * w + j] == ' ') ? purple : white;
|
||||
}
|
||||
}
|
||||
|
||||
int bytesPerPixel = 4;
|
||||
RefPtr<DataSourceSurface> fpsSurface = Factory::CreateWrappingDataSourceSurface(
|
||||
reinterpret_cast<uint8_t*>(buf), w * bytesPerPixel, IntSize(w, h), SurfaceFormat::B8G8R8A8);
|
||||
mFPSTextureSource = aCompositor->CreateDataTextureSource();
|
||||
mFPSTextureSource->Update(fpsSurface);
|
||||
}
|
||||
|
||||
EffectChain effectChain;
|
||||
effectChain.mPrimaryEffect = CreateTexturedEffect(SurfaceFormat::B8G8R8A8,
|
||||
mFPSTextureSource,
|
||||
SamplingFilter::POINT,
|
||||
true);
|
||||
|
||||
unsigned int fps = unsigned(mCompositionFps.AddFrameAndGetFps(aNow));
|
||||
unsigned int txnFps = unsigned(mTransactionFps.GetFPS(aNow));
|
||||
|
||||
DrawDigits(fps, aOffsetX + 0, aOffsetY, aCompositor, effectChain);
|
||||
DrawDigits(txnFps, aOffsetX + FontWidth * 4, aOffsetY, aCompositor, effectChain);
|
||||
DrawDigits(aFillRatio, aOffsetX + FontWidth * 8, aOffsetY, aCompositor, effectChain);
|
||||
}
|
||||
|
||||
} // end namespace layers
|
||||
} // end namespace mozilla
|
||||
|
@ -94,20 +94,6 @@ private:
|
||||
TimeStamp mLastInterval;
|
||||
};
|
||||
|
||||
struct FPSState {
|
||||
FPSState();
|
||||
void DrawFPS(TimeStamp, int offsetX, int offsetY, unsigned, Compositor* aCompositor);
|
||||
void NotifyShadowTreeTransaction() {
|
||||
mTransactionFps.AddFrame(TimeStamp::Now());
|
||||
}
|
||||
|
||||
FPSCounter mCompositionFps;
|
||||
FPSCounter mTransactionFps;
|
||||
|
||||
private:
|
||||
RefPtr<DataTextureSource> mFPSTextureSource;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user