void LayerManagerComposite::InvalidateDebugOverlay(const IntRect& aBounds) { bool drawFps = gfxPrefs::LayersDrawFPS(); bool drawFrameCounter = gfxPrefs::DrawFrameCounter(); bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars(); if (drawFps || drawFrameCounter) { AddInvalidRegion(nsIntRect(0, 0, 256, 256)); } if (drawFrameColorBars) { AddInvalidRegion(nsIntRect(0, 0, 10, aBounds.height)); } if (drawFrameColorBars) { AddInvalidRegion(nsIntRect(0, 0, 10, aBounds.height)); } }
void LayerManagerComposite::RenderDebugOverlay(const Rect& aBounds) { bool drawFps = gfxPrefs::LayersDrawFPS(); bool drawFrameCounter = gfxPrefs::DrawFrameCounter(); bool drawFrameColorBars = gfxPrefs::CompositorDrawColorBars(); TimeStamp now = TimeStamp::Now(); if (drawFps) { if (!mFPS) { mFPS = MakeUnique<FPSState>(); } float alpha = 1; #ifdef ANDROID // Draw a translation delay warning overlay int width; int border; if (!mWarnTime.IsNull() && (now - mWarnTime).ToMilliseconds() < kVisualWarningDuration) { EffectChain effects; // Black blorder border = 4; width = 6; effects.mPrimaryEffect = new EffectSolidColor(gfx::Color(0, 0, 0, 1)); mCompositor->DrawQuad(gfx::Rect(border, border, aBounds.width - 2 * border, width), aBounds, effects, alpha, gfx::Matrix4x4()); mCompositor->DrawQuad(gfx::Rect(border, aBounds.height - border - width, aBounds.width - 2 * border, width), aBounds, effects, alpha, gfx::Matrix4x4()); mCompositor->DrawQuad(gfx::Rect(border, border + width, width, aBounds.height - 2 * border - width * 2), aBounds, effects, alpha, gfx::Matrix4x4()); mCompositor->DrawQuad(gfx::Rect(aBounds.width - border - width, border + width, width, aBounds.height - 2 * border - 2 * width), aBounds, effects, alpha, gfx::Matrix4x4()); // Content border = 5; width = 4; effects.mPrimaryEffect = new EffectSolidColor(gfx::Color(1, 1.f - mWarningLevel, 0, 1)); mCompositor->DrawQuad(gfx::Rect(border, border, aBounds.width - 2 * border, width), aBounds, effects, alpha, gfx::Matrix4x4()); mCompositor->DrawQuad(gfx::Rect(border, aBounds.height - border - width, aBounds.width - 2 * border, width), aBounds, effects, alpha, gfx::Matrix4x4()); mCompositor->DrawQuad(gfx::Rect(border, border + width, width, aBounds.height - 2 * border - width * 2), aBounds, effects, alpha, gfx::Matrix4x4()); mCompositor->DrawQuad(gfx::Rect(aBounds.width - border - width, border + width, width, aBounds.height - 2 * border - 2 * width), aBounds, effects, alpha, gfx::Matrix4x4()); SetDebugOverlayWantsNextFrame(true); } #endif float fillRatio = mCompositor->GetFillRatio(); mFPS->DrawFPS(now, drawFrameColorBars ? 10 : 1, 2, unsigned(fillRatio), mCompositor); if (mUnusedApzTransformWarning) { // If we have an unused APZ transform on this composite, draw a 20x20 red box // in the top-right corner EffectChain effects; effects.mPrimaryEffect = new EffectSolidColor(gfx::Color(1, 0, 0, 1)); mCompositor->DrawQuad(gfx::Rect(aBounds.width - 20, 0, aBounds.width, 20), aBounds, effects, alpha, gfx::Matrix4x4()); mUnusedApzTransformWarning = false; SetDebugOverlayWantsNextFrame(true); } // Each frame is invalidate by the previous frame for simplicity AddInvalidRegion(nsIntRect(0, 0, 256, 256)); } else { mFPS = nullptr; } if (drawFrameColorBars) { gfx::Rect sideRect(0, 0, 10, aBounds.height); EffectChain effects; effects.mPrimaryEffect = new EffectSolidColor(gfxUtils::GetColorForFrameNumber(sFrameCount)); mCompositor->DrawQuad(sideRect, sideRect, effects, 1.0, gfx::Matrix4x4()); // Each frame is invalidate by the previous frame for simplicity AddInvalidRegion(nsIntRect(0, 0, sideRect.width, sideRect.height)); } #ifdef MOZ_PROFILING if (drawFrameCounter) { profiler_set_frame_number(sFrameCount); const char* qr = sQRCodeTable[sFrameCount%256]; int size = 21; int padding = 2; float opacity = 1.0; const uint16_t bitWidth = 5; gfx::Rect clip(0,0, bitWidth*640, bitWidth*640); // Draw the white squares at once gfx::Color bitColor(1.0, 1.0, 1.0, 1.0); EffectChain effects; effects.mPrimaryEffect = new EffectSolidColor(bitColor); int totalSize = (size + padding * 2) * bitWidth; mCompositor->DrawQuad(gfx::Rect(0, 0, totalSize, totalSize), clip, effects, opacity, gfx::Matrix4x4()); // Draw a black square for every bit set in qr[index] effects.mPrimaryEffect = new EffectSolidColor(gfx::Color(0, 0, 0, 1.0)); for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { // Select the right bit from the binary encoding int currBit = 128 >> ((x + y * 21) % 8); int i = (x + y * 21) / 8; if (qr[i] & currBit) { mCompositor->DrawQuad(gfx::Rect(bitWidth * (x + padding), bitWidth * (y + padding), bitWidth, bitWidth), clip, effects, opacity, gfx::Matrix4x4()); } } } // Each frame is invalidate by the previous frame for simplicity AddInvalidRegion(nsIntRect(0, 0, 256, 256)); } #endif if (drawFrameColorBars || drawFrameCounter) { // We intentionally overflow at 2^16. sFrameCount++; } }