Bug 334411: Introduce flashing invalidates areas when paint flashing is enabled. r=roc

This commit is contained in:
Bas Schouten 2011-11-15 04:59:03 +00:00
parent a3bbb32ede
commit 1b8e035e99
2 changed files with 28 additions and 0 deletions

View File

@ -49,6 +49,8 @@
#include "nsImageFrame.h" #include "nsImageFrame.h"
#include "nsRenderingContext.h" #include "nsRenderingContext.h"
#include "mozilla/Preferences.h"
#ifdef DEBUG #ifdef DEBUG
#include <stdio.h> #include <stdio.h>
#endif #endif
@ -470,6 +472,27 @@ FrameLayerBuilder::DisplayItemDataEntry::HasNonEmptyContainerLayer()
return false; return false;
} }
void
FrameLayerBuilder::FlashPaint(gfxContext *aContext)
{
static bool sPaintFlashingEnabled;
static bool sPaintFlashingPrefCached = false;
if (!sPaintFlashingPrefCached) {
sPaintFlashingPrefCached = true;
mozilla::Preferences::AddBoolVarCache(&sPaintFlashingEnabled,
"nglayout.debug.paint_flashing");
}
if (sPaintFlashingEnabled) {
float r = float(rand()) / RAND_MAX;
float g = float(rand()) / RAND_MAX;
float b = float(rand()) / RAND_MAX;
aContext->SetColor(gfxRGBA(r, g, b, 0.2));
aContext->Paint();
}
}
/* static */ nsTArray<FrameLayerBuilder::DisplayItemData>* /* static */ nsTArray<FrameLayerBuilder::DisplayItemData>*
FrameLayerBuilder::GetDisplayItemDataArrayForFrame(nsIFrame* aFrame) FrameLayerBuilder::GetDisplayItemDataArrayForFrame(nsIFrame* aFrame)
{ {
@ -2127,6 +2150,8 @@ FrameLayerBuilder::DrawThebesLayer(ThebesLayer* aLayer,
if (setClipRect) { if (setClipRect) {
aContext->Restore(); aContext->Restore();
} }
FlashPaint(aContext);
} }
bool bool

View File

@ -441,6 +441,9 @@ protected:
// LayerManagerData needs to see DisplayItemDataEntry. // LayerManagerData needs to see DisplayItemDataEntry.
friend class LayerManagerData; friend class LayerManagerData;
// Flash the area within the context clip if paint flashing is enabled.
static void FlashPaint(gfxContext *aContext);
/* /*
* Get the DisplayItemData array associated with this frame, or null if one * Get the DisplayItemData array associated with this frame, or null if one
* doesn't exist. * doesn't exist.