Bug 967844. Part 1: Move mBackgroundColor from Layer to FrameMetrics. r=kats

--HG--
extra : rebase_source : b5fd1fd1b0b1f55990e72d205cc871a46d5f4f8c
This commit is contained in:
Robert O'Callahan 2014-08-30 00:23:25 +12:00
parent 0029aa41fc
commit 24299705bb
10 changed files with 31 additions and 30 deletions

View File

@ -753,6 +753,7 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
WriteParam(aMsg, aParam.mUpdateScrollOffset);
WriteParam(aMsg, aParam.mScrollGeneration);
WriteParam(aMsg, aParam.mTransformScale);
WriteParam(aMsg, aParam.mBackgroundColor);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
@ -779,7 +780,8 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
ReadParam(aMsg, aIter, &aResult->mHasScrollgrab) &&
ReadParam(aMsg, aIter, &aResult->mUpdateScrollOffset) &&
ReadParam(aMsg, aIter, &aResult->mScrollGeneration) &&
ReadParam(aMsg, aIter, &aResult->mTransformScale));
ReadParam(aMsg, aIter, &aResult->mTransformScale) &&
ReadParam(aMsg, aIter, &aResult->mBackgroundColor));
}
};

View File

@ -12,6 +12,7 @@
#include "mozilla/gfx/Rect.h" // for RoundedIn
#include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
#include "mozilla/gfx/Logging.h" // for Log
#include "gfxColor.h"
namespace IPC {
template <typename T> struct ParamTraits;
@ -97,6 +98,7 @@ public:
, mUseDisplayPortMargins(false)
, mPresShellId(-1)
, mViewport(0, 0, 0, 0)
, mBackgroundColor(0, 0, 0, 0)
{}
// Default copy ctor and operator= are fine
@ -122,7 +124,8 @@ public:
mScrollParentId == aOther.mScrollParentId &&
mScrollOffset == aOther.mScrollOffset &&
mHasScrollgrab == aOther.mHasScrollgrab &&
mUpdateScrollOffset == aOther.mUpdateScrollOffset;
mUpdateScrollOffset == aOther.mUpdateScrollOffset &&
mBackgroundColor == aOther.mBackgroundColor;
}
bool operator!=(const FrameMetrics& aOther) const
{
@ -467,6 +470,16 @@ public:
return mViewport;
}
const gfxRGBA& GetBackgroundColor() const
{
return mBackgroundColor;
}
void SetBackgroundColor(const gfxRGBA& aBackgroundColor)
{
mBackgroundColor = aBackgroundColor;
}
private:
// New fields from now on should be made private and old fields should
// be refactored to be private.
@ -535,6 +548,9 @@ private:
// iframe. For layers that don't correspond to a document, this metric is
// meaningless and invalid.
CSSRect mViewport;
// The background color to use when overscrolling.
gfxRGBA mBackgroundColor;
};
/**

View File

@ -209,8 +209,7 @@ Layer::Layer(LayerManager* aManager, void* aImplData) :
mScrollbarTargetId(FrameMetrics::NULL_SCROLL_ID),
mScrollbarDirection(ScrollDirection::NONE),
mDebugColorIndex(0),
mAnimationGeneration(0),
mBackgroundColor(0, 0, 0, 0)
mAnimationGeneration(0)
{}
Layer::~Layer()

View File

@ -1171,17 +1171,6 @@ public:
}
}
void SetBackgroundColor(const gfxRGBA& aColor)
{
if (mBackgroundColor == aColor) {
return;
}
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) BackgroundColor", this));
mBackgroundColor = aColor;
Mutated();
}
void SetContentDescription(const std::string& aContentDescription)
{
if (mContentDescription == aContentDescription) {
@ -1226,7 +1215,6 @@ public:
FrameMetrics::ViewID GetScrollbarTargetContainerId() { return mScrollbarTargetId; }
ScrollDirection GetScrollbarDirection() { return mScrollbarDirection; }
Layer* GetMaskLayer() const { return mMaskLayer; }
gfxRGBA GetBackgroundColor() const { return mBackgroundColor; }
const std::string& GetContentDescription() const { return mContentDescription; }
@ -1655,8 +1643,6 @@ protected:
// If this layer is used for OMTA, then this counter is used to ensure we
// stay in sync with the animation manager
uint64_t mAnimationGeneration;
// This is currently set and used only for scrollable container layers.
gfxRGBA mBackgroundColor;
// A description of the content element corresponding to this frame.
// This is empty unless this is a scrollable ContainerLayer and the
// apz.printtree pref is turned on.

View File

@ -268,15 +268,16 @@ RenderLayers(ContainerT* aContainer,
// placeholder for APZ purposes.
if (aContainer->HasScrollableFrameMetrics() && !aContainer->IsScrollInfoLayer()) {
bool overscrolled = false;
gfxRGBA color;
for (uint32_t i = 0; i < aContainer->GetFrameMetricsCount(); i++) {
AsyncPanZoomController* apzc = aContainer->GetAsyncPanZoomController(i);
if (apzc && apzc->IsOverscrolled()) {
overscrolled = true;
color = aContainer->GetFrameMetrics(i).GetBackgroundColor();
break;
}
}
if (overscrolled) {
gfxRGBA color = aContainer->GetBackgroundColor();
// If the background is completely transparent, there's no point in
// drawing anything for it. Hopefully the layers behind, if any, will
// provide suitable content for the overscroll effect.

View File

@ -367,9 +367,9 @@ TiledContentHost::Composite(EffectChain& aEffectChain,
if (aOpacity == 1.0f && gfxPrefs::LowPrecisionOpacity() < 1.0f) {
// Background colors are only stored on scrollable layers. Grab
// the one from the nearest scrollable ancestor layer.
for (Layer* ancestor = GetLayer(); ancestor; ancestor = ancestor->GetParent()) {
if (ancestor->HasScrollableFrameMetrics()) {
backgroundColor = ancestor->GetBackgroundColor();
for (LayerMetricsWrapper ancestor(GetLayer(), LayerMetricsWrapper::StartAt::BOTTOM); ancestor; ancestor = ancestor.GetParent()) {
if (ancestor.Metrics().IsScrollable()) {
backgroundColor = ancestor.Metrics().GetBackgroundColor();
break;
}
}

View File

@ -321,7 +321,6 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
layer->SetAnimations(common.animations());
layer->SetInvalidRegion(common.invalidRegion());
layer->SetFrameMetrics(common.metrics());
layer->SetBackgroundColor(common.backgroundColor().value());
layer->SetContentDescription(common.contentDescription());
typedef SpecificLayerAttributes Specific;

View File

@ -216,7 +216,6 @@ struct CommonLayerAttributes {
Animation[] animations;
nsIntRegion invalidRegion;
FrameMetrics[] metrics;
LayerColor backgroundColor;
string contentDescription;
};

View File

@ -609,7 +609,6 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
common.animations() = mutant->GetAnimations();
common.invalidRegion() = mutant->GetInvalidRegion();
common.metrics() = mutant->GetAllFrameMetrics();
common.backgroundColor() = mutant->GetBackgroundColor();
common.contentDescription() = mutant->GetContentDescription();
attrs.specific() = null_t();
mutant->FillSpecificAttributes(attrs.specific());

View File

@ -848,20 +848,20 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
metrics.SetHasScrollgrab(true);
}
aRoot->SetFrameMetrics(metrics);
// Also compute and set the background color on the container.
// Also compute and set the background color.
// This is needed for APZ overscrolling support.
if (aScrollFrame) {
if (isRootScrollFrame) {
aRoot->SetBackgroundColor(presShell->GetCanvasBackground());
metrics.SetBackgroundColor(presShell->GetCanvasBackground());
} else {
nsStyleContext* backgroundStyle;
if (nsCSSRendering::FindBackground(aScrollFrame, &backgroundStyle)) {
aRoot->SetBackgroundColor(backgroundStyle->StyleBackground()->mBackgroundColor);
metrics.SetBackgroundColor(backgroundStyle->StyleBackground()->mBackgroundColor);
}
}
}
aRoot->SetFrameMetrics(metrics);
}
nsDisplayListBuilder::~nsDisplayListBuilder() {