зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1340082 - Convert nsDisplayOutline to WebRenderDisplayItemLayer. r=mattwoodrow
--HG-- extra : rebase_source : 171473c12467e70726ff57f6597cd9b9281a647c
This commit is contained in:
Родитель
3edceb1620
Коммит
d52379d334
|
@ -461,6 +461,7 @@ private:
|
|||
DECL_GFX_PREF(Live, "layers.advanced.bullet-layers", LayersAllowBulletLayers, bool, false);
|
||||
DECL_GFX_PREF(Live, "layers.advanced.caret-layers", LayersAllowCaretLayers, bool, false);
|
||||
DECL_GFX_PREF(Live, "layers.advanced.boxshadow-outer-layers", LayersAllowOuterBoxShadow, bool, false);
|
||||
DECL_GFX_PREF(Live, "layers.advanced.outline-layers", LayersAllowOutlineLayers, bool, false);
|
||||
DECL_GFX_PREF(Once, "layers.allow-d3d9-fallback", LayersAllowD3D9Fallback, bool, false);
|
||||
DECL_GFX_PREF(Once, "layers.amd-switchable-gfx.enabled", LayersAMDSwitchableGfxEnabled, bool, false);
|
||||
DECL_GFX_PREF(Once, "layers.async-pan-zoom.enabled", AsyncPanZoomEnabledDoNotUseDirectly, bool, true);
|
||||
|
|
|
@ -15,6 +15,7 @@ EXPORTS += [
|
|||
'DisplayListClipState.h',
|
||||
'FrameLayerBuilder.h',
|
||||
'LayerState.h',
|
||||
'nsCSSRenderingBorders.h',
|
||||
'nsDisplayItemTypes.h',
|
||||
'nsDisplayItemTypesList.h',
|
||||
'nsDisplayList.h',
|
||||
|
|
|
@ -948,13 +948,13 @@ GetOutlineInnerRect(nsIFrame* aFrame)
|
|||
return nsRect(nsPoint(0, 0), aFrame->GetSize());
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
|
||||
nsRenderingContext& aRenderingContext,
|
||||
nsIFrame* aForFrame,
|
||||
const nsRect& aDirtyRect,
|
||||
const nsRect& aBorderArea,
|
||||
nsStyleContext* aStyleContext)
|
||||
Maybe<nsCSSBorderRenderer>
|
||||
nsCSSRendering::CreateBorderRendererForOutline(nsPresContext* aPresContext,
|
||||
nsRenderingContext* aRenderingContext,
|
||||
nsIFrame* aForFrame,
|
||||
const nsRect& aDirtyRect,
|
||||
const nsRect& aBorderArea,
|
||||
nsStyleContext* aStyleContext)
|
||||
{
|
||||
nscoord twipsRadii[8];
|
||||
|
||||
|
@ -968,7 +968,7 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
|
|||
|
||||
if (width == 0 && outlineStyle != NS_STYLE_BORDER_STYLE_AUTO) {
|
||||
// Empty outline
|
||||
return;
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
nsIFrame* bgFrame = nsCSSRendering::FindNonTransparentBackgroundFrame
|
||||
|
@ -997,7 +997,7 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
|
|||
// encroach into the content area. A safer calculation would be to
|
||||
// shorten insideRect by the radius one each side before performing this test.
|
||||
if (innerRect.Contains(aDirtyRect))
|
||||
return;
|
||||
return Nothing();
|
||||
|
||||
nsRect outerRect = innerRect;
|
||||
outerRect.Inflate(width, width);
|
||||
|
@ -1022,14 +1022,14 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
|
|||
nsITheme* theme = aPresContext->GetTheme();
|
||||
if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame,
|
||||
NS_THEME_FOCUS_OUTLINE)) {
|
||||
theme->DrawWidgetBackground(&aRenderingContext, aForFrame,
|
||||
theme->DrawWidgetBackground(aRenderingContext, aForFrame,
|
||||
NS_THEME_FOCUS_OUTLINE, innerRect,
|
||||
aDirtyRect);
|
||||
return;
|
||||
return Nothing();
|
||||
}
|
||||
}
|
||||
if (width == 0) {
|
||||
return; // empty outline
|
||||
return Nothing(); // empty outline
|
||||
}
|
||||
// http://dev.w3.org/csswg/css-ui/#outline
|
||||
// "User agents may treat 'auto' as 'solid'."
|
||||
|
@ -1061,11 +1061,10 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
|
|||
document = content->OwnerDoc();
|
||||
}
|
||||
|
||||
// start drawing
|
||||
|
||||
DrawTarget* dt = aRenderingContext ? aRenderingContext->GetDrawTarget() : nullptr;
|
||||
nsCSSBorderRenderer br(aPresContext,
|
||||
document,
|
||||
aRenderingContext.GetDrawTarget(),
|
||||
dt,
|
||||
dirtyRect,
|
||||
oRect,
|
||||
outlineStyles,
|
||||
|
@ -1074,7 +1073,30 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
|
|||
outlineColors,
|
||||
nullptr,
|
||||
bgColor);
|
||||
br.DrawBorders();
|
||||
|
||||
return Some(br);
|
||||
}
|
||||
|
||||
void
|
||||
nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
|
||||
nsRenderingContext& aRenderingContext,
|
||||
nsIFrame* aForFrame,
|
||||
const nsRect& aDirtyRect,
|
||||
const nsRect& aBorderArea,
|
||||
nsStyleContext* aStyleContext)
|
||||
{
|
||||
Maybe<nsCSSBorderRenderer> br = CreateBorderRendererForOutline(aPresContext,
|
||||
&aRenderingContext,
|
||||
aForFrame,
|
||||
aDirtyRect,
|
||||
aBorderArea,
|
||||
aStyleContext);
|
||||
if (!br) {
|
||||
return;
|
||||
}
|
||||
|
||||
// start drawing
|
||||
br->DrawBorders();
|
||||
|
||||
PrintAsStringNewline();
|
||||
}
|
||||
|
|
|
@ -438,6 +438,13 @@ struct nsCSSRendering {
|
|||
nsStyleContext* aStyleContext,
|
||||
Sides aSkipSides = Sides());
|
||||
|
||||
static mozilla::Maybe<nsCSSBorderRenderer>
|
||||
CreateBorderRendererForOutline(nsPresContext* aPresContext,
|
||||
nsRenderingContext* aRenderingContext,
|
||||
nsIFrame* aForFrame,
|
||||
const nsRect& aDirtyRect,
|
||||
const nsRect& aBorderArea,
|
||||
nsStyleContext* aStyleContext);
|
||||
|
||||
/**
|
||||
* Render the outline for an element using css rendering rules
|
||||
|
|
|
@ -78,6 +78,7 @@ class nsCSSBorderRenderer final
|
|||
typedef mozilla::gfx::StrokeOptions StrokeOptions;
|
||||
|
||||
friend class nsDisplayBorder;
|
||||
friend class nsDisplayOutline;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -121,7 +122,7 @@ private:
|
|||
|
||||
// destination DrawTarget and dirty rect
|
||||
DrawTarget* mDrawTarget;
|
||||
const Rect mDirtyRect;
|
||||
Rect mDirtyRect;
|
||||
|
||||
// the rectangle of the outside and the inside of the border
|
||||
Rect mOuterRect;
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
#include "mozilla/layers/WebRenderLayerManager.h"
|
||||
#include "mozilla/layers/WebRenderDisplayItemLayer.h"
|
||||
#include "mozilla/layers/WebRenderMessages.h"
|
||||
#include "mozilla/layers/WebRenderDisplayItemLayer.h"
|
||||
|
||||
// GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
|
||||
// GetTickCount().
|
||||
|
@ -4090,6 +4091,72 @@ nsDisplayOutline::Paint(nsDisplayListBuilder* aBuilder,
|
|||
mFrame->StyleContext());
|
||||
}
|
||||
|
||||
LayerState
|
||||
nsDisplayOutline::GetLayerState(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerLayerParameters& aParameters)
|
||||
{
|
||||
if (!gfxPrefs::LayersAllowOutlineLayers()) {
|
||||
return LAYER_NONE;
|
||||
}
|
||||
|
||||
uint8_t outlineStyle = mFrame->StyleContext()->StyleOutline()->mOutlineStyle;
|
||||
if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO && nsLayoutUtils::IsOutlineStyleAutoEnabled()) {
|
||||
nsITheme* theme = mFrame->PresContext()->GetTheme();
|
||||
if (theme && theme->ThemeSupportsWidget(mFrame->PresContext(), mFrame,
|
||||
NS_THEME_FOCUS_OUTLINE)) {
|
||||
return LAYER_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
nsPoint offset = ToReferenceFrame();
|
||||
Maybe<nsCSSBorderRenderer> br =
|
||||
nsCSSRendering::CreateBorderRendererForOutline(mFrame->PresContext(),
|
||||
nullptr, mFrame,
|
||||
mVisibleRect,
|
||||
nsRect(offset, mFrame->GetSize()),
|
||||
mFrame->StyleContext());
|
||||
|
||||
if (!br) {
|
||||
return LAYER_NONE;
|
||||
}
|
||||
|
||||
mBorderRenderer = br;
|
||||
|
||||
return LAYER_ACTIVE;
|
||||
}
|
||||
|
||||
already_AddRefed<Layer>
|
||||
nsDisplayOutline::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerLayerParameters& aContainerParameters)
|
||||
{
|
||||
return BuildDisplayItemLayer(aBuilder, aManager, aContainerParameters);
|
||||
}
|
||||
|
||||
void
|
||||
nsDisplayOutline::CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
|
||||
WebRenderDisplayItemLayer* aLayer)
|
||||
{
|
||||
MOZ_ASSERT(mBorderRenderer.isSome());
|
||||
|
||||
Rect outlineTransformedRect = aLayer->RelativeToParent(mBorderRenderer->mOuterRect);
|
||||
|
||||
nsCSSBorderRenderer* br = mBorderRenderer.ptr();
|
||||
WrBorderSide side[4];
|
||||
NS_FOR_CSS_SIDES(i) {
|
||||
side[i] = wr::ToWrBorderSide(br->mBorderWidths[i], ToDeviceColor(br->mBorderColors[i]), br->mBorderStyles[i]);
|
||||
}
|
||||
WrBorderRadius borderRadius = wr::ToWrBorderRadius(LayerSize(br->mBorderRadii[0].width, br->mBorderRadii[0].height),
|
||||
LayerSize(br->mBorderRadii[1].width, br->mBorderRadii[1].height),
|
||||
LayerSize(br->mBorderRadii[3].width, br->mBorderRadii[3].height),
|
||||
LayerSize(br->mBorderRadii[2].width, br->mBorderRadii[2].height));
|
||||
aCommands.AppendElement(OpDPPushBorder(wr::ToWrRect(outlineTransformedRect),
|
||||
wr::ToWrRect(outlineTransformedRect),
|
||||
side[0], side[1], side[2], side[3],
|
||||
borderRadius));
|
||||
}
|
||||
|
||||
bool
|
||||
nsDisplayOutline::IsInvisibleInRect(const nsRect& aRect)
|
||||
{
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/gfx/UserData.h"
|
||||
#include "nsCSSRenderingBorders.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include "nsTHashtable.h"
|
||||
|
@ -3453,10 +3454,20 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerLayerParameters& aParameters) override;
|
||||
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerLayerParameters& aContainerParameters) override;
|
||||
virtual void CreateWebRenderCommands(nsTArray<WebRenderCommand>& aCommands,
|
||||
mozilla::layers::WebRenderDisplayItemLayer* aLayer) override;
|
||||
virtual bool IsInvisibleInRect(const nsRect& aRect) override;
|
||||
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) override;
|
||||
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) override;
|
||||
NS_DISPLAY_DECL_NAME("Outline", TYPE_OUTLINE)
|
||||
|
||||
mozilla::Maybe<nsCSSBorderRenderer> mBorderRenderer;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче