зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1343450 - Convert nsDisplayCanvasBackgroundColor to WebRenderDisplayItemLayer. r=mattwoodrow
This commit is contained in:
Родитель
f47b17cdff
Коммит
58f9109c72
|
@ -469,6 +469,7 @@ private:
|
|||
DECL_GFX_PREF(Live, "layers.advanced.image-layers", LayersAllowImageLayers, bool, false);
|
||||
DECL_GFX_PREF(Live, "layers.advanced.outline-layers", LayersAllowOutlineLayers, bool, false);
|
||||
DECL_GFX_PREF(Live, "layers.advanced.text-layers", LayersAllowTextLayers, bool, false);
|
||||
DECL_GFX_PREF(Live, "layers.advanced.canvas-background-color", LayersAllowCanvasBackgroundColorLayers, 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);
|
||||
DECL_GFX_PREF(Once, "layers.async-pan-zoom.separate-event-thread", AsyncPanZoomSeparateEventThread, bool, false);
|
||||
|
|
|
@ -275,6 +275,10 @@ nsDisplayCanvasBackgroundColor::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (aManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) {
|
||||
return BuildDisplayItemLayer(aBuilder, aManager, aContainerParameters);
|
||||
}
|
||||
|
||||
RefPtr<ColorLayer> layer = static_cast<ColorLayer*>
|
||||
(aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, this));
|
||||
if (!layer) {
|
||||
|
@ -298,6 +302,27 @@ nsDisplayCanvasBackgroundColor::BuildLayer(nsDisplayListBuilder* aBuilder,
|
|||
return layer.forget();
|
||||
}
|
||||
|
||||
void
|
||||
nsDisplayCanvasBackgroundColor::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
|
||||
nsTArray<WebRenderParentCommand>& aParentCommands,
|
||||
WebRenderDisplayItemLayer* aLayer)
|
||||
{
|
||||
nsCanvasFrame* frame = static_cast<nsCanvasFrame*>(mFrame);
|
||||
nsPoint offset = ToReferenceFrame();
|
||||
nsRect bgClipRect = frame->CanvasArea() + offset;
|
||||
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
|
||||
Rect devPxRect(Float(bgClipRect.x / appUnitsPerDevPixel),
|
||||
Float(bgClipRect.y / appUnitsPerDevPixel),
|
||||
Float(bgClipRect.width / appUnitsPerDevPixel),
|
||||
Float(bgClipRect.height / appUnitsPerDevPixel));
|
||||
|
||||
Rect transformedRect = aLayer->RelativeToParent(devPxRect);
|
||||
aBuilder.PushRect(wr::ToWrRect(transformedRect),
|
||||
aBuilder.BuildClipRegion(wr::ToWrRect(transformedRect)),
|
||||
wr::ToWrColor(ToDeviceColor(mColor)));
|
||||
}
|
||||
|
||||
#ifdef MOZ_DUMP_PAINTING
|
||||
void
|
||||
nsDisplayCanvasBackgroundColor::WriteDebugInfo(std::stringstream& aStream)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "nsIScrollPositionListener.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsIAnonymousContentCreator.h"
|
||||
#include "gfxPrefs.h"
|
||||
|
||||
class nsPresContext;
|
||||
class nsRenderingContext;
|
||||
|
@ -161,19 +162,22 @@ public:
|
|||
// We need to override so we don't consider border-radius.
|
||||
aOutFrames->AppendElement(mFrame);
|
||||
}
|
||||
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerLayerParameters& aContainerParameters) override;
|
||||
virtual void CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
|
||||
nsTArray<WebRenderParentCommand>& aParentCommands,
|
||||
mozilla::layers::WebRenderDisplayItemLayer* aLayer) override;
|
||||
|
||||
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerLayerParameters& aParameters) override
|
||||
{
|
||||
if (ForceActiveLayers()) {
|
||||
if (ForceActiveLayers() || gfxPrefs::LayersAllowCanvasBackgroundColorLayers()) {
|
||||
return mozilla::LAYER_ACTIVE;
|
||||
}
|
||||
return mozilla::LAYER_NONE;
|
||||
}
|
||||
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
LayerManager* aManager,
|
||||
const ContainerLayerParameters& aContainerParameters) override;
|
||||
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
||||
nsRenderingContext* aCtx) override;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче