From 45b510c8d79959f25ac8851a360fdc1117f74fae Mon Sep 17 00:00:00 2001 From: Fedor Date: Sun, 7 Jan 2024 10:36:11 +0200 Subject: [PATCH] The switch to disable webrender build --- build/moz.configure/old.configure | 1 + dom/base/nsDOMWindowUtils.cpp | 64 ++- dom/base/nsDOMWindowUtils.h | 4 + dom/canvas/CanvasRenderingContext2D.cpp | 8 +- dom/canvas/CanvasRenderingContext2D.h | 2 + dom/canvas/WebGLContext.cpp | 18 +- dom/canvas/WebGLContext.h | 5 +- .../nsICanvasRenderingContextInternal.h | 6 + dom/html/HTMLCanvasElement.cpp | 12 +- dom/html/HTMLCanvasElement.h | 14 +- dom/ipc/BrowserChild.cpp | 51 ++- dom/ipc/BrowserChild.h | 10 +- dom/ipc/BrowserParent.cpp | 10 +- gfx/2d/2D.h | 13 +- gfx/2d/ScaledFontDWrite.cpp | 16 +- gfx/2d/ScaledFontDWrite.h | 4 + gfx/2d/ScaledFontFontconfig.cpp | 10 +- gfx/2d/ScaledFontFontconfig.h | 4 + gfx/2d/ScaledFontFreeType.cpp | 6 +- gfx/2d/ScaledFontFreeType.h | 2 + gfx/2d/ScaledFontMac.cpp | 6 +- gfx/2d/ScaledFontMac.h | 2 + gfx/2d/SourceSurfaceRawData.cpp | 7 +- gfx/2d/SourceSurfaceRawData.h | 8 +- gfx/2d/UnscaledFontDWrite.h | 2 + gfx/2d/UnscaledFontFreeType.h | 4 +- gfx/gl/GLContextEGL.h | 7 +- gfx/gl/GLContextGLX.h | 12 +- gfx/gl/GLContextProviderCGL.mm | 18 +- gfx/gl/GLContextProviderEAGL.mm | 21 +- gfx/gl/GLContextProviderEGL.cpp | 107 ++++- gfx/gl/GLContextProviderGLX.cpp | 50 ++- gfx/gl/GLContextProviderImpl.h | 7 +- gfx/gl/GLContextProviderNull.cpp | 11 +- gfx/gl/GLContextProviderWGL.cpp | 39 +- gfx/gl/GLContextProviderWayland.cpp | 35 +- gfx/gl/GLLibraryEGL.cpp | 29 +- gfx/ipc/CompositorOptions.h | 26 +- gfx/ipc/CompositorSession.cpp | 2 +- gfx/ipc/CompositorSession.h | 2 + gfx/ipc/GPUParent.cpp | 27 +- gfx/ipc/GPUProcessManager.cpp | 14 +- gfx/ipc/GPUProcessManager.h | 8 +- gfx/layers/AnimationHelper.cpp | 16 +- gfx/layers/AnimationHelper.h | 26 +- gfx/layers/AnimationInfo.cpp | 8 +- gfx/layers/CanvasRenderer.h | 5 + gfx/layers/D3D11YCbCrImage.cpp | 8 +- gfx/layers/ImageContainer.cpp | 8 +- gfx/layers/ImageContainer.h | 6 + gfx/layers/LayerMetricsWrapper.h | 6 + gfx/layers/Layers.cpp | 22 +- gfx/layers/Layers.h | 20 +- gfx/layers/LayersLogging.cpp | 12 +- gfx/layers/LayersLogging.h | 14 +- gfx/layers/ShareableCanvasRenderer.cpp | 27 +- gfx/layers/ShareableCanvasRenderer.h | 5 +- gfx/layers/SourceSurfaceSharedData.cpp | 22 +- gfx/layers/SourceSurfaceSharedData.h | 29 +- gfx/layers/SourceSurfaceVolatileData.cpp | 7 +- gfx/layers/SourceSurfaceVolatileData.h | 8 +- gfx/layers/UpdateImageHelper.h | 14 +- gfx/layers/apz/public/APZSampler.h | 22 +- gfx/layers/apz/public/APZUpdater.h | 107 ++++- gfx/layers/apz/public/CompositorController.h | 9 +- gfx/layers/apz/public/IAPZCTreeManager.h | 53 ++- gfx/layers/apz/src/APZCTreeManager.cpp | 275 +++++++++--- gfx/layers/apz/src/APZCTreeManager.h | 83 +++- gfx/layers/apz/src/APZSampler.cpp | 32 +- gfx/layers/apz/src/APZUpdater.cpp | 206 +++++++-- gfx/layers/apz/src/AsyncPanZoomController.cpp | 17 +- gfx/layers/apz/src/AsyncPanZoomController.h | 12 + gfx/layers/apz/src/FocusTarget.cpp | 6 +- gfx/layers/apz/src/FocusTarget.h | 12 +- gfx/layers/apz/src/HitTestingTreeNode.cpp | 14 +- gfx/layers/apz/src/HitTestingTreeNode.h | 11 +- gfx/layers/apz/test/gtest/APZCBasicTester.h | 5 + .../apz/test/gtest/APZCTreeManagerTester.h | 5 + gfx/layers/apz/util/APZCCallbackHelper.cpp | 40 +- gfx/layers/apz/util/APZCCallbackHelper.h | 11 +- .../apz/util/ChromeProcessController.cpp | 7 + gfx/layers/client/CanvasClient.cpp | 62 ++- gfx/layers/client/CanvasClient.h | 63 ++- gfx/layers/client/ClientImageLayer.cpp | 15 +- gfx/layers/client/ClientLayerManager.cpp | 4 + gfx/layers/client/CompositableClient.cpp | 22 +- gfx/layers/client/CompositableClient.h | 27 +- gfx/layers/client/ContentClient.cpp | 25 +- gfx/layers/client/ImageClient.cpp | 59 ++- gfx/layers/client/ImageClient.h | 32 +- gfx/layers/client/TextureClient.cpp | 17 +- gfx/layers/client/TextureClient.h | 8 +- gfx/layers/composite/CompositableHost.cpp | 27 +- gfx/layers/composite/CompositableHost.h | 13 +- gfx/layers/composite/GPUVideoTextureHost.cpp | 2 + gfx/layers/composite/GPUVideoTextureHost.h | 2 + gfx/layers/composite/TextureHost.cpp | 73 ++- gfx/layers/composite/TextureHost.h | 28 +- gfx/layers/d3d11/TextureD3D11.cpp | 22 +- gfx/layers/d3d11/TextureD3D11.h | 4 + gfx/layers/ipc/APZCTreeManagerChild.cpp | 46 +- gfx/layers/ipc/APZCTreeManagerChild.h | 48 +- gfx/layers/ipc/APZCTreeManagerParent.cpp | 141 +++++- gfx/layers/ipc/APZCTreeManagerParent.h | 69 ++- gfx/layers/ipc/CompositableForwarder.h | 16 +- .../ipc/CompositableTransactionParent.cpp | 27 +- .../ipc/CompositableTransactionParent.h | 13 +- gfx/layers/ipc/CompositorBridgeChild.cpp | 41 +- gfx/layers/ipc/CompositorBridgeChild.h | 16 +- gfx/layers/ipc/CompositorBridgeParent.cpp | 425 +++++++++++------- gfx/layers/ipc/CompositorBridgeParent.h | 182 ++++++-- gfx/layers/ipc/CompositorManagerChild.cpp | 2 + gfx/layers/ipc/CompositorManagerChild.h | 8 +- gfx/layers/ipc/CompositorManagerParent.cpp | 10 +- gfx/layers/ipc/CompositorManagerParent.h | 4 + .../ipc/ContentCompositorBridgeParent.cpp | 126 +++++- .../ipc/ContentCompositorBridgeParent.h | 62 ++- gfx/layers/ipc/ISurfaceAllocator.h | 2 + gfx/layers/ipc/ImageBridgeChild.cpp | 62 ++- gfx/layers/ipc/ImageBridgeChild.h | 34 +- gfx/layers/ipc/ImageBridgeParent.cpp | 24 +- gfx/layers/ipc/ImageBridgeParent.h | 8 +- gfx/layers/ipc/LayerTransactionParent.cpp | 65 ++- gfx/layers/ipc/LayerTransactionParent.h | 8 +- gfx/layers/ipc/LayersMessageUtils.h | 27 +- gfx/layers/ipc/PAPZCTreeManager.ipdl | 58 ++- gfx/layers/ipc/PCompositorBridge.ipdl | 20 +- gfx/layers/ipc/PCompositorManager.ipdl | 10 +- gfx/layers/ipc/PImageBridge.ipdl | 10 +- gfx/layers/ipc/PLayerTransaction.ipdl | 12 +- gfx/layers/ipc/ShadowLayers.cpp | 16 +- gfx/layers/ipc/ShadowLayers.h | 18 +- gfx/layers/ipc/TextureForwarder.h | 4 + gfx/layers/ipc/VideoBridgeChild.cpp | 5 +- gfx/layers/ipc/VideoBridgeChild.h | 2 + gfx/layers/ipc/VideoBridgeParent.cpp | 7 +- gfx/layers/moz.build | 129 +++--- gfx/layers/opengl/CompositorOGL.cpp | 8 +- .../opengl/MacIOSurfaceTextureHostOGL.cpp | 2 + .../opengl/MacIOSurfaceTextureHostOGL.h | 2 + gfx/layers/opengl/TextureHostOGL.cpp | 10 +- gfx/layers/opengl/TextureHostOGL.h | 8 +- gfx/moz.build | 5 +- gfx/thebes/DeviceManagerDx.cpp | 13 +- gfx/thebes/gfxContext.cpp | 6 +- gfx/thebes/gfxContext.h | 5 + gfx/thebes/gfxEnv.h | 2 + gfx/thebes/gfxFont.cpp | 99 +++- gfx/thebes/gfxFont.h | 10 +- gfx/thebes/gfxFontMissingGlyphs.cpp | 17 +- gfx/thebes/gfxPlatform.cpp | 116 +++-- gfx/thebes/gfxPlatform.h | 8 + gfx/thebes/gfxTextRun.cpp | 23 +- gfx/thebes/gfxUtils.cpp | 8 +- gfx/thebes/gfxUtils.h | 14 +- gfx/thebes/gfxWindowsPlatform.cpp | 10 + gfx/thebes/gfxWindowsPlatform.h | 4 +- image/Image.cpp | 6 +- image/Image.h | 13 +- image/RecyclingSourceSurface.h | 9 +- image/SurfaceCache.cpp | 2 + image/imgFrame.cpp | 23 +- image/imgFrame.h | 13 +- image/imgLoader.cpp | 114 ++++- image/imgRequest.cpp | 4 +- image/moz.build | 9 +- ipc/glue/ByteBufUtils.h | 69 +++ ipc/glue/IPCStreamChild.cpp | 4 +- ipc/glue/IPCStreamDestination.cpp | 2 +- ipc/glue/IPCStreamDestination.h | 7 +- ipc/glue/IPCStreamParent.cpp | 4 +- ipc/glue/IPCStreamSource.cpp | 4 +- ipc/glue/IPCStreamSource.h | 7 +- ipc/glue/PChildToParentStream.ipdl | 4 +- ipc/glue/PParentToChildStream.ipdl | 4 +- layout/base/PresShell.cpp | 18 +- layout/base/nsLayoutUtils.cpp | 19 +- layout/base/nsLayoutUtils.h | 8 + layout/forms/nsButtonFrameRenderer.cpp | 16 +- layout/forms/nsFieldSetFrame.cpp | 4 + layout/generic/TextOverflow.cpp | 8 +- layout/generic/moz.build | 3 +- layout/generic/nsBulletFrame.cpp | 24 +- layout/generic/nsCanvasFrame.cpp | 8 +- layout/generic/nsCanvasFrame.h | 2 + layout/generic/nsColumnSetFrame.cpp | 6 + layout/generic/nsFrame.cpp | 59 ++- layout/generic/nsGfxScrollFrame.cpp | 17 +- layout/generic/nsHTMLCanvasFrame.cpp | 12 +- layout/generic/nsHTMLCanvasFrame.h | 6 + layout/generic/nsIFrame.h | 2 + layout/generic/nsImageFrame.cpp | 18 +- layout/generic/nsImageFrame.h | 4 + layout/generic/nsPluginFrame.cpp | 12 +- layout/generic/nsPluginFrame.h | 12 +- layout/generic/nsTextFrame.cpp | 50 ++- layout/generic/nsTextFrame.h | 2 + layout/generic/nsVideoFrame.cpp | 6 +- layout/ipc/RenderFrame.cpp | 12 +- layout/ipc/RenderFrame.h | 2 + layout/mathml/nsMathMLmtableFrame.cpp | 2 + layout/painting/DisplayItemClip.cpp | 8 +- layout/painting/DisplayItemClip.h | 4 + layout/painting/FrameLayerBuilder.cpp | 13 +- layout/painting/nsCSSRendering.cpp | 40 +- layout/painting/nsCSSRendering.h | 19 +- layout/painting/nsCSSRenderingBorders.cpp | 12 +- layout/painting/nsCSSRenderingBorders.h | 6 + layout/painting/nsCSSRenderingGradients.cpp | 12 +- layout/painting/nsCSSRenderingGradients.h | 2 + layout/painting/nsDisplayItemTypesList.h | 2 + layout/painting/nsDisplayList.cpp | 131 +++++- layout/painting/nsDisplayList.h | 127 +++++- layout/painting/nsImageRenderer.cpp | 15 +- layout/painting/nsImageRenderer.h | 6 + layout/style/ImageLoader.cpp | 7 +- layout/style/nsStyleStruct.cpp | 2 + layout/style/nsStyleStruct.h | 6 +- layout/style/nsStyleStructInlines.h | 7 +- layout/svg/SVGObserverUtils.cpp | 7 +- layout/svg/nsFilterInstance.cpp | 3 +- layout/svg/nsFilterInstance.h | 6 +- layout/svg/nsSVGForeignObjectFrame.cpp | 2 + layout/svg/nsSVGIntegrationUtils.cpp | 15 +- layout/svg/nsSVGIntegrationUtils.h | 8 +- layout/tables/nsTableCellFrame.cpp | 2 + layout/tables/nsTableFrame.cpp | 37 +- layout/tables/nsTableFrame.h | 4 + layout/xul/nsBoxFrame.cpp | 27 +- layout/xul/nsImageBoxFrame.cpp | 12 +- layout/xul/nsImageBoxFrame.h | 4 + layout/xul/nsTextBoxFrame.cpp | 10 +- modules/libpref/init/StaticPrefList.yaml | 4 + modules/libpref/init/all.js | 2 + old-configure.in | 13 + toolkit/library/rust/gkrust-features.mozbuild | 7 +- toolkit/library/rust/shared/lib.rs | 9 + widget/PuppetWidget.cpp | 15 +- widget/PuppetWidget.h | 10 +- widget/android/nsWindow.cpp | 13 +- widget/android/nsWindow.h | 4 + widget/cocoa/nsChildView.h | 2 + widget/nsBaseWidget.cpp | 107 ++++- widget/nsBaseWidget.h | 29 +- widget/nsIWidget.h | 28 +- widget/windows/nsWindow.cpp | 75 ++-- widget/windows/nsWindow.h | 6 +- 247 files changed, 4758 insertions(+), 1278 deletions(-) diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure index d5c57f4f0f..930cbd362d 100644 --- a/build/moz.configure/old.configure +++ b/build/moz.configure/old.configure @@ -214,6 +214,7 @@ def old_configure_options(*options): '--enable-system-sqlite', '--enable-universalchardet', '--enable-updater', + '--enable-webrender', '--enable-xul', '--enable-zipwriter', '--includedir', diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 0780eeaf68..150f5e3cc5 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -105,8 +105,10 @@ #include "mozilla/gfx/GPUProcessManager.h" #include "mozilla/dom/TimeoutManager.h" #include "mozilla/PreloadedStyleSheet.h" -#include "mozilla/layers/WebRenderBridgeChild.h" -#include "mozilla/layers/WebRenderLayerManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderBridgeChild.h" +# include "mozilla/layers/WebRenderLayerManager.h" +#endif #include "mozilla/ResultExtensions.h" #ifdef XP_WIN @@ -244,6 +246,7 @@ LayerTransactionChild* nsDOMWindowUtils::GetLayerTransaction() { : nullptr; } +#ifdef MOZ_BUILD_WEBRENDER WebRenderBridgeChild* nsDOMWindowUtils::GetWebRenderBridge() { if (nsIWidget* widget = GetWidget()) { if (LayerManager* lm = widget->GetLayerManager()) { @@ -254,6 +257,7 @@ WebRenderBridgeChild* nsDOMWindowUtils::GetWebRenderBridge() { } return nullptr; } +#endif CompositorBridgeChild* nsDOMWindowUtils::GetCompositorBridge() { if (nsIWidget* widget = GetWidget()) { @@ -2131,8 +2135,11 @@ nsDOMWindowUtils::GetUsingAdvancedLayers(bool* retval) { NS_IMETHODIMP nsDOMWindowUtils::GetIsWebRenderRequested(bool* retval) { +#ifdef MOZ_BUILD_WEBRENDER + *retval = gfxPlatform::WebRenderPrefEnabled() || gfxPlatform::WebRenderEnvvarEnabled(); +#endif return NS_OK; } @@ -2242,8 +2249,10 @@ nsDOMWindowUtils::AdvanceTimeAndRefresh(int64_t aMilliseconds) { RefPtr transaction = GetLayerTransaction(); if (transaction && transaction->IPCOpen()) { transaction->SendSetTestSampleTime(driver->MostRecentRefresh()); +#ifdef MOZ_BUILD_WEBRENDER } else if (WebRenderBridgeChild* wrbc = GetWebRenderBridge()) { wrbc->SendSetTestSampleTime(driver->MostRecentRefresh()); +#endif } } @@ -2270,8 +2279,10 @@ nsDOMWindowUtils::RestoreNormalRefresh() { RefPtr transaction = GetLayerTransaction(); if (transaction && transaction->IPCOpen()) { transaction->SendLeaveTestMode(); +#ifdef MOZ_BUILD_WEBRENDER } else if (WebRenderBridgeChild* wrbc = GetWebRenderBridge()) { wrbc->SendLeaveTestMode(); +#endif } if (nsPresContext* pc = GetPresContext()) { @@ -2319,6 +2330,7 @@ nsDOMWindowUtils::SetAsyncScrollOffset(Element* aElement, float aX, float aY) { if (!manager) { return NS_ERROR_FAILURE; } +#ifdef MOZ_BUILD_WEBRENDER if (WebRenderLayerManager* wrlm = manager->AsWebRenderLayerManager()) { WebRenderBridgeChild* wrbc = wrlm->WrBridge(); if (!wrbc) { @@ -2327,6 +2339,7 @@ nsDOMWindowUtils::SetAsyncScrollOffset(Element* aElement, float aX, float aY) { wrbc->SendSetAsyncScrollOffset(viewId, aX, aY); return NS_OK; } +#endif ShadowLayerForwarder* forwarder = manager->AsShadowForwarder(); if (!forwarder || !forwarder->HasShadowManager()) { return NS_ERROR_UNEXPECTED; @@ -2352,6 +2365,7 @@ nsDOMWindowUtils::SetAsyncZoom(Element* aRootElement, float aValue) { if (!manager) { return NS_ERROR_FAILURE; } +#ifdef MOZ_BUILD_WEBRENDER if (WebRenderLayerManager* wrlm = manager->AsWebRenderLayerManager()) { WebRenderBridgeChild* wrbc = wrlm->WrBridge(); if (!wrbc) { @@ -2360,6 +2374,7 @@ nsDOMWindowUtils::SetAsyncZoom(Element* aRootElement, float aValue) { wrbc->SendSetAsyncZoom(viewId, aValue); return NS_OK; } +#endif ShadowLayerForwarder* forwarder = manager->AsShadowForwarder(); if (!forwarder || !forwarder->HasShadowManager()) { return NS_ERROR_UNEXPECTED; @@ -2385,6 +2400,7 @@ nsDOMWindowUtils::FlushApzRepaints(bool* aOutResult) { *aOutResult = false; return NS_OK; } +#ifdef MOZ_BUILD_WEBRENDER if (WebRenderLayerManager* wrlm = manager->AsWebRenderLayerManager()) { WebRenderBridgeChild* wrbc = wrlm->WrBridge(); if (!wrbc) { @@ -2394,6 +2410,7 @@ nsDOMWindowUtils::FlushApzRepaints(bool* aOutResult) { *aOutResult = true; return NS_OK; } +#endif ShadowLayerForwarder* forwarder = manager->AsShadowForwarder(); if (!forwarder || !forwarder->HasShadowManager()) { *aOutResult = false; @@ -3372,8 +3389,12 @@ static Result GetTargetFrame( return frame; } -static OMTAValue GetOMTAValue(nsIFrame* aFrame, DisplayItemType aDisplayItemKey, - WebRenderBridgeChild* aWebRenderBridgeChild) { +static OMTAValue GetOMTAValue(nsIFrame* aFrame, DisplayItemType aDisplayItemKey +#ifdef MOZ_BUILD_WEBRENDER + , + WebRenderBridgeChild* aWebRenderBridgeChild +#endif +) { OMTAValue value = mozilla::null_t(); Layer* layer = FrameLayerBuilder::GetDedicatedLayer(aFrame, aDisplayItemKey); @@ -3383,6 +3404,7 @@ static OMTAValue GetOMTAValue(nsIFrame* aFrame, DisplayItemType aDisplayItemKey, forwarder->GetShadowManager()->SendGetAnimationValue( layer->GetCompositorAnimationsId(), &value); } +#ifdef MOZ_BUILD_WEBRENDER } else if (aWebRenderBridgeChild) { RefPtr animationData = GetWebRenderUserData(aFrame, @@ -3392,6 +3414,7 @@ static OMTAValue GetOMTAValue(nsIFrame* aFrame, DisplayItemType aDisplayItemKey, animationData->GetAnimationInfo().GetCompositorAnimationsId(), &value); } +#endif } return value; } @@ -3418,8 +3441,12 @@ nsDOMWindowUtils::GetOMTAStyle(Element* aElement, const nsAString& aProperty, } if (aProperty.EqualsLiteral("opacity")) { - OMTAValue value = GetOMTAValue(frame, DisplayItemType::TYPE_OPACITY, - GetWebRenderBridge()); + OMTAValue value = GetOMTAValue(frame, DisplayItemType::TYPE_OPACITY +#ifdef MOZ_BUILD_WEBRENDER + , + GetWebRenderBridge() +#endif + ); if (value.type() == OMTAValue::Tfloat) { cssValue = new nsROCSSPrimitiveValue; cssValue->SetNumber(value.get_float()); @@ -3432,14 +3459,23 @@ nsDOMWindowUtils::GetOMTAStyle(Element* aElement, const nsAString& aProperty, aProperty.EqualsLiteral("offset-distance") || aProperty.EqualsLiteral("offset-rotate") || aProperty.EqualsLiteral("offset-anchor")) { - OMTAValue value = GetOMTAValue(frame, DisplayItemType::TYPE_TRANSFORM, - GetWebRenderBridge()); + OMTAValue value = GetOMTAValue(frame, DisplayItemType::TYPE_TRANSFORM +#ifdef MOZ_BUILD_WEBRENDER + , + GetWebRenderBridge() +#endif + ); if (value.type() == OMTAValue::TMatrix4x4) { cssValue = nsComputedDOMStyle::MatrixToCSSValue(value.get_Matrix4x4()); } } else if (aProperty.EqualsLiteral("background-color")) { - OMTAValue value = GetOMTAValue( - frame, DisplayItemType::TYPE_BACKGROUND_COLOR, GetWebRenderBridge()); + OMTAValue value = + GetOMTAValue(frame, DisplayItemType::TYPE_BACKGROUND_COLOR +#ifdef MOZ_BUILD_WEBRENDER + , + GetWebRenderBridge() +#endif + ); if (value.type() == OMTAValue::Tnscolor) { cssValue = new nsROCSSPrimitiveValue; nsComputedDOMStyle::SetToRGBAColor(cssValue, value.get_nscolor()); @@ -3466,9 +3502,11 @@ nsDOMWindowUtils::GetOMTCTransform(Element* aElement, return NS_ERROR_INVALID_ARG; } +#ifdef MOZ_BUILD_WEBRENDER if (GetWebRenderBridge()) { return NS_ERROR_NOT_IMPLEMENTED; } +#endif auto frameOrError = GetTargetFrame(aElement, aPseudoElement); if (frameOrError.isErr()) { @@ -3615,10 +3653,12 @@ nsDOMWindowUtils::GetContentAPZTestData( if (!clm->GetAPZTestData().ToJS(aOutContentTestData, aContext)) { return NS_ERROR_FAILURE; } +#ifdef MOZ_BUILD_WEBRENDER } else if (WebRenderLayerManager* wrlm = lm->AsWebRenderLayerManager()) { if (!wrlm->GetAPZTestData().ToJS(aOutContentTestData, aContext)) { return NS_ERROR_FAILURE; } +#endif } } @@ -3636,6 +3676,7 @@ nsDOMWindowUtils::GetCompositorAPZTestData( APZTestData compositorSideData; if (ClientLayerManager* clm = lm->AsClientLayerManager()) { clm->GetCompositorSideAPZTestData(&compositorSideData); +#ifdef MOZ_BUILD_WEBRENDER } else if (WebRenderLayerManager* wrlm = lm->AsWebRenderLayerManager()) { if (!wrlm->WrBridge()) { return NS_ERROR_UNEXPECTED; @@ -3643,6 +3684,7 @@ nsDOMWindowUtils::GetCompositorAPZTestData( if (!wrlm->WrBridge()->SendGetAPZTestData(&compositorSideData)) { return NS_ERROR_FAILURE; } +#endif } if (!compositorSideData.ToJS(aOutCompositorTestData, aContext)) { return NS_ERROR_FAILURE; @@ -4066,9 +4108,11 @@ nsTranslationNodeList::GetLength(uint32_t* aRetVal) { NS_IMETHODIMP nsDOMWindowUtils::WrCapture() { +#ifdef MOZ_BUILD_WEBRENDER if (WebRenderBridgeChild* wrbc = GetWebRenderBridge()) { wrbc->Capture(); } +#endif return NS_OK; } diff --git a/dom/base/nsDOMWindowUtils.h b/dom/base/nsDOMWindowUtils.h index bfe1fc5826..09ba643f00 100644 --- a/dom/base/nsDOMWindowUtils.h +++ b/dom/base/nsDOMWindowUtils.h @@ -25,7 +25,9 @@ class Element; } // namespace dom namespace layers { class LayerTransactionChild; +#ifdef MOZ_BUILD_WEBRENDER class WebRenderBridgeChild; +#endif } // namespace layers } // namespace mozilla @@ -79,7 +81,9 @@ class nsDOMWindowUtils final : public nsIDOMWindowUtils, nsPresContext* GetPresContext(); mozilla::dom::Document* GetDocument(); mozilla::layers::LayerTransactionChild* GetLayerTransaction(); +#ifdef MOZ_BUILD_WEBRENDER mozilla::layers::WebRenderBridgeChild* GetWebRenderBridge(); +#endif mozilla::layers::CompositorBridgeChild* GetCompositorBridge(); // Until callers are annotated. diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 65c751452d..003e9bb443 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -118,8 +118,10 @@ #include "mozilla/ServoStyleSet.h" #include "mozilla/SVGContentUtils.h" #include "mozilla/layers/CanvasClient.h" -#include "mozilla/layers/WebRenderUserData.h" -#include "mozilla/layers/WebRenderCanvasRenderer.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderUserData.h" +# include "mozilla/layers/WebRenderCanvasRenderer.h" +#endif #undef free // apparently defined by some windows header, clashing with a // free() method in SkTypes.h @@ -5312,6 +5314,7 @@ already_AddRefed CanvasRenderingContext2D::GetCanvasLayer( return canvasLayer.forget(); } +#ifdef MOZ_BUILD_WEBRENDER bool CanvasRenderingContext2D::UpdateWebRenderCanvasData( nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) { if (mOpaque) { @@ -5356,6 +5359,7 @@ bool CanvasRenderingContext2D::UpdateWebRenderCanvasData( mResetLayer = false; return true; } +#endif bool CanvasRenderingContext2D::InitializeCanvasRenderer( nsDisplayListBuilder* aBuilder, CanvasRenderer* aRenderer) { diff --git a/dom/canvas/CanvasRenderingContext2D.h b/dom/canvas/CanvasRenderingContext2D.h index 3cd4a39b2d..8c262adaaf 100644 --- a/dom/canvas/CanvasRenderingContext2D.h +++ b/dom/canvas/CanvasRenderingContext2D.h @@ -431,8 +431,10 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal, Layer* aOldLayer, LayerManager* aManager) override; +#ifdef MOZ_BUILD_WEBRENDER bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) override; +#endif bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder, CanvasRenderer* aRenderer) override; diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index e7138ebab1..a3cd9022df 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -51,8 +51,10 @@ #endif #include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/TextureClientSharedSurface.h" -#include "mozilla/layers/WebRenderUserData.h" -#include "mozilla/layers/WebRenderCanvasRenderer.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderUserData.h" +# include "mozilla/layers/WebRenderCanvasRenderer.h" +#endif // Local #include "CanvasUtils.h" @@ -1169,6 +1171,7 @@ already_AddRefed WebGLContext::GetCanvasLayer( return canvasLayer.forget(); } +#ifdef MOZ_BUILD_WEBRENDER bool WebGLContext::UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) { CanvasRenderer* renderer = aCanvasData->GetCanvasRenderer(); @@ -1188,6 +1191,7 @@ bool WebGLContext::UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder, mResetLayer = false; return true; } +#endif bool WebGLContext::InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder, CanvasRenderer* aRenderer) { @@ -2123,7 +2127,7 @@ CheckedUint32 WebGLContext::GetUnpackSize(bool isFunc3D, uint32_t width, } #ifdef MOZ_VR -#if defined(MOZ_WIDGET_ANDROID) +# if defined(MOZ_WIDGET_ANDROID) already_AddRefed WebGLContext::GetVRFrame() { if (!gl) return nullptr; @@ -2163,7 +2167,7 @@ WebGLContext::GetVRFrame() { return sharedSurface.forget(); } -#else +# else already_AddRefed WebGLContext::GetVRFrame() { if (!gl) return nullptr; @@ -2186,7 +2190,7 @@ WebGLContext::GetVRFrame() { return sharedSurface.forget(); } -#endif // ifdefined(MOZ_WIDGET_ANDROID) +# endif // ifdefined(MOZ_WIDGET_ANDROID) void WebGLContext::EnsureVRReady() { if (mVRReady) { @@ -2208,12 +2212,12 @@ void WebGLContext::EnsureVRReady() { auto factory = gl::GLScreenBuffer::CreateFactory(gl, caps, imageBridge.get(), flags); gl->Screen()->Morph(std::move(factory)); -#if defined(MOZ_WIDGET_ANDROID) +# if defined(MOZ_WIDGET_ANDROID) // On Android we are using a different GLScreenBuffer for WebVR, so we need // a resize here because PresentScreenBuffer() may not be called for the // gl->Screen() after we set the new factory. gl->Screen()->Resize(DrawingBufferSize()); -#endif +# endif mVRReady = true; } } diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h index 8b3ce226a5..66e8e2c914 100644 --- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -480,8 +480,10 @@ class WebGLContext : public nsICanvasRenderingContextInternal, Layer* oldLayer, LayerManager* manager) override; +#ifdef MOZ_BUILD_WEBRENDER bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) override; +#endif bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder, CanvasRenderer* aRenderer) override; @@ -798,8 +800,7 @@ class WebGLContext : public nsICanvasRenderingContextInternal, public: explicit Arr(const viewT& view) - : elemCount(ComputeAndReturnLength(view)), - elemBytes(view.Data()) {} + : elemCount(ComputeAndReturnLength(view)), elemBytes(view.Data()) {} explicit Arr(const dom::Sequence& seq) : elemCount(seq.Length()), elemBytes(seq.Elements()) {} diff --git a/dom/canvas/nsICanvasRenderingContextInternal.h b/dom/canvas/nsICanvasRenderingContextInternal.h index 5c6edf376d..76b25a0e52 100644 --- a/dom/canvas/nsICanvasRenderingContextInternal.h +++ b/dom/canvas/nsICanvasRenderingContextInternal.h @@ -33,7 +33,9 @@ class CanvasLayer; class CanvasRenderer; class Layer; class LayerManager; +#ifdef MOZ_BUILD_WEBRENDER class WebRenderCanvasData; +#endif } // namespace layers namespace gfx { class SourceSurface; @@ -47,7 +49,9 @@ class nsICanvasRenderingContextInternal : public nsISupports, typedef mozilla::layers::CanvasRenderer CanvasRenderer; typedef mozilla::layers::Layer Layer; typedef mozilla::layers::LayerManager LayerManager; +#ifdef MOZ_BUILD_WEBRENDER typedef mozilla::layers::WebRenderCanvasData WebRenderCanvasData; +#endif NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASRENDERINGCONTEXTINTERNAL_IID) @@ -144,10 +148,12 @@ class nsICanvasRenderingContextInternal : public nsISupports, virtual already_AddRefed GetCanvasLayer(nsDisplayListBuilder* builder, Layer* oldLayer, LayerManager* manager) = 0; +#ifdef MOZ_BUILD_WEBRENDER virtual bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) { return false; } +#endif virtual bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder, CanvasRenderer* aRenderer) { return true; diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 9d31384ee4..d010b75297 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -24,8 +24,10 @@ #include "mozilla/EventDispatcher.h" #include "mozilla/gfx/Rect.h" #include "mozilla/layers/AsyncCanvasRenderer.h" -#include "mozilla/layers/WebRenderCanvasRenderer.h" -#include "mozilla/layers/WebRenderUserData.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderCanvasRenderer.h" +# include "mozilla/layers/WebRenderUserData.h" +#endif #include "mozilla/MouseEvents.h" #include "mozilla/Preferences.h" #include "mozilla/Telemetry.h" @@ -994,6 +996,7 @@ void HTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect) { ActiveLayerTracker::NotifyContentChange(frame); +#ifdef MOZ_BUILD_WEBRENDER // When using layers-free WebRender, we cannot invalidate the layer (because // there isn't one). Instead, we mark the CanvasRenderer dirty and scheduling // an empty transaction which is effectively equivalent. @@ -1008,6 +1011,7 @@ void HTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect) { renderer->SetDirty(); frame->SchedulePaint(nsIFrame::PAINT_COMPOSITE_ONLY); } else { +#endif Layer* layer = nullptr; if (damageRect) { nsIntSize size = GetWidthHeight(); @@ -1023,7 +1027,9 @@ void HTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect) { if (layer) { static_cast(layer)->Updated(); } +#ifdef MOZ_BUILD_WEBRENDER } +#endif /* * Treat canvas invalidations as animation activity for JS. Frequently @@ -1114,6 +1120,7 @@ already_AddRefed HTMLCanvasElement::GetCanvasLayer( return nullptr; } +#ifdef MOZ_BUILD_WEBRENDER bool HTMLCanvasElement::UpdateWebRenderCanvasData( nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) { if (mCurrentContext) { @@ -1142,6 +1149,7 @@ bool HTMLCanvasElement::UpdateWebRenderCanvasData( aCanvasData->ClearCanvasRenderer(); return false; } +#endif bool HTMLCanvasElement::InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder, CanvasRenderer* aRenderer) { diff --git a/dom/html/HTMLCanvasElement.h b/dom/html/HTMLCanvasElement.h index ea7d20b212..4d6f345961 100644 --- a/dom/html/HTMLCanvasElement.h +++ b/dom/html/HTMLCanvasElement.h @@ -33,13 +33,15 @@ class Image; class Layer; class LayerManager; class SharedSurfaceTextureClient; +# ifdef MOZ_BUILD_WEBRENDER class WebRenderCanvasData; +# endif } // namespace layers namespace gfx { class SourceSurface; -#ifdef MOZ_VR +# ifdef MOZ_VR class VRLayerChild; -#endif +# endif } // namespace gfx namespace dom { @@ -121,7 +123,9 @@ class HTMLCanvasElement final : public nsGenericHTMLElement, typedef layers::CanvasLayer CanvasLayer; typedef layers::Layer Layer; typedef layers::LayerManager LayerManager; +# ifdef MOZ_BUILD_WEBRENDER typedef layers::WebRenderCanvasData WebRenderCanvasData; +# endif public: explicit HTMLCanvasElement( @@ -295,8 +299,10 @@ class HTMLCanvasElement final : public nsGenericHTMLElement, already_AddRefed GetCanvasLayer(nsDisplayListBuilder* aBuilder, Layer* aOldLayer, LayerManager* aManager); +# ifdef MOZ_BUILD_WEBRENDER bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData); +# endif bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder, CanvasRenderer* aRenderer); // Should return true if the canvas layer should always be marked inactive. @@ -328,9 +334,9 @@ class HTMLCanvasElement final : public nsGenericHTMLElement, static void SetAttrFromAsyncCanvasRenderer(AsyncCanvasRenderer* aRenderer); static void InvalidateFromAsyncCanvasRenderer(AsyncCanvasRenderer* aRenderer); -#ifdef MOZ_VR +# ifdef MOZ_VR already_AddRefed GetVRFrame(); -#endif +# endif bool MaybeModified() const { return mMaybeModified; }; diff --git a/dom/ipc/BrowserChild.cpp b/dom/ipc/BrowserChild.cpp index 2ae4651984..67cca79621 100644 --- a/dom/ipc/BrowserChild.cpp +++ b/dom/ipc/BrowserChild.cpp @@ -44,7 +44,9 @@ #include "mozilla/layers/InputAPZContext.h" #include "mozilla/layers/LayerTransactionChild.h" #include "mozilla/layers/ShadowLayers.h" -#include "mozilla/layers/WebRenderLayerManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderLayerManager.h" +#endif #include "mozilla/plugins/PPluginWidgetChild.h" #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" @@ -467,9 +469,13 @@ void BrowserChild::ContentReceivedInputBlock(uint64_t aInputBlockId, } } -void BrowserChild::SetTargetAPZC( - uint64_t aInputBlockId, - const nsTArray& aTargets) const { +void BrowserChild::SetTargetAPZC(uint64_t aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif +) const { if (mApzcTreeManager) { mApzcTreeManager->SetTargetAPZC(aInputBlockId, aTargets); } @@ -490,8 +496,13 @@ bool BrowserChild::DoUpdateZoomConstraints( return false; } +#ifdef MOZ_BUILD_WEBRENDER SLGuidAndRenderRoot guid = SLGuidAndRenderRoot( mLayersId, aPresShellId, aViewId, gfxUtils::GetContentRenderRoot()); +#else + ScrollableLayerGuid guid = + ScrollableLayerGuid(mLayersId, aPresShellId, aViewId); +#endif mApzcTreeManager->UpdateZoomConstraints(guid, aConstraints); return true; @@ -1294,8 +1305,12 @@ void BrowserChild::HandleDoubleTap(const CSSPoint& aPoint, if (APZCCallbackHelper::GetOrCreateScrollIdentifiers( document->GetDocumentElement(), &presShellId, &viewId) && mApzcTreeManager) { +#ifdef MOZ_BUILD_WEBRENDER SLGuidAndRenderRoot guid(mLayersId, presShellId, viewId, gfxUtils::GetContentRenderRoot()); +#else + ScrollableLayerGuid guid(mLayersId, presShellId, viewId); +#endif mApzcTreeManager->ZoomToRect(guid, zoomToRect, DEFAULT_BEHAVIOR); } @@ -1381,9 +1396,14 @@ bool BrowserChild::NotifyAPZStateChange( void BrowserChild::StartScrollbarDrag( const layers::AsyncDragMetrics& aDragMetrics) { +#ifdef MOZ_BUILD_WEBRENDER SLGuidAndRenderRoot guid(mLayersId, aDragMetrics.mPresShellId, aDragMetrics.mViewId, gfxUtils::GetContentRenderRoot()); +#else + ScrollableLayerGuid guid(mLayersId, aDragMetrics.mPresShellId, + aDragMetrics.mViewId); +#endif if (mApzcTreeManager) { mApzcTreeManager->StartScrollbarDrag(guid, aDragMetrics); @@ -1393,8 +1413,12 @@ void BrowserChild::StartScrollbarDrag( void BrowserChild::ZoomToRect(const uint32_t& aPresShellId, const ScrollableLayerGuid::ViewID& aViewId, const CSSRect& aRect, const uint32_t& aFlags) { +#ifdef MOZ_BUILD_WEBRENDER SLGuidAndRenderRoot guid(mLayersId, aPresShellId, aViewId, gfxUtils::GetContentRenderRoot()); +#else + ScrollableLayerGuid guid(mLayersId, aPresShellId, aViewId); +#endif if (mApzcTreeManager) { mApzcTreeManager->ZoomToRect(guid, aRect, aFlags); @@ -2674,6 +2698,7 @@ bool BrowserChild::CreateRemoteLayerManager( MOZ_ASSERT(aCompositorChild); bool success = false; +#ifdef MOZ_BUILD_WEBRENDER if (mCompositorOptions->UseWebRender()) { success = mPuppetWidget->CreateRemoteLayerManager( [&](LayerManager* aLayerManager) -> bool { @@ -2683,6 +2708,7 @@ bool BrowserChild::CreateRemoteLayerManager( &mTextureFactoryIdentifier); }); } else { +#endif nsTArray ignored; PLayerTransactionChild* shadowManager = aCompositorChild->SendPLayerTransactionConstructor(ignored, @@ -2715,7 +2741,9 @@ bool BrowserChild::CreateRemoteLayerManager( return true; }); } +#ifdef MOZ_BUILD_WEBRENDER } +#endif return success; } @@ -3043,9 +3071,12 @@ void BrowserChild::ReinitRenderingForDeviceReset() { InvalidateLayers(); RefPtr lm = mPuppetWidget->GetLayerManager(); +#ifdef MOZ_BUILD_WEBRENDER if (WebRenderLayerManager* wlm = lm->AsWebRenderLayerManager()) { wlm->DoDestroy(/* aIsSync */ true); - } else if (ClientLayerManager* clm = lm->AsClientLayerManager()) { + } else +#endif + if (ClientLayerManager* clm = lm->AsClientLayerManager()) { if (ShadowLayerForwarder* fwd = clm->AsShadowForwarder()) { // Force the LayerTransactionChild to synchronously shutdown. It is // okay to do this early, we'll simply stop sending messages. This @@ -3557,9 +3588,9 @@ NS_IMETHODIMP BrowserChild::OnLocationChange(nsIWebProgress* aWebProgress, locationChangeData->mayEnableCharacterEncodingMenu() = docShell->GetMayEnableCharacterEncodingMenu(); -//1543077 -// locationChangeData->charsetAutodetected() = -// docShell->GetCharsetAutodetected(); + // 1543077 + // locationChangeData->charsetAutodetected() = + // docShell->GetCharsetAutodetected(); locationChangeData->contentPrincipal() = document->NodePrincipal(); locationChangeData->contentStoragePrincipal() = @@ -3567,8 +3598,8 @@ NS_IMETHODIMP BrowserChild::OnLocationChange(nsIWebProgress* aWebProgress, locationChangeData->csp() = document->GetCsp(); locationChangeData->contentBlockingAllowListPrincipal() = document->GetContentBlockingAllowListPrincipal(); -//1534681 -// locationChangeData->referrerInfo() = document->ReferrerInfo(); + // 1534681 + // locationChangeData->referrerInfo() = document->ReferrerInfo(); locationChangeData->isSyntheticDocument() = document->IsSyntheticDocument(); if (nsCOMPtr loadGroup = document->GetDocumentLoadGroup()) { diff --git a/dom/ipc/BrowserChild.h b/dom/ipc/BrowserChild.h index 3d39d43b5b..020b4ba552 100644 --- a/dom/ipc/BrowserChild.h +++ b/dom/ipc/BrowserChild.h @@ -581,9 +581,13 @@ class BrowserChild final : public BrowserChildBase, void ContentReceivedInputBlock(uint64_t aInputBlockId, bool aPreventDefault) const; - void SetTargetAPZC( - uint64_t aInputBlockId, - const nsTArray& aTargets) const; + void SetTargetAPZC(uint64_t aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) const; MOZ_CAN_RUN_SCRIPT_BOUNDARY mozilla::ipc::IPCResult RecvHandleTap( const layers::GeckoContentController::TapType& aType, diff --git a/dom/ipc/BrowserParent.cpp b/dom/ipc/BrowserParent.cpp index bd03412307..973a173329 100644 --- a/dom/ipc/BrowserParent.cpp +++ b/dom/ipc/BrowserParent.cpp @@ -129,9 +129,9 @@ using namespace mozilla::widget; using namespace mozilla::jsipc; using namespace mozilla::gfx; -using mozilla::Unused; using mozilla::LazyLogModule; using mozilla::StaticAutoPtr; +using mozilla::Unused; LazyLogModule gBrowserFocusLog("BrowserFocus"); @@ -3811,8 +3811,12 @@ BrowserParent::StartApzAutoscroll(float aAnchorX, float aAnchorY, if (mRenderFrame.IsInitialized()) { layers::LayersId layersId = mRenderFrame.GetLayersId(); if (nsCOMPtr widget = GetWidget()) { +#ifdef MOZ_BUILD_WEBRENDER SLGuidAndRenderRoot guid(layersId, aPresShellId, aScrollId, gfxUtils::GetContentRenderRoot()); +#else + ScrollableLayerGuid guid(layersId, aPresShellId, aScrollId); +#endif // The anchor coordinates that are passed in are relative to the origin // of the screen, but we are sending them to APZ which only knows about @@ -3841,8 +3845,12 @@ BrowserParent::StopApzAutoscroll(nsViewID aScrollId, uint32_t aPresShellId) { if (mRenderFrame.IsInitialized()) { layers::LayersId layersId = mRenderFrame.GetLayersId(); if (nsCOMPtr widget = GetWidget()) { +#ifdef MOZ_BUILD_WEBRENDER SLGuidAndRenderRoot guid(layersId, aPresShellId, aScrollId, gfxUtils::GetContentRenderRoot()); +#else + ScrollableLayerGuid guid(layersId, aPresShellId, aScrollId); +#endif widget->StopAsyncAutoscroll(guid); } diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index cd67b3b21a..a8aa70b692 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -537,8 +537,13 @@ class DataSourceSurface : public SourceSurface { virtual void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const {} + size_t& aExtHandlesOut +#ifdef MOZ_BUILD_WEBRENDER + , + uint64_t& aExtIdOut +#endif + ) const { + } /** * Returns whether or not the data was allocated on the heap. This should @@ -776,6 +781,7 @@ class UnscaledFont : public SupportsThreadSafeWeakPtr { return nullptr; } +#ifdef MOZ_BUILD_WEBRENDER virtual already_AddRefed CreateScaledFontFromWRFont( Float aGlyphSize, const wr::FontInstanceOptions* aOptions, const wr::FontInstancePlatformOptions* aPlatformOptions, @@ -783,6 +789,7 @@ class UnscaledFont : public SupportsThreadSafeWeakPtr { return CreateScaledFont(aGlyphSize, nullptr, 0, aVariations, aNumVariations); } +#endif protected: UnscaledFont() {} @@ -839,12 +846,14 @@ class ScaledFont : public SupportsThreadSafeWeakPtr { return false; } +#ifdef MOZ_BUILD_WEBRENDER virtual bool GetWRFontInstanceOptions( Maybe* aOutOptions, Maybe* aOutPlatformOptions, std::vector* aOutVariations) { return false; } +#endif virtual bool CanSerialize() { return false; } diff --git a/gfx/2d/ScaledFontDWrite.cpp b/gfx/2d/ScaledFontDWrite.cpp index fe3363c091..2f1b36702b 100644 --- a/gfx/2d/ScaledFontDWrite.cpp +++ b/gfx/2d/ScaledFontDWrite.cpp @@ -8,7 +8,9 @@ #include "gfxFont.h" #include "Logging.h" #include "mozilla/FontPropertyTypes.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "HelpersD2D.h" #ifdef USE_SKIA @@ -287,7 +289,8 @@ bool UnscaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback, } RefPtr stream; - hr = loader->CreateStreamFromKey(referenceKey, refKeySize, getter_AddRefs(stream)); + hr = loader->CreateStreamFromKey(referenceKey, refKeySize, + getter_AddRefs(stream)); if (FAILED(hr)) { return false; } @@ -315,6 +318,7 @@ bool UnscaledFontDWrite::GetFontFileData(FontFileDataOutput aDataCallback, return true; } +#ifdef MOZ_BUILD_WEBRENDER static bool GetFontFileName(RefPtr aFontFace, std::vector& aFileName) { UINT32 numFiles; @@ -417,15 +421,18 @@ ScaledFontDWrite::InstanceData::InstanceData( mContrast = aPlatformOptions->contrast / 100.0f; } } +#endif bool ScaledFontDWrite::GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) { InstanceData instance(this); - aCb(reinterpret_cast(&instance), sizeof(instance), nullptr, 0, aBaton); + aCb(reinterpret_cast(&instance), sizeof(instance), nullptr, 0, + aBaton); return true; } +#ifdef MOZ_BUILD_WEBRENDER bool ScaledFontDWrite::GetWRFontInstanceOptions( Maybe* aOutOptions, Maybe* aOutPlatformOptions, @@ -471,6 +478,7 @@ bool ScaledFontDWrite::GetWRFontInstanceOptions( *aOutPlatformOptions = Some(platformOptions); return true; } +#endif already_AddRefed UnscaledFontDWrite::CreateScaledFont( Float aGlyphSize, const uint8_t* aInstanceData, @@ -496,6 +504,7 @@ already_AddRefed UnscaledFontDWrite::CreateScaledFont( return scaledFont.forget(); } +#ifdef MOZ_BUILD_WEBRENDER already_AddRefed UnscaledFontDWrite::CreateScaledFontFromWRFont( Float aGlyphSize, const wr::FontInstanceOptions* aOptions, const wr::FontInstancePlatformOptions* aPlatformOptions, @@ -504,6 +513,7 @@ already_AddRefed UnscaledFontDWrite::CreateScaledFontFromWRFont( return CreateScaledFont(aGlyphSize, reinterpret_cast(&instanceData), sizeof(instanceData), aVariations, aNumVariations); } +#endif AntialiasMode ScaledFontDWrite::GetDefaultAAMode() { AntialiasMode defaultMode = GetSystemDefaultAAMode(); diff --git a/gfx/2d/ScaledFontDWrite.h b/gfx/2d/ScaledFontDWrite.h index 56df0ee50a..9241bec174 100644 --- a/gfx/2d/ScaledFontDWrite.h +++ b/gfx/2d/ScaledFontDWrite.h @@ -53,10 +53,12 @@ class ScaledFontDWrite final : public ScaledFontBase { bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override; +#ifdef MOZ_BUILD_WEBRENDER bool GetWRFontInstanceOptions( Maybe* aOutOptions, Maybe* aOutPlatformOptions, std::vector* aOutVariations) override; +#endif AntialiasMode GetDefaultAAMode() override; @@ -100,8 +102,10 @@ class ScaledFontDWrite final : public ScaledFontBase { mGamma(aScaledFont->mGamma), mContrast(aScaledFont->mContrast) {} +#ifdef MOZ_BUILD_WEBRENDER InstanceData(const wr::FontInstanceOptions* aOptions, const wr::FontInstancePlatformOptions* aPlatformOptions); +#endif bool mUseEmbeddedBitmap; DWRITE_RENDERING_MODE mRenderingMode; diff --git a/gfx/2d/ScaledFontFontconfig.cpp b/gfx/2d/ScaledFontFontconfig.cpp index 9a7889587d..488b8ac555 100644 --- a/gfx/2d/ScaledFontFontconfig.cpp +++ b/gfx/2d/ScaledFontFontconfig.cpp @@ -7,7 +7,9 @@ #include "NativeFontResourceFreeType.h" #include "Logging.h" #include "StackArray.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #ifdef USE_SKIA # include "skia/include/ports/SkTypeface_cairo.h" @@ -110,6 +112,7 @@ ScaledFontFontconfig::InstanceData::InstanceData( cairo_font_options_destroy(fontOptions); } +#ifdef MOZ_BUILD_WEBRENDER ScaledFontFontconfig::InstanceData::InstanceData( const wr::FontInstanceOptions* aOptions, const wr::FontInstancePlatformOptions* aPlatformOptions) @@ -174,6 +177,7 @@ ScaledFontFontconfig::InstanceData::InstanceData( } } } +#endif void ScaledFontFontconfig::InstanceData::SetupPattern( FcPattern* aPattern) const { @@ -293,6 +297,7 @@ bool ScaledFontFontconfig::GetFontInstanceData(FontInstanceDataOutput aCb, return true; } +#ifdef MOZ_BUILD_WEBRENDER bool ScaledFontFontconfig::GetWRFontInstanceOptions( Maybe* aOutOptions, Maybe* aOutPlatformOptions, @@ -430,6 +435,7 @@ bool ScaledFontFontconfig::GetWRFontInstanceOptions( return true; } +#endif // MOZ_BUILD_WEBRENDER static cairo_user_data_key_t sNativeFontResourceKey; @@ -561,6 +567,7 @@ already_AddRefed UnscaledFontFontconfig::CreateScaledFont( return scaledFont.forget(); } +#ifdef MOZ_BUILD_WEBRENDER already_AddRefed UnscaledFontFontconfig::CreateScaledFontFromWRFont( Float aGlyphSize, const wr::FontInstanceOptions* aOptions, const wr::FontInstancePlatformOptions* aPlatformOptions, @@ -569,6 +576,7 @@ already_AddRefed UnscaledFontFontconfig::CreateScaledFontFromWRFont( return CreateScaledFont(aGlyphSize, reinterpret_cast(&instanceData), sizeof(instanceData), aVariations, aNumVariations); } +#endif bool ScaledFontFontconfig::HasVariationSettings() { // Check if the FT face has been cloned. diff --git a/gfx/2d/ScaledFontFontconfig.h b/gfx/2d/ScaledFontFontconfig.h index 2cd8139403..9c3d1f86b0 100644 --- a/gfx/2d/ScaledFontFontconfig.h +++ b/gfx/2d/ScaledFontFontconfig.h @@ -32,10 +32,12 @@ class ScaledFontFontconfig : public ScaledFontBase { bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override; +#ifdef MOZ_BUILD_WEBRENDER bool GetWRFontInstanceOptions( Maybe* aOutOptions, Maybe* aOutPlatformOptions, std::vector* aOutVariations) override; +#endif bool HasVariationSettings() override; @@ -54,8 +56,10 @@ class ScaledFontFontconfig : public ScaledFontBase { }; InstanceData(cairo_scaled_font_t* aScaledFont, FcPattern* aPattern); +#ifdef MOZ_BUILD_WEBRENDER InstanceData(const wr::FontInstanceOptions* aOptions, const wr::FontInstancePlatformOptions* aPlatformOptions); +#endif void SetupPattern(FcPattern* aPattern) const; void SetupFontOptions(cairo_font_options_t* aFontOptions) const; diff --git a/gfx/2d/ScaledFontFreeType.cpp b/gfx/2d/ScaledFontFreeType.cpp index c76e50fbe0..522fd4951f 100644 --- a/gfx/2d/ScaledFontFreeType.cpp +++ b/gfx/2d/ScaledFontFreeType.cpp @@ -7,7 +7,9 @@ #include "NativeFontResourceFreeType.h" #include "Logging.h" #include "StackArray.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #ifdef USE_SKIA # include "skia/include/ports/SkTypeface_cairo.h" @@ -46,6 +48,7 @@ bool ScaledFontFreeType::GetFontInstanceData(FontInstanceDataOutput aCb, return true; } +#ifdef MOZ_BUILD_WEBRENDER bool ScaledFontFreeType::GetWRFontInstanceOptions( Maybe* aOutOptions, Maybe* aOutPlatformOptions, @@ -72,6 +75,7 @@ bool ScaledFontFreeType::GetWRFontInstanceOptions( return true; } +#endif FT_Face UnscaledFontFreeType::InitFace() { if (mFace) { diff --git a/gfx/2d/ScaledFontFreeType.h b/gfx/2d/ScaledFontFreeType.h index 33468cf327..47efe5eef0 100644 --- a/gfx/2d/ScaledFontFreeType.h +++ b/gfx/2d/ScaledFontFreeType.h @@ -29,10 +29,12 @@ class ScaledFontFreeType : public ScaledFontBase { bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override; +#ifdef MOZ_BUILD_WEBRENDER bool GetWRFontInstanceOptions( Maybe* aOutOptions, Maybe* aOutPlatformOptions, std::vector* aOutVariations) override; +#endif bool HasVariationSettings() override; diff --git a/gfx/2d/ScaledFontMac.cpp b/gfx/2d/ScaledFontMac.cpp index f36f983430..e751f14f80 100644 --- a/gfx/2d/ScaledFontMac.cpp +++ b/gfx/2d/ScaledFontMac.cpp @@ -4,7 +4,9 @@ #include "ScaledFontMac.h" #include "UnscaledFontMac.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #ifdef USE_SKIA # include "PathSkia.h" # include "skia/include/core/SkPaint.h" @@ -410,6 +412,7 @@ bool ScaledFontMac::GetFontInstanceData(FontInstanceDataOutput aCb, return true; } +#ifdef MOZ_BUILD_WEBRENDER bool ScaledFontMac::GetWRFontInstanceOptions( Maybe* aOutOptions, Maybe* aOutPlatformOptions, @@ -431,6 +434,7 @@ bool ScaledFontMac::GetWRFontInstanceOptions( *aOutOptions = Some(options); return true; } +#endif static CFDictionaryRef CreateVariationDictionaryOrNull( CGFontRef aCGFont, uint32_t aVariationCount, diff --git a/gfx/2d/ScaledFontMac.h b/gfx/2d/ScaledFontMac.h index 42752812ad..e3fc353de8 100644 --- a/gfx/2d/ScaledFontMac.h +++ b/gfx/2d/ScaledFontMac.h @@ -36,9 +36,11 @@ class ScaledFontMac : public ScaledFontBase { bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override; +#ifdef MOZ_BUILD_WEBRENDER bool GetWRFontInstanceOptions(Maybe* aOutOptions, Maybe* aOutPlatformOptions, std::vector* aOutVariations) override; +#endif bool CanSerialize() override { return true; } diff --git a/gfx/2d/SourceSurfaceRawData.cpp b/gfx/2d/SourceSurfaceRawData.cpp index 11c1246ffb..5046b2ae64 100644 --- a/gfx/2d/SourceSurfaceRawData.cpp +++ b/gfx/2d/SourceSurfaceRawData.cpp @@ -71,7 +71,12 @@ bool SourceSurfaceAlignedRawData::Init(const IntSize& aSize, void SourceSurfaceAlignedRawData::AddSizeOfExcludingThis( MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, uint64_t& aExtIdOut) const { + size_t& aExtHandlesOut +#ifdef MOZ_BUILD_WEBRENDER + , + uint64_t& aExtIdOut +#endif +) const { aHeapSizeOut += mArray.HeapSizeOfExcludingThis(aMallocSizeOf); } diff --git a/gfx/2d/SourceSurfaceRawData.h b/gfx/2d/SourceSurfaceRawData.h index 885c537420..d985afd215 100644 --- a/gfx/2d/SourceSurfaceRawData.h +++ b/gfx/2d/SourceSurfaceRawData.h @@ -81,8 +81,12 @@ class SourceSurfaceAlignedRawData : public DataSourceSurface { virtual SurfaceFormat GetFormat() const override { return mFormat; } void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, - size_t& aNonHeapSizeOut, size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const override; + size_t& aNonHeapSizeOut, size_t& aExtHandlesOut +#ifdef MOZ_BUILD_WEBRENDER + , + uint64_t& aExtIdOut +#endif + ) const override; private: friend class Factory; diff --git a/gfx/2d/UnscaledFontDWrite.h b/gfx/2d/UnscaledFontDWrite.h index 5a60a0d959..d26e06cad6 100644 --- a/gfx/2d/UnscaledFontDWrite.h +++ b/gfx/2d/UnscaledFontDWrite.h @@ -40,12 +40,14 @@ class UnscaledFontDWrite final : public UnscaledFont { uint32_t aInstanceDataLength, const FontVariation* aVariations, uint32_t aNumVariations) override; +#ifdef MOZ_BUILD_WEBRENDER already_AddRefed CreateScaledFontFromWRFont( Float aGlyphSize, const wr::FontInstanceOptions* aOptions, const wr::FontInstancePlatformOptions* aPlatformOptions, const FontVariation* aVariations, uint32_t aNumVariations) override; bool GetWRFontDescriptor(WRFontDescriptorOutput aCb, void* aBaton) override; +#endif private: RefPtr mFontFace; diff --git a/gfx/2d/UnscaledFontFreeType.h b/gfx/2d/UnscaledFontFreeType.h index ff0f8d2ca2..2ea14b34cc 100644 --- a/gfx/2d/UnscaledFontFreeType.h +++ b/gfx/2d/UnscaledFontFreeType.h @@ -102,12 +102,14 @@ class UnscaledFontFontconfig : public UnscaledFontFreeType { uint32_t aInstanceDataLength, const FontVariation* aVariations, uint32_t aNumVariations) override; +# ifdef MOZ_BUILD_WEBRENDER already_AddRefed CreateScaledFontFromWRFont( Float aGlyphSize, const wr::FontInstanceOptions* aOptions, const wr::FontInstancePlatformOptions* aPlatformOptions, const FontVariation* aVariations, uint32_t aNumVariations) override; +# endif }; -#endif +#endif // MOZ_WIDGET_GTK } // namespace gfx } // namespace mozilla diff --git a/gfx/gl/GLContextEGL.h b/gfx/gl/GLContextEGL.h index 8abf3cfcbf..3b491ae701 100644 --- a/gfx/gl/GLContextEGL.h +++ b/gfx/gl/GLContextEGL.h @@ -134,7 +134,12 @@ class GLContextEGL : public GLContext { #endif // defined(MOZ_WIDGET_ANDROID) }; -bool CreateConfig(EGLConfig* config, int32_t depth, bool enableDepthBuffer); +bool CreateConfig(EGLConfig* config, int32_t depth +#ifdef MOZ_BUILD_WEBRENDER + , + bool enableDepthBuffer +#endif +); } // namespace gl } // namespace mozilla diff --git a/gfx/gl/GLContextGLX.h b/gfx/gl/GLContextGLX.h index 3d2a131391..c7d884ed5e 100644 --- a/gfx/gl/GLContextGLX.h +++ b/gfx/gl/GLContextGLX.h @@ -22,14 +22,22 @@ class GLContextGLX : public GLContext { Display* display, GLXDrawable drawable, GLXFBConfig cfg, bool deleteDrawable, gfxXlibSurface* pixmap); - static bool FindVisual(Display* display, int screen, bool useWebRender, + static bool FindVisual(Display* display, int screen, +#ifdef MOZ_BUILD_WEBRENDER + bool useWebRender, +#endif bool useAlpha, int* const out_visualId); // Finds a GLXFBConfig compatible with the provided window. static bool FindFBConfigForWindow( Display* display, int screen, Window window, ScopedXFree* const out_scopedConfigArr, - GLXFBConfig* const out_config, int* const out_visid, bool aWebRender); + GLXFBConfig* const out_config, int* const out_visid +#ifdef MOZ_BUILD_WEBRENDER + , + bool aWebRender +#endif + ); virtual ~GLContextGLX(); diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm index 2a85d51888..a431e4f29d 100644 --- a/gfx/gl/GLContextProviderCGL.mm +++ b/gfx/gl/GLContextProviderCGL.mm @@ -141,6 +141,7 @@ bool UseDoubleBufferedWindows() const { static const NSOpenGLPixelFormatAttribute kAttribs_doubleBuffered_accel[] = { NSOpenGLPFAAccelerated, NSOpenGLPFAAllowOfflineRenderers, NSOpenGLPFADoubleBuffer, 0}; +#ifdef MOZ_BUILD_WEBRENDER static const NSOpenGLPixelFormatAttribute kAttribs_doubleBuffered_accel_webrender[] = { NSOpenGLPFAAccelerated, NSOpenGLPFAAllowOfflineRenderers, @@ -150,6 +151,7 @@ bool UseDoubleBufferedWindows() const { NSOpenGLPFADepthSize, 24, 0}; +#endif static NSOpenGLContext* CreateWithFormat(const NSOpenGLPixelFormatAttribute* attribs) { NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; @@ -166,12 +168,20 @@ bool UseDoubleBufferedWindows() const { } already_AddRefed GLContextProviderCGL::CreateForCompositorWidget( - CompositorWidget* aCompositorWidget, bool aWebRender, bool aForceAccelerated) { + CompositorWidget* aCompositorWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif + bool aForceAccelerated) { if (!aCompositorWidget) { MOZ_ASSERT(false); return nullptr; } - return CreateForWindow(aCompositorWidget->RealWidget(), aWebRender, aForceAccelerated); + return CreateForWindow(aCompositorWidget->RealWidget(), +#ifdef MOZ_BUILD_WEBRENDER + aWebRender, +#endif + aForceAccelerated); } already_AddRefed GLContextProviderCGL::CreateForWindow(nsIWidget* aWidget, @@ -189,12 +199,16 @@ bool UseDoubleBufferedWindows() const { const NSOpenGLPixelFormatAttribute* attribs; if (sCGLLibrary.UseDoubleBufferedWindows()) { +#ifdef MOZ_BUILD_WEBRENDER if (aWebRender) { attribs = aForceAccelerated ? kAttribs_doubleBuffered_accel_webrender : kAttribs_doubleBuffered; } else { +#endif attribs = aForceAccelerated ? kAttribs_doubleBuffered_accel : kAttribs_doubleBuffered; +#ifdef MOZ_BUILD_WEBRENDER } +#endif } else { attribs = aForceAccelerated ? kAttribs_singleBuffered_accel : kAttribs_singleBuffered; } diff --git a/gfx/gl/GLContextProviderEAGL.mm b/gfx/gl/GLContextProviderEAGL.mm index 164ba4175a..ebd20b7bbb 100644 --- a/gfx/gl/GLContextProviderEAGL.mm +++ b/gfx/gl/GLContextProviderEAGL.mm @@ -164,19 +164,32 @@ static PRFuncPtr GLAPIENTRY GetLoadedProcAddress(const char* const name) { } already_AddRefed GLContextProviderEAGL::CreateForCompositorWidget( - CompositorWidget* aCompositorWidget, bool aWebRender, bool aForceAccelerated) { + CompositorWidget* aCompositorWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif + bool aForceAccelerated) { if (!aCompositorWidget) { MOZ_ASSERT(false); return nullptr; } - return CreateForWindow(aCompositorWidget->RealWidget(), aWebRender, aForceAccelerated); + return CreateForWindow(aCompositorWidget->RealWidget(), +#ifdef MOZ_BUILD_WEBRENDER + aWebRender, +#endif + aForceAccelerated); } already_AddRefed GLContextProviderEAGL::CreateForWindow(nsIWidget* aWidget, +#ifdef MOZ_BUILD_WEBRENDER bool aWebRender, +#endif bool aForceAccelerated) { - RefPtr glContext = - CreateEAGLContext(CreateContextFlags::NONE, false, GetGlobalContextEAGL()); + RefPtr glContext = CreateEAGLContext(CreateContextFlags::NONE, +#ifdef MOZ_BUILD_WEBRENDER + false, +#endif + GetGlobalContextEAGL()); if (!glContext) { return nullptr; } diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 908d132be2..3df9b57a91 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -131,7 +131,12 @@ void DeleteWaylandGLSurface(EGLSurface surface) { (_array).AppendElement(_k); \ } while (0) -static bool CreateConfig(EGLConfig* aConfig, bool aEnableDepthBuffer); +static bool CreateConfig(EGLConfig* aConfig +#ifdef MOZ_BUILD_WEBRENDER + , + bool aEnableDepthBuffer +#endif +); // append three zeros at the end of attribs list to work around // EGL implementation bugs that iterate until they find 0, instead of @@ -235,8 +240,12 @@ static EGLSurface CreateSurfaceFromNativeWindow(EGLNativeWindowType window, */ class GLContextEGLFactory { public: - static already_AddRefed Create(EGLNativeWindowType aWindow, - bool aWebRender); + static already_AddRefed Create(EGLNativeWindowType aWindow +#ifdef MOZ_BUILD_WEBRENDER + , + bool aWebRender +#endif + ); private: GLContextEGLFactory() {} @@ -244,7 +253,12 @@ class GLContextEGLFactory { }; already_AddRefed GLContextEGLFactory::Create( - EGLNativeWindowType aWindow, bool aWebRender) { + EGLNativeWindowType aWindow +#ifdef MOZ_BUILD_WEBRENDER + , + bool aWebRender +#endif +) { nsCString discardFailureId; if (!GLLibraryEGL::EnsureInitialized(false, &discardFailureId)) { gfxCriticalNote << "Failed to load EGL library 3!"; @@ -255,6 +269,7 @@ already_AddRefed GLContextEGLFactory::Create( bool doubleBuffered = true; EGLConfig config; +#ifdef MOZ_BUILD_WEBRENDER if (aWebRender && egl->IsANGLE()) { // Force enable alpha channel to make sure ANGLE use correct framebuffer // formart @@ -265,11 +280,19 @@ already_AddRefed GLContextEGLFactory::Create( return nullptr; } } else { - if (!CreateConfig(&config, aWebRender)) { +#endif + if (!CreateConfig(&config +#ifdef MOZ_BUILD_WEBRENDER + , + aWebRender +#endif + )) { gfxCriticalNote << "Failed to create EGLConfig!"; return nullptr; } +#ifdef MOZ_BUILD_WEBRENDER } +#endif EGLSurface surface = EGL_NO_SURFACE; if (aWindow) { @@ -277,9 +300,11 @@ already_AddRefed GLContextEGLFactory::Create( } CreateContextFlags flags = CreateContextFlags::NONE; +#ifdef MOZ_BUILD_WEBRENDER if (aWebRender) { flags |= CreateContextFlags::PREFER_ES3; } +#endif SurfaceCaps caps = SurfaceCaps::Any(); RefPtr gl = GLContextEGL::CreateGLContext( flags, caps, false, config, surface, &discardFailureId); @@ -300,10 +325,12 @@ already_AddRefed GLContextEGLFactory::Create( egl->fSwapInterval(EGL_DISPLAY(), 0); } #endif +#ifdef MOZ_BUILD_WEBRENDER if (aWebRender && egl->IsANGLE()) { MOZ_ASSERT(doubleBuffered); egl->fSwapInterval(EGL_DISPLAY(), 0); } +#endif return gl.forget(); } @@ -785,7 +812,12 @@ static const EGLint kEGLConfigAttribsRGBA32[] = { 8, EGL_ATTRIBS_LIST_SAFE_TERMINATION_WORKING_AROUND_BUGS}; -bool CreateConfig(EGLConfig* aConfig, int32_t depth, bool aEnableDepthBuffer) { +bool CreateConfig(EGLConfig* aConfig, int32_t depth +#ifdef MOZ_BUILD_WEBRENDER + , + bool aEnableDepthBuffer +#endif +) { EGLConfig configs[64]; const EGLint* attribs; EGLint ncfg = ArrayLength(configs); @@ -824,6 +856,7 @@ bool CreateConfig(EGLConfig* aConfig, int32_t depth, bool aEnableDepthBuffer) { ((depth == 16 && r == 5 && g == 6 && b == 5) || (depth == 24 && r == 8 && g == 8 && b == 8) || (depth == 32 && r == 8 && g == 8 && b == 8 && a == 8))) { +#ifdef MOZ_BUILD_WEBRENDER EGLint z; if (aEnableDepthBuffer) { if (!egl->fGetConfigAttrib(EGL_DISPLAY(), config, LOCAL_EGL_DEPTH_SIZE, @@ -832,6 +865,7 @@ bool CreateConfig(EGLConfig* aConfig, int32_t depth, bool aEnableDepthBuffer) { continue; } } +#endif *aConfig = config; return true; } @@ -844,19 +878,39 @@ bool CreateConfig(EGLConfig* aConfig, int32_t depth, bool aEnableDepthBuffer) { // // NB: It's entirely legal for the returned EGLConfig to be valid yet // have the value null. -static bool CreateConfig(EGLConfig* aConfig, bool aEnableDepthBuffer) { +static bool CreateConfig(EGLConfig* aConfig +#ifdef MOZ_BUILD_WEBRENDER + , + bool aEnableDepthBuffer +#endif +) { int32_t depth = gfxVars::ScreenDepth(); - if (!CreateConfig(aConfig, depth, aEnableDepthBuffer)) { + if (!CreateConfig(aConfig, depth +#ifdef MOZ_BUILD_WEBRENDER + , + aEnableDepthBuffer +#endif + )) { #ifdef MOZ_WIDGET_ANDROID // Bug 736005 // Android doesn't always support 16 bit so also try 24 bit if (depth == 16) { - return CreateConfig(aConfig, 24, aEnableDepthBuffer); + return CreateConfig(aConfig, 24 +# ifdef MOZ_BUILD_WEBRENDER + , + aEnableDepthBuffer +# endif + ); } // Bug 970096 // Some devices that have 24 bit screens only support 16 bit OpenGL? if (depth == 24) { - return CreateConfig(aConfig, 16, aEnableDepthBuffer); + return CreateConfig(aConfig, 16 +# ifdef MOZ_BUILD_WEBRENDER + , + aEnableDepthBuffer +# endif + ); } #endif return false; @@ -887,20 +941,36 @@ already_AddRefed GLContextProviderEGL::CreateWrappingExisting( } already_AddRefed GLContextProviderEGL::CreateForCompositorWidget( - CompositorWidget* aCompositorWidget, bool aWebRender, + CompositorWidget* aCompositorWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif bool aForceAccelerated) { EGLNativeWindowType window = nullptr; if (aCompositorWidget) { window = GET_NATIVE_WINDOW_FROM_COMPOSITOR_WIDGET(aCompositorWidget); } - return GLContextEGLFactory::Create(window, aWebRender); + return GLContextEGLFactory::Create(window +#ifdef MOZ_BUILD_WEBRENDER + , + aWebRender +#endif + ); } already_AddRefed GLContextProviderEGL::CreateForWindow( - nsIWidget* aWidget, bool aWebRender, bool aForceAccelerated) { + nsIWidget* aWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif + bool aForceAccelerated) { MOZ_ASSERT(aWidget); - return GLContextEGLFactory::Create( - GET_NATIVE_WINDOW_FROM_REAL_WIDGET(aWidget), aWebRender); + return GLContextEGLFactory::Create(GET_NATIVE_WINDOW_FROM_REAL_WIDGET(aWidget) +#ifdef MOZ_BUILD_WEBRENDER + , + aWebRender +#endif + ); } #if defined(MOZ_WIDGET_ANDROID) @@ -922,7 +992,12 @@ EGLSurface GLContextProviderEGL::CreateEGLSurface(void* aWindow, } auto* egl = gl::GLLibraryEGL::Get(); EGLConfig config = aConfig; - if (!config && !CreateConfig(&config, /* aEnableDepthBuffer */ false)) { + if (!config && !CreateConfig(&config +# ifdef MOZ_BUILD_WEBRENDER + , + /* aEnableDepthBuffer */ false +# endif + )) { MOZ_CRASH("GFX: Failed to create EGLConfig 2!"); } diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 1db5c72c5a..5d8abaf30e 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -705,7 +705,9 @@ already_AddRefed GLContextProviderGLX::CreateWrappingExisting( } already_AddRefed CreateForWidget(Display* aXDisplay, Window aXWindow, +#ifdef MOZ_BUILD_WEBRENDER bool aWebRender, +#endif bool aForceAccelerated) { if (!sGLXLibrary.EnsureInitialized()) { return nullptr; @@ -734,18 +736,25 @@ already_AddRefed CreateForWidget(Display* aXDisplay, Window aXWindow, } CreateContextFlags flags; +#ifdef MOZ_BUILD_WEBRENDER if (aWebRender) { flags = CreateContextFlags::NONE; // WR needs GL3.2+ } else { +#endif flags = CreateContextFlags::REQUIRE_COMPAT_PROFILE; +#ifdef MOZ_BUILD_WEBRENDER } +#endif return GLContextGLX::CreateGLContext(flags, SurfaceCaps::Any(), false, aXDisplay, aXWindow, config, false, nullptr); } already_AddRefed GLContextProviderGLX::CreateForCompositorWidget( - CompositorWidget* aCompositorWidget, bool aWebRender, + CompositorWidget* aCompositorWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif bool aForceAccelerated) { if (!aCompositorWidget) { MOZ_ASSERT(false); @@ -755,16 +764,27 @@ already_AddRefed GLContextProviderGLX::CreateForCompositorWidget( MOZ_ASSERT(compWidget); return CreateForWidget(compWidget->XDisplay(), compWidget->XWindow(), - aWebRender, aForceAccelerated); +#ifdef MOZ_BUILD_WEBRENDER + aWebRender, +#endif + aForceAccelerated); } already_AddRefed GLContextProviderGLX::CreateForWindow( - nsIWidget* aWidget, bool aWebRender, bool aForceAccelerated) { + nsIWidget* aWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif + bool aForceAccelerated) { Display* display = (Display*)aWidget->GetNativeData(NS_NATIVE_COMPOSITOR_DISPLAY); Window window = GET_NATIVE_WINDOW(aWidget); - return CreateForWidget(display, window, aWebRender, aForceAccelerated); + return CreateForWidget(display, window, +#ifdef MOZ_BUILD_WEBRENDER + aWebRender, +#endif + aForceAccelerated); } static bool ChooseConfig(GLXLibrary* glx, Display* display, int screen, @@ -826,7 +846,10 @@ static bool ChooseConfig(GLXLibrary* glx, Display* display, int screen, return false; } -bool GLContextGLX::FindVisual(Display* display, int screen, bool useWebRender, +bool GLContextGLX::FindVisual(Display* display, int screen, +#ifdef MOZ_BUILD_WEBRENDER + bool useWebRender, +#endif bool useAlpha, int* const out_visualId) { if (!sGLXLibrary.EnsureInitialized()) { return false; @@ -864,7 +887,11 @@ bool GLContextGLX::FindVisual(Display* display, int screen, bool useWebRender, const int bpp = useAlpha ? 32 : 24; const int alphaSize = useAlpha ? 8 : 0; - const int depthSize = useWebRender ? 24 : 0; +#ifdef MOZ_BUILD_WEBRENDER + const int depthSize = 24; +#else + const int depthSize = 0; +#endif for (auto& cur : visualInfos) { const auto fnConfigMatches = [&](const int pname, const int expected) { @@ -899,7 +926,12 @@ bool GLContextGLX::FindVisual(Display* display, int screen, bool useWebRender, bool GLContextGLX::FindFBConfigForWindow( Display* display, int screen, Window window, ScopedXFree* const out_scopedConfigArr, - GLXFBConfig* const out_config, int* const out_visid, bool aWebRender) { + GLXFBConfig* const out_config, int* const out_visid +#ifdef MOZ_BUILD_WEBRENDER + , + bool aWebRender +#endif +) { // XXX the visual ID is almost certainly the LOCAL_GLX_FBCONFIG_ID, so // we could probably do this first and replace the glXGetFBConfigs // with glXChooseConfigs. Docs are sparklingly clear as always. @@ -911,6 +943,7 @@ bool GLContextGLX::FindFBConfigForWindow( ScopedXFree& cfgs = *out_scopedConfigArr; int numConfigs; +#ifdef MOZ_BUILD_WEBRENDER const int webrenderAttribs[] = {LOCAL_GLX_ALPHA_SIZE, windowAttrs.depth == 32 ? 8 : 0, LOCAL_GLX_DEPTH_SIZE, @@ -923,8 +956,11 @@ bool GLContextGLX::FindFBConfigForWindow( cfgs = sGLXLibrary.fChooseFBConfig(display, screen, webrenderAttribs, &numConfigs); } else { +#endif cfgs = sGLXLibrary.fGetFBConfigs(display, screen, &numConfigs); +#ifdef MOZ_BUILD_WEBRENDER } +#endif if (!cfgs) { NS_WARNING("[GLX] glXGetFBConfigs() failed"); diff --git a/gfx/gl/GLContextProviderImpl.h b/gfx/gl/GLContextProviderImpl.h index 7826b5b8b2..4eadd96d9d 100644 --- a/gfx/gl/GLContextProviderImpl.h +++ b/gfx/gl/GLContextProviderImpl.h @@ -39,7 +39,10 @@ class GL_CONTEXT_PROVIDER_NAME { * @return Context to use for the window */ static already_AddRefed CreateForCompositorWidget( - mozilla::widget::CompositorWidget* aCompositorWidget, bool aWebRender, + mozilla::widget::CompositorWidget* aCompositorWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif bool aForceAccelerated); /** @@ -66,7 +69,9 @@ class GL_CONTEXT_PROVIDER_NAME { * @return Context to use for the window */ static already_AddRefed CreateForWindow(nsIWidget* aWidget, +#ifdef MOZ_BUILD_WEBRENDER bool aWebRender, +#endif bool aForceAccelerated); /** diff --git a/gfx/gl/GLContextProviderNull.cpp b/gfx/gl/GLContextProviderNull.cpp index 9a91a20b26..61ec08707a 100644 --- a/gfx/gl/GLContextProviderNull.cpp +++ b/gfx/gl/GLContextProviderNull.cpp @@ -10,13 +10,20 @@ namespace gl { using namespace mozilla::widget; already_AddRefed GLContextProviderNull::CreateForCompositorWidget( - CompositorWidget* aCompositorWidget, bool aWebRender, + CompositorWidget* aCompositorWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif bool aForceAccelerated) { return nullptr; } already_AddRefed GLContextProviderNull::CreateForWindow( - nsIWidget* aWidget, bool aWebRender, bool aForceAccelerated) { + nsIWidget* aWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif + bool aForceAccelerated) { return nullptr; } diff --git a/gfx/gl/GLContextProviderWGL.cpp b/gfx/gl/GLContextProviderWGL.cpp index b4e5275a3c..a7334b5588 100644 --- a/gfx/gl/GLContextProviderWGL.cpp +++ b/gfx/gl/GLContextProviderWGL.cpp @@ -18,7 +18,9 @@ #include "mozilla/Preferences.h" #include "mozilla/StaticPtr.h" #include "mozilla/layers/CompositorOptions.h" -#include "mozilla/webrender/RenderThread.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/RenderThread.h" +#endif #include "mozilla/widget/CompositorWidget.h" #include "mozilla/widget/WinCompositorWidget.h" @@ -353,7 +355,9 @@ WGLLibrary::CreateContextWithFallback(const HDC dc, } static RefPtr CreateForWidget(const HWND window, +#ifdef MOZ_BUILD_WEBRENDER const bool isWebRender, +#endif const bool requireAccelerated) { auto& wgl = sWGLLib; if (!wgl.EnsureInitialized()) return nullptr; @@ -375,6 +379,8 @@ static RefPtr CreateForWidget(const HWND window, LOCAL_WGL_ACCELERATION_ARB, LOCAL_WGL_FULL_ACCELERATION_ARB, 0}; + const int* attribs; +#ifdef MOZ_BUILD_WEBRENDER const int kAttribsForWebRender[] = {LOCAL_WGL_DRAW_TO_WINDOW_ARB, true, LOCAL_WGL_SUPPORT_OPENGL_ARB, @@ -386,12 +392,14 @@ static RefPtr CreateForWidget(const HWND window, LOCAL_WGL_ACCELERATION_ARB, LOCAL_WGL_FULL_ACCELERATION_ARB, 0}; - const int* attribs; if (wr::RenderThread::IsInRenderThread()) { attribs = kAttribsForWebRender; } else { +#endif attribs = kAttribs; +#ifdef MOZ_BUILD_WEBRENDER } +#endif if (!wgl.mSymbols.fChoosePixelFormat(wgl.RootDc(), attribs, nullptr, 1, &chosenFormat, &foundFormats)) { @@ -408,6 +416,8 @@ static RefPtr CreateForWidget(const HWND window, LOCAL_WGL_DOUBLE_BUFFER_ARB, true, 0}; + const int* attribs; +#ifdef MOZ_BUILD_WEBRENDER const int kAttribsForWebRender[] = {LOCAL_WGL_DRAW_TO_WINDOW_ARB, true, LOCAL_WGL_SUPPORT_OPENGL_ARB, @@ -418,12 +428,14 @@ static RefPtr CreateForWidget(const HWND window, 24, 0}; - const int* attribs; if (wr::RenderThread::IsInRenderThread()) { attribs = kAttribsForWebRender; } else { +#endif attribs = kAttribs; +#ifdef MOZ_BUILD_WEBRENDER } +#endif if (!wgl.mSymbols.fChoosePixelFormat(wgl.RootDc(), attribs, nullptr, 1, &chosenFormat, &foundFormats)) { @@ -451,21 +463,34 @@ static RefPtr CreateForWidget(const HWND window, } already_AddRefed GLContextProviderWGL::CreateForCompositorWidget( - CompositorWidget* aCompositorWidget, bool aWebRender, + CompositorWidget* aCompositorWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif bool aForceAccelerated) { if (!aCompositorWidget) { MOZ_ASSERT(false); return nullptr; } - return CreateForWidget(aCompositorWidget->AsWindows()->GetHwnd(), aWebRender, + return CreateForWidget(aCompositorWidget->AsWindows()->GetHwnd(), +#ifdef MOZ_BUILD_WEBRENDER + aWebRender, +#endif aForceAccelerated) .forget(); } already_AddRefed GLContextProviderWGL::CreateForWindow( - nsIWidget* aWidget, bool aWebRender, bool aForceAccelerated) { + nsIWidget* aWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif + bool aForceAccelerated) { return CreateForWidget((HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW), - aWebRender, aForceAccelerated) +#ifdef MOZ_BUILD_WEBRENDER + aWebRender, +#endif + aForceAccelerated) .forget(); } diff --git a/gfx/gl/GLContextProviderWayland.cpp b/gfx/gl/GLContextProviderWayland.cpp index 6a8256e814..95339661d9 100644 --- a/gfx/gl/GLContextProviderWayland.cpp +++ b/gfx/gl/GLContextProviderWayland.cpp @@ -28,24 +28,43 @@ already_AddRefed GLContextProviderWayland::CreateWrappingExisting( } already_AddRefed GLContextProviderWayland::CreateForCompositorWidget( - CompositorWidget* aCompositorWidget, bool aWebRender, + CompositorWidget* aCompositorWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif bool aForceAccelerated) { if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) { - return sGLContextProviderGLX.CreateForCompositorWidget( - aCompositorWidget, aWebRender, aForceAccelerated); + return sGLContextProviderGLX.CreateForCompositorWidget(aCompositorWidget, +#ifdef MOZ_BUILD_WEBRENDER + aWebRender, +#endif + aForceAccelerated); } else { - return sGLContextProviderEGL.CreateForCompositorWidget( - aCompositorWidget, aWebRender, aForceAccelerated); + return sGLContextProviderEGL.CreateForCompositorWidget(aCompositorWidget, +#ifdef MOZ_BUILD_WEBRENDER + aWebRender, +#endif + aForceAccelerated); } } already_AddRefed GLContextProviderWayland::CreateForWindow( - nsIWidget* aWidget, bool aWebRender, bool aForceAccelerated) { + nsIWidget* aWidget, +#ifdef MOZ_BUILD_WEBRENDER + bool aWebRender, +#endif + bool aForceAccelerated) { if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) { - return sGLContextProviderGLX.CreateForWindow(aWidget, aWebRender, + return sGLContextProviderGLX.CreateForWindow(aWidget, +#ifdef MOZ_BUILD_WEBRENDER + aWebRender, +#endif aForceAccelerated); } else { - return sGLContextProviderEGL.CreateForWindow(aWidget, aWebRender, + return sGLContextProviderEGL.CreateForWindow(aWidget, +#ifdef MOZ_BUILD_WEBRENDER + aWebRender, +#endif aForceAccelerated); } } diff --git a/gfx/gl/GLLibraryEGL.cpp b/gfx/gl/GLLibraryEGL.cpp index 79ace94132..345c1beb9d 100644 --- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -15,7 +15,9 @@ #include "mozilla/StaticPrefs_gfx.h" #include "mozilla/StaticPrefs_webgl.h" #include "mozilla/Unused.h" -#include "mozilla/webrender/RenderThread.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/RenderThread.h" +#endif #include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceUtils.h" #include "nsIGfxInfo.h" @@ -157,9 +159,10 @@ static EGLDisplay GetAndInitWARPDisplay(GLLibraryEGL& egl, void* displayType) { return display; } +#ifdef MOZ_BUILD_WEBRENDER static EGLDisplay GetAndInitDisplayForWebRender(GLLibraryEGL& egl, void* displayType) { -#ifdef XP_WIN +# ifdef XP_WIN const EGLint attrib_list[] = {LOCAL_EGL_NONE}; RefPtr d3d11Device = gfx::DeviceManagerDx::Get()->GetCompositorDevice(); @@ -201,18 +204,21 @@ static EGLDisplay GetAndInitDisplayForWebRender(GLLibraryEGL& egl, return EGL_NO_DISPLAY; } return display; -#else +# else return EGL_NO_DISPLAY; -#endif +# endif } +#endif static bool IsAccelAngleSupported(const nsCOMPtr& gfxInfo, nsACString* const out_failureId) { +#ifdef MOZ_BUILD_WEBRENDER if (wr::RenderThread::IsInRenderThread()) { // We can only enter here with WebRender, so assert that this is a // WebRender-enabled build. return true; } +#endif int32_t angleSupport; nsCString failureId; gfxUtils::ThreadSafeGetFeatureStatus(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_ANGLE, @@ -280,9 +286,11 @@ static EGLDisplay GetAndInitDisplayForAccelANGLE( GLLibraryEGL& egl, nsACString* const out_failureId) { EGLDisplay ret = 0; +#ifdef MOZ_BUILD_WEBRENDER if (wr::RenderThread::IsInRenderThread()) { return GetAndInitDisplayForWebRender(egl, EGL_DEFAULT_DISPLAY); } +#endif FeatureState& d3d11ANGLE = gfxConfig::GetFeature(Feature::D3D11_HW_ANGLE); @@ -411,12 +419,11 @@ bool GLLibraryEGL::DoEnsureInitialized(bool forceAccel, // Also note that we intentionally leak the libs we load. do { - if (IsVistaOrLater()) { - // Windows 8.1+ has d3dcompiler_47.dll in the system directory. - // Try it first. Note that _46 will never be in the system - // directory. So there is no point trying _46 in the system - // directory. + // Windows 8.1+ has d3dcompiler_47.dll in the system directory. + // Try it first. Note that _46 will never be in the system + // directory. So there is no point trying _46 in the system + // directory. if (LoadLibrarySystem32(L"d3dcompiler_47.dll")) break; @@ -426,11 +433,11 @@ bool GLLibraryEGL::DoEnsureInitialized(bool forceAccel, break; # endif } -#ifdef MOZ_D3DCOMPILER_XP_DLL +# ifdef MOZ_D3DCOMPILER_XP_DLL if (LoadLibraryForEGLOnWindows( NS_LITERAL_STRING(MOZ_STRINGIFY(MOZ_D3DCOMPILER_XP_DLL)))) break; -#endif +# endif MOZ_ASSERT(false, "d3dcompiler DLL loading failed."); } while (false); diff --git a/gfx/ipc/CompositorOptions.h b/gfx/ipc/CompositorOptions.h index 37018d64cb..ca353f04b2 100644 --- a/gfx/ipc/CompositorOptions.h +++ b/gfx/ipc/CompositorOptions.h @@ -29,18 +29,31 @@ class CompositorOptions { // This constructor needed for IPDL purposes, don't use it anywhere else. CompositorOptions() : mUseAPZ(false), +#ifdef MOZ_BUILD_WEBRENDER mUseWebRender(false), +#endif mUseAdvancedLayers(false), - mInitiallyPaused(false) {} + mInitiallyPaused(false) { + } - CompositorOptions(bool aUseAPZ, bool aUseWebRender) + CompositorOptions(bool aUseAPZ +#ifdef MOZ_BUILD_WEBRENDER + , + bool aUseWebRender +#endif + ) : mUseAPZ(aUseAPZ), +#ifdef MOZ_BUILD_WEBRENDER mUseWebRender(aUseWebRender), +#endif mUseAdvancedLayers(false), - mInitiallyPaused(false) {} + mInitiallyPaused(false) { + } bool UseAPZ() const { return mUseAPZ; } +#ifdef MOZ_BUILD_WEBRENDER bool UseWebRender() const { return mUseWebRender; } +#endif bool UseAdvancedLayers() const { return mUseAdvancedLayers; } bool InitiallyPaused() const { return mInitiallyPaused; } @@ -53,7 +66,10 @@ class CompositorOptions { } bool operator==(const CompositorOptions& aOther) const { - return mUseAPZ == aOther.mUseAPZ && mUseWebRender == aOther.mUseWebRender && + return mUseAPZ == aOther.mUseAPZ && +#ifdef MOZ_BUILD_WEBRENDER + mUseWebRender == aOther.mUseWebRender && +#endif mUseAdvancedLayers == aOther.mUseAdvancedLayers; } @@ -61,7 +77,9 @@ class CompositorOptions { private: bool mUseAPZ; +#ifdef MOZ_BUILD_WEBRENDER bool mUseWebRender; +#endif bool mUseAdvancedLayers; bool mInitiallyPaused; diff --git a/gfx/ipc/CompositorSession.cpp b/gfx/ipc/CompositorSession.cpp index 46f59ed98f..3d3bb8f0fb 100644 --- a/gfx/ipc/CompositorSession.cpp +++ b/gfx/ipc/CompositorSession.cpp @@ -34,7 +34,7 @@ CompositorBridgeChild* CompositorSession::GetCompositorBridgeChild() { return mCompositorBridgeChild; } -#if defined(MOZ_WIDGET_ANDROID) +#if defined(MOZ_WIDGET_ANDROID) && defined(MOZ_BUILD_WEBRENDER) void CompositorSession::NotifyDisablingWebRender() { if (!mWidget) { return; diff --git a/gfx/ipc/CompositorSession.h b/gfx/ipc/CompositorSession.h index 20381c0562..63edcdd94a 100644 --- a/gfx/ipc/CompositorSession.h +++ b/gfx/ipc/CompositorSession.h @@ -79,7 +79,9 @@ class CompositorSession { return mUiCompositorControllerChild; } +# ifdef MOZ_BUILD_WEBRENDER void NotifyDisablingWebRender(); +# endif #endif // defined(MOZ_WIDGET_ANDROID) protected: CompositorSession(nsBaseWidget* aWidget, CompositorWidgetDelegate* aDelegate, diff --git a/gfx/ipc/GPUParent.cpp b/gfx/ipc/GPUParent.cpp index 5aa5a50a60..33f52884c5 100644 --- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -21,7 +21,6 @@ #include "mozilla/dom/MemoryReportRequest.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/gfxVars.h" -#include "mozilla/image/ImageMemoryReporter.h" #include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/ipc/ProcessChild.h" #include "mozilla/layers/APZInputBridgeParent.h" @@ -34,8 +33,11 @@ #include "mozilla/layers/LayerTreeOwnerTracker.h" #include "mozilla/layers/UiCompositorControllerParent.h" #include "mozilla/layers/MemoryReportingMLGPU.h" -#include "mozilla/webrender/RenderThread.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/image/ImageMemoryReporter.h" +# include "mozilla/webrender/RenderThread.h" +# include "mozilla/webrender/WebRenderAPI.h" +#endif #include "mozilla/HangDetails.h" #include "nscore.h" #include "nsDebugImpl.h" @@ -182,6 +184,7 @@ mozilla::ipc::IPCResult GPUParent::RecvInit( gfxConfig::Inherit(Feature::ADVANCED_LAYERS, devicePrefs.advancedLayers()); gfxConfig::Inherit(Feature::DIRECT2D, devicePrefs.useD2D1()); +#ifdef MOZ_BUILD_WEBRENDER { // Let the crash reporter know if we've got WR enabled or not. For other // processes this happens in gfxPlatform::InitWebRenderConfig. ScopedGfxFeatureReporter reporter("WR", @@ -190,6 +193,7 @@ mozilla::ipc::IPCResult GPUParent::RecvInit( reporter.SetSuccessful(); } } +#endif for (const LayerTreeIdMapping& map : aMappings) { LayerTreeOwnerTracker::Get()->Map(map.layersId(), map.ownerId()); @@ -203,6 +207,7 @@ mozilla::ipc::IPCResult GPUParent::RecvInit( if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) { DeviceManagerDx::Get()->CreateCompositorDevices(); } +# ifdef MOZ_BUILD_WEBRENDER if (gfxVars::UseWebRender()) { DeviceManagerDx::Get()->CreateDirectCompositionDevice(); // Ensure to initialize GfxInfo @@ -211,6 +216,7 @@ mozilla::ipc::IPCResult GPUParent::RecvInit( Factory::EnsureDWriteFactory(); } +# endif #endif #if defined(MOZ_WIDGET_GTK) @@ -239,6 +245,7 @@ mozilla::ipc::IPCResult GPUParent::RecvInit( // Ensure we have an FT library for font instantiation. // This would normally be set by gfxPlatform::Init(). // Since we bypass that, we must do it here instead. +# ifdef MOZ_BUILD_WEBRENDER if (gfxVars::UseWebRender()) { FT_Library library = Factory::NewFTLibrary(); MOZ_ASSERT(library); @@ -246,15 +253,19 @@ mozilla::ipc::IPCResult GPUParent::RecvInit( SkInitCairoFT(true); } +# endif #endif // Make sure to do this *after* we update gfxVars above. +#ifdef MOZ_BUILD_WEBRENDER if (gfxVars::UseWebRender()) { wr::RenderThread::Start(); image::ImageMemoryReporter::InitForWebRender(); } -#ifdef XP_WIN - else { +# ifdef XP_WIN + else +# endif + { if (gfxVars::UseDoubleBufferingWithCompositor()) { // This is needed to avoid freezing the window on a device crash on double // buffering, see bug 1549674. @@ -380,9 +391,11 @@ mozilla::ipc::IPCResult GPUParent::RecvSimulateDeviceReset( DeviceManagerDx::Get()->ForceDeviceReset( ForcedDeviceResetReason::COMPOSITOR_UPDATED); DeviceManagerDx::Get()->MaybeResetAndReacquireDevices(); +# ifdef MOZ_BUILD_WEBRENDER if (gfxVars::UseWebRender()) { wr::RenderThread::Get()->SimulateDeviceReset(); } +# endif #endif RecvGetDeviceStatus(aOut); return IPC_OK(); @@ -513,18 +526,22 @@ void GPUParent::ActorDestroy(ActorDestroyReason aWhy) { } RemoteDecoderManagerParent::ShutdownVideoBridge(); CompositorThreadHolder::Shutdown(); +#ifdef MOZ_BUILD_WEBRENDER // There is a case that RenderThread exists when gfxVars::UseWebRender() is // false. This could happen when WebRender was fallbacked to compositor. if (wr::RenderThread::Get()) { wr::RenderThread::ShutDown(); } +#endif #ifdef XP_WIN if (widget::WinCompositorWindowThread::Get()) { widget::WinCompositorWindowThread::ShutDown(); } #endif +#ifdef MOZ_BUILD_WEBRENDER image::ImageMemoryReporter::ShutdownForWebRender(); +#endif // Shut down the default GL context provider. gl::GLContextProvider::Shutdown(); diff --git a/gfx/ipc/GPUProcessManager.cpp b/gfx/ipc/GPUProcessManager.cpp index b85b36f129..d546a6f056 100644 --- a/gfx/ipc/GPUProcessManager.cpp +++ b/gfx/ipc/GPUProcessManager.cpp @@ -181,7 +181,9 @@ void GPUProcessManager::DisableGPUProcess(const char* aMessage) { gfxConfig::SetFailed(Feature::GPU_PROCESS, FeatureStatus::Failed, aMessage); gfxCriticalNote << aMessage; +#ifdef MOZ_BUILD_WEBRENDER gfxPlatform::NotifyGPUProcessDisabled(); +#endif Telemetry::Accumulate(Telemetry::GPU_PROCESS_CRASH_FALLBACKS, uint32_t(FallbackType::DISABLED)); @@ -435,6 +437,7 @@ void GPUProcessManager::SimulateDeviceReset() { } } +#ifdef MOZ_BUILD_WEBRENDER void GPUProcessManager::DisableWebRender(wr::WebRenderError aError) { if (!gfx::gfxVars::UseWebRender()) { return; @@ -466,14 +469,14 @@ void GPUProcessManager::DisableWebRender(wr::WebRenderError aError) { } gfx::gfxVars::SetUseWebRender(false); -#if defined(MOZ_WIDGET_ANDROID) +# if defined(MOZ_WIDGET_ANDROID) // If aError is not wr::WebRenderError::INITIALIZE, nsWindow does not // re-create LayerManager. Needs to trigger re-creating LayerManager on // android if (aError != wr::WebRenderError::INITIALIZE) { NotifyDisablingWebRender(); } -#endif +# endif if (mProcess) { OnRemoteProcessDeviceReset(mProcess); @@ -485,6 +488,7 @@ void GPUProcessManager::DisableWebRender(wr::WebRenderError aError) { void GPUProcessManager::NotifyWebRenderError(wr::WebRenderError aError) { DisableWebRender(aError); } +#endif void GPUProcessManager::OnInProcessDeviceReset() { RebuildInProcessSessions(); @@ -666,8 +670,9 @@ void GPUProcessManager::RebuildInProcessSessions() { } } +#ifdef MOZ_BUILD_WEBRENDER void GPUProcessManager::NotifyDisablingWebRender() { -#if defined(MOZ_WIDGET_ANDROID) +# if defined(MOZ_WIDGET_ANDROID) for (const auto& session : mRemoteSessions) { session->NotifyDisablingWebRender(); } @@ -675,8 +680,9 @@ void GPUProcessManager::NotifyDisablingWebRender() { for (const auto& session : mInProcessSessions) { session->NotifyDisablingWebRender(); } -#endif +# endif } +#endif void GPUProcessManager::NotifyRemoteActorDestroyed( const uint64_t& aProcessToken) { diff --git a/gfx/ipc/GPUProcessManager.h b/gfx/ipc/GPUProcessManager.h index 20cc6f7ea3..5322ea4831 100644 --- a/gfx/ipc/GPUProcessManager.h +++ b/gfx/ipc/GPUProcessManager.h @@ -15,7 +15,9 @@ #include "mozilla/ipc/TaskFactory.h" #include "mozilla/ipc/Transport.h" #include "mozilla/layers/LayersTypes.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "nsThreadUtils.h" class nsBaseWidget; @@ -144,8 +146,10 @@ class GPUProcessManager final : public GPUProcessHost::Listener { void OnProcessLaunchComplete(GPUProcessHost* aHost) override; void OnProcessUnexpectedShutdown(GPUProcessHost* aHost) override; void SimulateDeviceReset(); +#ifdef MOZ_BUILD_WEBRENDER void DisableWebRender(wr::WebRenderError aError); void NotifyWebRenderError(wr::WebRenderError aError); +#endif void OnInProcessDeviceReset(); void OnRemoteProcessDeviceReset(GPUProcessHost* aHost) override; void NotifyListenersOnCompositeDeviceReset(); @@ -210,7 +214,9 @@ class GPUProcessManager final : public GPUProcessHost::Listener { void RebuildRemoteSessions(); void RebuildInProcessSessions(); +#ifdef MOZ_BUILD_WEBRENDER void NotifyDisablingWebRender(); +#endif void FallbackToSoftware(const char* aMessage); diff --git a/gfx/layers/AnimationHelper.cpp b/gfx/layers/AnimationHelper.cpp index 5b129955ac..44ab89b92b 100644 --- a/gfx/layers/AnimationHelper.cpp +++ b/gfx/layers/AnimationHelper.cpp @@ -25,7 +25,9 @@ void CompositorAnimationStorage::Clear() { mAnimatedValues.Clear(); mAnimations.Clear(); +#ifdef MOZ_BUILD_WEBRENDER mAnimationRenderRoots.Clear(); +#endif } void CompositorAnimationStorage::ClearById(const uint64_t& aId) { @@ -33,7 +35,9 @@ void CompositorAnimationStorage::ClearById(const uint64_t& aId) { mAnimatedValues.Remove(aId); mAnimations.Remove(aId); +#ifdef MOZ_BUILD_WEBRENDER mAnimationRenderRoots.Remove(aId); +#endif } AnimatedValue* CompositorAnimationStorage::GetAnimatedValue( @@ -119,11 +123,17 @@ void CompositorAnimationStorage::SetAnimatedValue(uint64_t aId, } void CompositorAnimationStorage::SetAnimations(uint64_t aId, - const AnimationArray& aValue, - wr::RenderRoot aRenderRoot) { + const AnimationArray& aValue +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif +) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); mAnimations.Put(aId, AnimationHelper::ExtractAnimations(aValue)); +#ifdef MOZ_BUILD_WEBRENDER mAnimationRenderRoots.Put(aId, aRenderRoot); +#endif } enum class CanSkipCompose { @@ -577,6 +587,7 @@ uint64_t AnimationHelper::GetNextCompositorAnimationsId() { return nextId; } +#ifdef MOZ_BUILD_WEBRENDER bool AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage, TimeStamp aPreviousFrameTime, TimeStamp aCurrentFrameTime) { @@ -657,6 +668,7 @@ bool AnimationHelper::SampleAnimations(CompositorAnimationStorage* aStorage, return isAnimating; } +#endif gfx::Matrix4x4 AnimationHelper::ServoAnimationValueToMatrix4x4( const nsTArray>& aValues, diff --git a/gfx/layers/AnimationHelper.h b/gfx/layers/AnimationHelper.h index 9cc66106e9..5ff30ec6dd 100644 --- a/gfx/layers/AnimationHelper.h +++ b/gfx/layers/AnimationHelper.h @@ -6,10 +6,12 @@ #define mozilla_layers_AnimationHelper_h #include "mozilla/dom/Nullable.h" -#include "mozilla/ComputedTimingFunction.h" // for ComputedTimingFunction -#include "mozilla/layers/LayersMessages.h" // for TransformData, etc -#include "mozilla/webrender/WebRenderTypes.h" // for RenderRoot -#include "mozilla/TimeStamp.h" // for TimeStamp +#include "mozilla/ComputedTimingFunction.h" // for ComputedTimingFunction +#include "mozilla/layers/LayersMessages.h" // for TransformData, etc +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" // for RenderRoot +#endif +#include "mozilla/TimeStamp.h" // for TimeStamp #include "mozilla/TimingParams.h" #include "mozilla/Variant.h" #include "X11UndefineNone.h" @@ -156,8 +158,10 @@ class CompositorAnimationStorage final { typedef nsClassHashtable AnimatedValueTable; typedef nsDataHashtable AnimationsTable; +#ifdef MOZ_BUILD_WEBRENDER typedef nsDataHashtable AnimationsRenderRootsTable; +#endif NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorAnimationStorage) public: @@ -203,8 +207,12 @@ class CompositorAnimationStorage final { /** * Set the animations based on the unique id */ - void SetAnimations(uint64_t aId, const AnimationArray& aAnimations, - wr::RenderRoot aRenderRoot); + void SetAnimations(uint64_t aId, const AnimationArray& aAnimations +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif + ); /** * Return the iterator of animations table @@ -215,9 +223,11 @@ class CompositorAnimationStorage final { uint32_t AnimationsCount() const { return mAnimations.Count(); } +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot AnimationRenderRoot(const uint64_t& aId) const { return mAnimationRenderRoots.Get(aId); } +#endif /** * Clear AnimatedValues and Animations data @@ -231,7 +241,9 @@ class CompositorAnimationStorage final { private: AnimatedValueTable mAnimatedValues; AnimationsTable mAnimations; +#ifdef MOZ_BUILD_WEBRENDER AnimationsRenderRootsTable mAnimationRenderRoots; +#endif }; /** @@ -334,6 +346,7 @@ class AnimationHelper { */ static uint64_t GetNextCompositorAnimationsId(); +#ifdef MOZ_BUILD_WEBRENDER /** * Sample animation based a given time stamp |aTime| and the animation * data inside CompositorAnimationStorage |aStorage|. The animated values @@ -349,6 +362,7 @@ class AnimationHelper { static bool SampleAnimations(CompositorAnimationStorage* aStorage, TimeStamp aPreviousFrameTime, TimeStamp aCurrentFrameTime); +#endif /** * Convert an array of animation values into a matrix given the corresponding diff --git a/gfx/layers/AnimationInfo.cpp b/gfx/layers/AnimationInfo.cpp index 584c4f2b47..7f6b584f03 100644 --- a/gfx/layers/AnimationInfo.cpp +++ b/gfx/layers/AnimationInfo.cpp @@ -4,7 +4,9 @@ #include "AnimationInfo.h" #include "mozilla/LayerAnimationInfo.h" -#include "mozilla/layers/WebRenderLayerManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderLayerManager.h" +#endif #include "mozilla/layers/AnimationHelper.h" #include "mozilla/layers/CompositorThread.h" #include "mozilla/dom/Animation.h" @@ -165,12 +167,14 @@ Maybe AnimationInfo::GetGenerationFromFrame( if (nsLayoutUtils::IsFirstContinuationOrIBSplitSibling(aFrame)) { aFrame = nsLayoutUtils::LastContinuationOrIBSplitSibling(aFrame); } +#ifdef MOZ_BUILD_WEBRENDER RefPtr animationData = GetWebRenderUserData(aFrame, (uint32_t)aDisplayItemKey); if (animationData) { return animationData->GetAnimationInfo().GetAnimationGeneration(); } +#endif return Nothing(); } @@ -205,6 +209,7 @@ void AnimationInfo::EnumerateGenerationOnFrame( RefPtr layerManager = nsContentUtils::LayerManagerForContent(aContent); +#ifdef MOZ_BUILD_WEBRENDER if (layerManager && layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) { // In case of continuation, nsDisplayItem uses its last continuation, so we @@ -231,6 +236,7 @@ void AnimationInfo::EnumerateGenerationOnFrame( } return; } +#endif FrameLayerBuilder::EnumerateGenerationForDedicatedLayers(aFrame, aCallback); } diff --git a/gfx/layers/CanvasRenderer.h b/gfx/layers/CanvasRenderer.h index 5744900e86..a2fc1fa050 100644 --- a/gfx/layers/CanvasRenderer.h +++ b/gfx/layers/CanvasRenderer.h @@ -24,7 +24,9 @@ class AsyncCanvasRenderer; class ClientCanvasRenderer; class CopyableCanvasRenderer; class PersistentBufferProvider; +#ifdef MOZ_BUILD_WEBRENDER class WebRenderCanvasRendererAsync; +#endif struct CanvasInitializeData final { CanvasInitializeData(); @@ -116,9 +118,12 @@ class CanvasRenderer { virtual CopyableCanvasRenderer* AsCopyableCanvasRenderer() { return nullptr; } virtual ClientCanvasRenderer* AsClientCanvasRenderer() { return nullptr; } + +#ifdef MOZ_BUILD_WEBRENDER virtual WebRenderCanvasRendererAsync* AsWebRenderCanvasRendererAsync() { return nullptr; } +#endif protected: void FirePreTransactionCallback() { diff --git a/gfx/layers/D3D11YCbCrImage.cpp b/gfx/layers/D3D11YCbCrImage.cpp index 8321d6c404..c1860e2f99 100644 --- a/gfx/layers/D3D11YCbCrImage.cpp +++ b/gfx/layers/D3D11YCbCrImage.cpp @@ -360,9 +360,13 @@ already_AddRefed DXGIYCbCrTextureAllocationHelper::Allocate( ? DXGI_FORMAT_R8_UNORM : DXGI_FORMAT_R16_UNORM, mData.mYSize.width, mData.mYSize.height, 1, 1); + // WebRender requests keyed mutex - if (mDevice == gfx::DeviceManagerDx::Get()->GetCompositorDevice() && - !gfxVars::UseWebRender()) { + if (mDevice == gfx::DeviceManagerDx::Get()->GetCompositorDevice() +#ifdef MOZ_BUILD_WEBRENDER + && !gfxVars::UseWebRender() +#endif + ) { newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; } else { newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX; diff --git a/gfx/layers/ImageContainer.cpp b/gfx/layers/ImageContainer.cpp index 97150a53eb..041cf28b6f 100644 --- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -17,7 +17,9 @@ #include "mozilla/layers/ImageDataSerializer.h" // for SurfaceDescriptorBuffer #include "mozilla/layers/LayersMessages.h" #include "mozilla/layers/SharedPlanarYCbCrImage.h" -#include "mozilla/layers/SharedSurfacesChild.h" // for SharedSurfacesAnimation +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/SharedSurfacesChild.h" // for SharedSurfacesAnimation +#endif #include "mozilla/layers/SharedRGBImage.h" #include "mozilla/layers/TextureClientRecycleAllocator.h" #include "mozilla/gfx/gfxVars.h" @@ -171,12 +173,14 @@ void ImageContainer::EnsureImageClient() { } } +#ifdef MOZ_BUILD_WEBRENDER SharedSurfacesAnimation* ImageContainer::EnsureSharedSurfacesAnimation() { if (!mSharedAnimation) { mSharedAnimation = new SharedSurfacesAnimation(); } return mSharedAnimation; } +#endif ImageContainer::ImageContainer(Mode flag) : mRecursiveMutex("ImageContainer.mRecursiveMutex"), @@ -216,9 +220,11 @@ ImageContainer::~ImageContainer() { imageBridge->ForgetImageContainer(mAsyncContainerHandle); } } +#ifdef MOZ_BUILD_WEBRENDER if (mSharedAnimation) { mSharedAnimation->Destroy(); } +#endif } RefPtr ImageContainer::CreatePlanarYCbCrImage() { diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index d76799d08d..427e0a0c01 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -148,7 +148,9 @@ class ImageCompositeNotification; class ImageContainer; class ImageContainerChild; class SharedPlanarYCbCrImage; +#ifdef MOZ_BUILD_WEBRENDER class SharedSurfacesAnimation; +#endif class PlanarYCbCrImage; class TextureClient; class KnowsCompositor; @@ -602,11 +604,13 @@ class ImageContainer final : public SupportsWeakPtr { void DropImageClient(); +#ifdef MOZ_BUILD_WEBRENDER SharedSurfacesAnimation* GetSharedSurfacesAnimation() const { return mSharedAnimation; } SharedSurfacesAnimation* EnsureSharedSurfacesAnimation(); +#endif private: typedef mozilla::RecursiveMutex RecursiveMutex; @@ -668,7 +672,9 @@ class ImageContainer final : public SupportsWeakPtr { // than asynchronusly using the ImageBridge IPDL protocol. RefPtr mImageClient; +#ifdef MOZ_BUILD_WEBRENDER RefPtr mSharedAnimation; +#endif bool mIsAsync; CompositableHandle mAsyncContainerHandle; diff --git a/gfx/layers/LayerMetricsWrapper.h b/gfx/layers/LayerMetricsWrapper.h index e6fef5cd44..ab0eee0e55 100644 --- a/gfx/layers/LayerMetricsWrapper.h +++ b/gfx/layers/LayerMetricsWrapper.h @@ -335,7 +335,9 @@ class MOZ_STACK_CLASS LayerMetricsWrapper final { return Nothing(); } +#ifdef MOZ_BUILD_WEBRENDER Maybe GetReferentRenderRoot() const { return Nothing(); } +#endif Maybe GetClipRect() const { MOZ_ASSERT(IsValid()); @@ -383,6 +385,7 @@ class MOZ_STACK_CLASS LayerMetricsWrapper final { return mLayer->GetScrollbarData(); } +#ifdef MOZ_BUILD_WEBRENDER Maybe GetScrollbarAnimationId() const { MOZ_ASSERT(IsValid()); // This function is only really needed for template-compatibility with @@ -390,6 +393,7 @@ class MOZ_STACK_CLASS LayerMetricsWrapper final { // value is not used. return Nothing(); } +#endif ScrollableLayerGuid::ViewID GetFixedPositionScrollContainerId() const { MOZ_ASSERT(IsValid()); @@ -403,6 +407,7 @@ class MOZ_STACK_CLASS LayerMetricsWrapper final { return mLayer->GetFixedPositionSides(); } +#ifdef MOZ_BUILD_WEBRENDER Maybe GetZoomAnimationId() const { MOZ_ASSERT(IsValid()); // This function is only really needed for template-compatibility with @@ -410,6 +415,7 @@ class MOZ_STACK_CLASS LayerMetricsWrapper final { // value is not used. return Nothing(); } +#endif bool IsBackfaceHidden() const { MOZ_ASSERT(IsValid()); diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index c55a00c8aa..45d3d8dc79 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -15,7 +15,7 @@ #include "UnitTransforms.h" // for ViewAs #include "gfxEnv.h" #include "gfxPlatform.h" // for gfxPlatform -#include "gfxUtils.h" // for gfxUtils, etc +#include "gfxUtils.h" // for gfxUtils, etc #include "gfx2DGlue.h" #include "mozilla/DebugOnly.h" // for DebugOnly #include "mozilla/IntegerPrintfMacros.h" @@ -2213,14 +2213,19 @@ bool LayerManager::IsLogEnabled() { } bool LayerManager::SetPendingScrollUpdateForNextTransaction( - ScrollableLayerGuid::ViewID aScrollId, const ScrollUpdateInfo& aUpdateInfo, - wr::RenderRoot aRenderRoot) { + ScrollableLayerGuid::ViewID aScrollId, const ScrollUpdateInfo& aUpdateInfo +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif +) { Layer* withPendingTransform = DepthFirstSearch( GetRoot(), [](Layer* aLayer) { return aLayer->HasPendingTransform(); }); if (withPendingTransform) { return false; } +#ifdef MOZ_BUILD_WEBRENDER // If this is called on a LayerManager that's not a WebRenderLayerManager, // then we don't actually need the aRenderRoot information. We force it to // RenderRoot::Default so that we can make assumptions in @@ -2229,21 +2234,29 @@ bool LayerManager::SetPendingScrollUpdateForNextTransaction( ? aRenderRoot : wr::RenderRoot::Default; mPendingScrollUpdates[renderRoot].Put(aScrollId, aUpdateInfo); +#else + mPendingScrollUpdates.Put(aScrollId, aUpdateInfo); +#endif return true; } Maybe LayerManager::GetPendingScrollInfoUpdate( ScrollableLayerGuid::ViewID aScrollId) { +#ifdef MOZ_BUILD_WEBRENDER // This never gets called for WebRenderLayerManager, so we assume that all // pending scroll info updates are stored under the default RenderRoot. MOZ_ASSERT(GetBackendType() != LayersBackend::LAYERS_WR); auto p = mPendingScrollUpdates[wr::RenderRoot::Default].Lookup(aScrollId); +#else + auto p = mPendingScrollUpdates.Lookup(aScrollId); +#endif return p ? Some(p.Data()) : Nothing(); } std::unordered_set LayerManager::ClearPendingScrollInfoUpdate() { std::unordered_set scrollIds; +#ifdef MOZ_BUILD_WEBRENDER for (auto renderRoot : wr::kRenderRoots) { auto& updates = mPendingScrollUpdates[renderRoot]; for (auto it = updates.Iter(); !it.Done(); it.Next()) { @@ -2251,6 +2264,9 @@ LayerManager::ClearPendingScrollInfoUpdate() { } updates.Clear(); } +#else + mPendingScrollUpdates.Clear(); +#endif return scrollIds; } diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 8fb68a1606..95ae118e7b 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -37,7 +37,9 @@ #include "mozilla/layers/CanvasRenderer.h" #include "mozilla/layers/LayerAttributes.h" #include "mozilla/layers/LayersTypes.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "mozilla/mozalloc.h" // for operator delete, etc #include "nsAutoPtr.h" // for nsAutoPtr, nsRefPtr, etc #include "nsCOMPtr.h" // for already_AddRefed @@ -105,7 +107,9 @@ class Compositor; class FrameUniformityData; class PersistentBufferProvider; class GlyphArray; +#ifdef MOZ_BUILD_WEBRENDER class WebRenderLayerManager; +#endif struct AnimData; namespace layerscope { @@ -270,7 +274,9 @@ class LayerManager : public FrameRecorder { virtual BasicLayerManager* AsBasicLayerManager() { return nullptr; } virtual HostLayerManager* AsHostLayerManager() { return nullptr; } +#ifdef MOZ_BUILD_WEBRENDER virtual WebRenderLayerManager* AsWebRenderLayerManager() { return nullptr; } +#endif /** * Returns true if this LayerManager is owned by an nsIWidget, @@ -798,15 +804,23 @@ class LayerManager : public FrameRecorder { * scroll position updates to the APZ code. */ virtual bool SetPendingScrollUpdateForNextTransaction( - ScrollableLayerGuid::ViewID aScrollId, - const ScrollUpdateInfo& aUpdateInfo, wr::RenderRoot aRenderRoot); + ScrollableLayerGuid::ViewID aScrollId, const ScrollUpdateInfo& aUpdateInfo +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif + ); Maybe GetPendingScrollInfoUpdate( ScrollableLayerGuid::ViewID aScrollId); std::unordered_set ClearPendingScrollInfoUpdate(); protected: +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRootArray mPendingScrollUpdates; +#else + ScrollUpdatesMap mPendingScrollUpdates; +#endif }; /** diff --git a/gfx/layers/LayersLogging.cpp b/gfx/layers/LayersLogging.cpp index 5ccbd2e054..7ff66680b9 100644 --- a/gfx/layers/LayersLogging.cpp +++ b/gfx/layers/LayersLogging.cpp @@ -67,6 +67,7 @@ void AppendToString(std::stringstream& aStream, const nsRectAbsolute& r, aStream << sfx; } +#ifdef MOZ_BUILD_WEBRENDER void AppendToString(std::stringstream& aStream, const wr::ColorF& c, const char* pfx, const char* sfx) { aStream << pfx; @@ -92,17 +93,18 @@ void AppendToString(std::stringstream& aStream, const wr::LayoutSize& s, aStream << sfx; } -void AppendToString(std::stringstream& aStream, const nsSize& sz, +void AppendToString(std::stringstream& aStream, const wr::StickyOffsetBounds& s, const char* pfx, const char* sfx) { aStream << pfx; - aStream << nsPrintfCString("(w=%d, h=%d)", sz.width, sz.height).get(); + aStream << nsPrintfCString("(min=%f max=%f)", s.min, s.max).get(); aStream << sfx; } +#endif -void AppendToString(std::stringstream& aStream, const wr::StickyOffsetBounds& s, +void AppendToString(std::stringstream& aStream, const nsSize& sz, const char* pfx, const char* sfx) { aStream << pfx; - aStream << nsPrintfCString("(min=%f max=%f)", s.min, s.max).get(); + aStream << nsPrintfCString("(w=%d, h=%d)", sz.width, sz.height).get(); aStream << sfx; } @@ -256,12 +258,14 @@ void AppendToString(std::stringstream& aStream, const ScrollableLayerGuid& s, << sfx; } +#ifdef MOZ_BUILD_WEBRENDER void AppendToString(std::stringstream& aStream, const SLGuidAndRenderRoot& s, const char* pfx, const char* sfx) { aStream << pfx << "{ "; AppendToString(aStream, s.mScrollableLayerGuid, "s="); aStream << nsPrintfCString(", r=%d }", (int)s.mRenderRoot).get() << sfx; } +#endif void AppendToString(std::stringstream& aStream, const ZoomConstraints& z, const char* pfx, const char* sfx) { diff --git a/gfx/layers/LayersLogging.h b/gfx/layers/LayersLogging.h index 689e6c8b5e..c8a7ebad83 100644 --- a/gfx/layers/LayersLogging.h +++ b/gfx/layers/LayersLogging.h @@ -10,9 +10,11 @@ #include "mozilla/gfx/Point.h" // for IntSize, etc #include "mozilla/gfx/TiledRegion.h" // for TiledRegion #include "mozilla/gfx/Types.h" // for SamplingFilter, SurfaceFormat -#include "mozilla/layers/APZTypes.h" // for SLGuidAndRenderRoot #include "mozilla/layers/CompositorTypes.h" // for TextureFlags -#include "mozilla/layers/WebRenderLayersLogging.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/APZTypes.h" // for SLGuidAndRenderRoot +# include "mozilla/layers/WebRenderLayersLogging.h" +#endif #include "mozilla/layers/ZoomConstraints.h" #include "nsAString.h" #include "nsPrintfCString.h" // for nsPrintfCString @@ -116,6 +118,7 @@ void AppendToString(std::stringstream& aStream, aStream << sfx; } +#ifdef MOZ_BUILD_WEBRENDER void AppendToString(std::stringstream& aStream, const wr::ColorF& c, const char* pfx = "", const char* sfx = ""); @@ -125,10 +128,11 @@ void AppendToString(std::stringstream& aStream, const wr::LayoutRect& r, void AppendToString(std::stringstream& aStream, const wr::LayoutSize& s, const char* pfx = "", const char* sfx = ""); -void AppendToString(std::stringstream& aStream, const nsSize& sz, +void AppendToString(std::stringstream& aStream, const wr::StickyOffsetBounds& s, const char* pfx = "", const char* sfx = ""); +#endif -void AppendToString(std::stringstream& aStream, const wr::StickyOffsetBounds& s, +void AppendToString(std::stringstream& aStream, const nsSize& sz, const char* pfx = "", const char* sfx = ""); void AppendToString(std::stringstream& aStream, const nsRegion& r, @@ -180,8 +184,10 @@ void AppendToString(std::stringstream& aStream, const FrameMetrics& m, void AppendToString(std::stringstream& aStream, const ScrollableLayerGuid& s, const char* pfx = "", const char* sfx = ""); +#ifdef MOZ_BUILD_WEBRENDER void AppendToString(std::stringstream& aStream, const SLGuidAndRenderRoot& s, const char* pfx = "", const char* sfx = ""); +#endif void AppendToString(std::stringstream& aStream, const ZoomConstraints& z, const char* pfx = "", const char* sfx = ""); diff --git a/gfx/layers/ShareableCanvasRenderer.cpp b/gfx/layers/ShareableCanvasRenderer.cpp index 42e6ea640e..793a45429e 100644 --- a/gfx/layers/ShareableCanvasRenderer.cpp +++ b/gfx/layers/ShareableCanvasRenderer.cpp @@ -176,7 +176,10 @@ CanvasClient::CanvasClientType ShareableCanvasRenderer::GetCanvasClientType() { } void ShareableCanvasRenderer::UpdateCompositableClient( - wr::RenderRoot aRenderRoot) { +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRoot aRenderRoot +#endif +) { if (!CreateCompositable()) { return; } @@ -196,16 +199,28 @@ void ShareableCanvasRenderer::UpdateCompositableClient( gfxCriticalNote << "BufferProvider::SetForwarder failed"; return; } - mCanvasClient->UpdateFromTexture(mBufferProvider->GetTextureClient(), - aRenderRoot); + mCanvasClient->UpdateFromTexture(mBufferProvider->GetTextureClient() +#ifdef MOZ_BUILD_WEBRENDER + , + aRenderRoot +#endif + ); } else { - mCanvasClient->Update(gfx::IntSize(mSize.width, mSize.height), this, - aRenderRoot); + mCanvasClient->Update(gfx::IntSize(mSize.width, mSize.height), this +#ifdef MOZ_BUILD_WEBRENDER + , + aRenderRoot +#endif + ); } FireDidTransactionCallback(); - mCanvasClient->Updated(aRenderRoot); + mCanvasClient->Updated( +#ifdef MOZ_BUILD_WEBRENDER + aRenderRoot +#endif + ); } } // namespace layers diff --git a/gfx/layers/ShareableCanvasRenderer.h b/gfx/layers/ShareableCanvasRenderer.h index b74d0abdc0..5fadace4cf 100644 --- a/gfx/layers/ShareableCanvasRenderer.h +++ b/gfx/layers/ShareableCanvasRenderer.h @@ -38,7 +38,10 @@ class ShareableCanvasRenderer : public CopyableCanvasRenderer { void Destroy() override; void UpdateCompositableClient( - wr::RenderRoot aRenderRoot = wr::RenderRoot::Default); +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRoot aRenderRoot = wr::RenderRoot::Default +#endif + ); const TextureFlags& Flags() const { return mFlags; } diff --git a/gfx/layers/SourceSurfaceSharedData.cpp b/gfx/layers/SourceSurfaceSharedData.cpp index b2ba39363a..32cbfb27df 100644 --- a/gfx/layers/SourceSurfaceSharedData.cpp +++ b/gfx/layers/SourceSurfaceSharedData.cpp @@ -6,7 +6,9 @@ #include "mozilla/Likely.h" #include "mozilla/Types.h" // for decltype -#include "mozilla/layers/SharedSurfacesChild.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/SharedSurfacesChild.h" +#endif #include "base/process_util.h" @@ -20,7 +22,9 @@ # define SHARED_SURFACE_PROTECT_FINALIZED #endif +#ifdef MOZ_BUILD_WEBRENDER using namespace mozilla::layers; +#endif namespace mozilla { namespace gfx { @@ -71,9 +75,11 @@ bool SourceSurfaceSharedData::Init(const IntSize& aSize, int32_t aStride, return false; } +#ifdef MOZ_BUILD_WEBRENDER if (aShare) { layers::SharedSurfacesChild::Share(this); } +#endif return true; } @@ -82,9 +88,15 @@ void SourceSurfaceSharedData::GuaranteePersistance() { // Shared memory is not unmapped until we release SourceSurfaceSharedData. } -void SourceSurfaceSharedData::AddSizeOfExcludingThis( - MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, uint64_t& aExtIdOut) const { +void SourceSurfaceSharedData::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, + size_t& aHeapSizeOut, + size_t& aNonHeapSizeOut, + size_t& aExtHandlesOut +#ifdef MOZ_BUILD_WEBRENDER + , + uint64_t& aExtIdOut +#endif +) const { MutexAutoLock lock(mMutex); if (mBuf) { aNonHeapSizeOut += GetAlignedDataLength(); @@ -92,10 +104,12 @@ void SourceSurfaceSharedData::AddSizeOfExcludingThis( if (!mClosed) { ++aExtHandlesOut; } +#ifdef MOZ_BUILD_WEBRENDER Maybe extId = SharedSurfacesChild::GetExternalId(this); if (extId) { aExtIdOut = wr::AsUint64(extId.ref()); } +#endif } uint8_t* SourceSurfaceSharedData::GetDataInternal() const { diff --git a/gfx/layers/SourceSurfaceSharedData.h b/gfx/layers/SourceSurfaceSharedData.h index d2fa03aa5f..3e4925505d 100644 --- a/gfx/layers/SourceSurfaceSharedData.h +++ b/gfx/layers/SourceSurfaceSharedData.h @@ -40,8 +40,13 @@ class SourceSurfaceSharedDataWrapper final : public DataSourceSurface { : mStride(0), mConsumers(0), mFormat(SurfaceFormat::UNKNOWN), - mCreatorPid(0), - mCreatorRef(true) {} + mCreatorPid(0) +#ifdef MOZ_BUILD_WEBRENDER + , + mCreatorRef(true) +#endif + { + } bool Init(const IntSize& aSize, int32_t aStride, SurfaceFormat aFormat, const SharedMemoryBasic::Handle& aHandle, @@ -63,8 +68,13 @@ class SourceSurfaceSharedDataWrapper final : public DataSourceSurface { bool AddConsumer() { return ++mConsumers == 1; } - bool RemoveConsumer(bool aForCreator) { + bool RemoveConsumer( +#ifdef MOZ_BUILD_WEBRENDER + bool aForCreator +#endif + ) { MOZ_ASSERT(mConsumers > 0); +#ifdef MOZ_BUILD_WEBRENDER if (aForCreator) { if (!mCreatorRef) { MOZ_ASSERT_UNREACHABLE("Already released creator reference!"); @@ -72,15 +82,18 @@ class SourceSurfaceSharedDataWrapper final : public DataSourceSurface { } mCreatorRef = false; } +#endif return --mConsumers == 0; } +#ifdef MOZ_BUILD_WEBRENDER uint32_t GetConsumers() const { MOZ_ASSERT(mConsumers > 0); return mConsumers; } bool HasCreatorRef() const { return mCreatorRef; } +#endif private: size_t GetDataLength() const { @@ -97,7 +110,9 @@ class SourceSurfaceSharedDataWrapper final : public DataSourceSurface { RefPtr mBuf; SurfaceFormat mFormat; base::ProcessId mCreatorPid; +#ifdef MOZ_BUILD_WEBRENDER bool mCreatorRef; +#endif }; /** @@ -142,8 +157,12 @@ class SourceSurfaceSharedData final : public DataSourceSurface { void GuaranteePersistance() override; void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, - size_t& aNonHeapSizeOut, size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const override; + size_t& aNonHeapSizeOut, size_t& aExtHandlesOut +#ifdef MOZ_BUILD_WEBRENDER + , + uint64_t& aExtIdOut +#endif + ) const override; bool OnHeap() const override { return false; } diff --git a/gfx/layers/SourceSurfaceVolatileData.cpp b/gfx/layers/SourceSurfaceVolatileData.cpp index b5231febe6..9fea6c415d 100644 --- a/gfx/layers/SourceSurfaceVolatileData.cpp +++ b/gfx/layers/SourceSurfaceVolatileData.cpp @@ -33,7 +33,12 @@ void SourceSurfaceVolatileData::GuaranteePersistance() { void SourceSurfaceVolatileData::AddSizeOfExcludingThis( MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, size_t& aNonHeapSizeOut, - size_t& aExtHandlesOut, uint64_t& aExtIdOut) const { + size_t& aExtHandlesOut +#ifdef MOZ_BUILD_WEBRENDER + , + uint64_t& aExtIdOut +#endif +) const { if (mVBuf) { aHeapSizeOut += mVBuf->HeapSizeOfExcludingThis(aMallocSizeOf); aNonHeapSizeOut += mVBuf->NonHeapSizeOfExcludingThis(); diff --git a/gfx/layers/SourceSurfaceVolatileData.h b/gfx/layers/SourceSurfaceVolatileData.h index c83010e4a7..fb15c0c439 100644 --- a/gfx/layers/SourceSurfaceVolatileData.h +++ b/gfx/layers/SourceSurfaceVolatileData.h @@ -43,8 +43,12 @@ class SourceSurfaceVolatileData : public DataSourceSurface { void GuaranteePersistance() override; void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, - size_t& aNonHeapSizeOut, size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const override; + size_t& aNonHeapSizeOut, size_t& aExtHandlesOut +#ifdef MOZ_BUILD_WEBRENDER + , + uint64_t& aExtIdOut +#endif + ) const override; bool OnHeap() const override { return mVBuf->OnHeap(); } diff --git a/gfx/layers/UpdateImageHelper.h b/gfx/layers/UpdateImageHelper.h index 1772311ba7..5abd2fa551 100644 --- a/gfx/layers/UpdateImageHelper.h +++ b/gfx/layers/UpdateImageHelper.h @@ -50,7 +50,11 @@ class UpdateImageHelper { return target.forget(); } - bool UpdateImage(wr::RenderRoot aRenderRoot) { + bool UpdateImage( +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRoot aRenderRoot +#endif + ) { if (!mTexture) { return false; } @@ -63,8 +67,12 @@ class UpdateImageHelper { RefPtr image = new TextureWrapperImage( mTexture, gfx::IntRect(gfx::IntPoint(0, 0), mImageSize)); mImageContainer->SetCurrentImageInTransaction(image); - return mImageClient->UpdateImage(mImageContainer, /* unused */ 0, - Some(aRenderRoot)); + return mImageClient->UpdateImage(mImageContainer, /* unused */ 0 +#ifdef MOZ_BUILD_WEBRENDER + , + Some(aRenderRoot) +#endif + ); } private: diff --git a/gfx/layers/apz/public/APZSampler.h b/gfx/layers/apz/public/APZSampler.h index a93c4efe8a..55c0acd930 100644 --- a/gfx/layers/apz/public/APZSampler.h +++ b/gfx/layers/apz/public/APZSampler.h @@ -19,12 +19,14 @@ namespace mozilla { class TimeStamp; +#ifdef MOZ_BUILD_WEBRENDER namespace wr { struct Transaction; class TransactionWrapper; struct WrTransformProperty; struct WrWindowId; } // namespace wr +#endif namespace layers { @@ -41,8 +43,14 @@ class APZSampler { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(APZSampler) public: - APZSampler(const RefPtr& aApz, bool aIsUsingWebRender); - + APZSampler(const RefPtr& aApz +#ifdef MOZ_BUILD_WEBRENDER + , + bool aIsUsingWebRender +#endif + ); + +#ifdef MOZ_BUILD_WEBRENDER // Whoever creates this sampler is responsible for calling Destroy() on it // before releasing the owning refptr. void Destroy(); @@ -63,6 +71,7 @@ class APZSampler { void SetSampleTime(const TimeStamp& aSampleTime); void SampleForWebRender(wr::TransactionWrapper& aTxn, wr::RenderRoot aRenderRoot); +#endif bool SampleAnimations(const LayerMetricsWrapper& aLayer, const TimeStamp& aSampleTime); @@ -114,12 +123,13 @@ class APZSampler { protected: virtual ~APZSampler(); +#ifdef MOZ_BUILD_WEBRENDER static already_AddRefed GetSampler( const wr::WrWindowId& aWindowId); +#endif private: RefPtr mApz; - bool mIsUsingWebRender; // Used to manage the mapping from a WR window id to APZSampler. These are // only used if WebRender is enabled. Both sWindowIdMap and mWindowId should @@ -127,10 +137,11 @@ class APZSampler { // StaticAutoPtr wrapper on sWindowIdMap to avoid a static initializer for the // unordered_map. This also avoids the initializer/memory allocation in cases // where we're not using WebRender. +#ifdef MOZ_BUILD_WEBRENDER static StaticMutex sWindowIdLock; static StaticAutoPtr>> sWindowIdMap; - Maybe mWindowId; + bool mIsUsingWebRender; // Lock used to protected mSamplerThreadId mutable Mutex mThreadIdLock; @@ -139,9 +150,12 @@ class APZSampler { // this APZSampler instance. Maybe mSamplerThreadId; + Maybe mWindowId; + Mutex mSampleTimeLock; // Can only be accessed or modified while holding mSampleTimeLock. TimeStamp mSampleTime; +#endif }; } // namespace layers diff --git a/gfx/layers/apz/public/APZUpdater.h b/gfx/layers/apz/public/APZUpdater.h index 2391a4acc1..ad36d3f2ca 100644 --- a/gfx/layers/apz/public/APZUpdater.h +++ b/gfx/layers/apz/public/APZUpdater.h @@ -10,12 +10,14 @@ #include "base/platform_thread.h" // for PlatformThreadId #include "LayersTypes.h" -#include "APZTypes.h" #include "mozilla/layers/APZTestData.h" -#include "mozilla/layers/WebRenderScrollData.h" #include "mozilla/StaticMutex.h" #include "mozilla/StaticPtr.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "APZTypes.h" +# include "mozilla/layers/WebRenderScrollData.h" +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "nsThreadUtils.h" #include "Units.h" @@ -26,7 +28,9 @@ namespace layers { class APZCTreeManager; class FocusTarget; class Layer; +#ifdef MOZ_BUILD_WEBRENDER class WebRenderScrollData; +#endif /** * This interface is used to send updates or otherwise mutate APZ internal @@ -39,9 +43,15 @@ class APZUpdater { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(APZUpdater) public: - APZUpdater(const RefPtr& aApz, bool aIsUsingWebRender); + APZUpdater(const RefPtr& aApz +#ifdef MOZ_BUILD_WEBRENDER + , + bool aIsUsingWebRender +#endif + ); bool HasTreeManager(const RefPtr& aApz); +#ifdef MOZ_BUILD_WEBRENDER void SetWebRenderWindowId(const wr::WindowId& aWindowId); /** @@ -55,13 +65,22 @@ class APZUpdater { static void CompleteSceneSwap(const wr::WrWindowId& aWindowId, const wr::WrPipelineInfo& aInfo); static void ProcessPendingTasks(const wr::WrWindowId& aWindowId); +#endif - void ClearTree(LayersId aRootLayersId); + void ClearTree( +#ifdef MOZ_BUILD_WEBRENDER + LayersId aRootLayersId +#endif + ); void UpdateFocusState(LayersId aRootLayerTreeId, +#ifdef MOZ_BUILD_WEBRENDER WRRootId aOriginatingWrRootId, +#else + LayersId aOriginatingLayersId, +#endif const FocusTarget& aFocusTarget); - void UpdateHitTestingTree(Layer* aRoot, - bool aIsFirstPaint, LayersId aOriginatingLayersId, + void UpdateHitTestingTree(Layer* aRoot, bool aIsFirstPaint, + LayersId aOriginatingLayersId, uint32_t aPaintSequenceNumber); /** * This should be called (in the WR-enabled case) when the compositor receives @@ -71,6 +90,7 @@ class APZUpdater { * This function will store the new scroll data and update the focus state and * hit-testing tree. */ +#ifdef MOZ_BUILD_WEBRENDER void UpdateScrollDataAndTreeState(WRRootId aRootLayerTreeId, WRRootId aOriginatingWrRootId, const wr::Epoch& aEpoch, @@ -85,22 +105,51 @@ class APZUpdater { WRRootId aOriginatingWrRootId, ScrollUpdatesMap&& aUpdates, uint32_t aPaintSequenceNumber); - - void NotifyLayerTreeAdopted(WRRootId aWrRootId, - const RefPtr& aOldUpdater); - void NotifyLayerTreeRemoved(WRRootId aWrRootId); - - bool GetAPZTestData(WRRootId aWrRootId, APZTestData* aOutData); - - void SetTestAsyncScrollOffset(WRRootId aWrRootId, - const ScrollableLayerGuid::ViewID& aScrollId, - const CSSPoint& aOffset); - void SetTestAsyncZoom(WRRootId aWrRootId, - const ScrollableLayerGuid::ViewID& aScrollId, - const LayerToParentLayerScale& aZoom); +#endif + + void NotifyLayerTreeAdopted( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId, +#else + LayersId aLayersId, +#endif + const RefPtr& aOldUpdater); + void NotifyLayerTreeRemoved( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId +#else + LayersId aLayersId +#endif + ); + + bool GetAPZTestData( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId, +#else + LayersId aLayersId, +#endif + APZTestData* aOutData); + + void SetTestAsyncScrollOffset( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId, +#else + LayersId aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, const CSSPoint& aOffset); + void SetTestAsyncZoom( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId, +#else + LayersId aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom); // This can only be called on the updater thread. +#ifdef MOZ_BUILD_WEBRENDER const WebRenderScrollData* GetScrollData(WRRootId aWrRootId) const; +#endif /** * This can be used to assert that the current thread is the @@ -125,8 +174,11 @@ class APZUpdater { * render roots the task is tied to so that this ordering dependency can be * respected. */ - void RunOnUpdaterThread(UpdaterQueueSelector aSelector, - already_AddRefed aTask); + void RunOnUpdaterThread( +#ifdef MOZ_BUILD_WEBRENDER + UpdaterQueueSelector aSelector, +#endif + already_AddRefed aTask); /** * Returns true if currently on the APZUpdater's "updater thread". @@ -143,21 +195,27 @@ class APZUpdater { * * See the RunOnUpdaterThread method for details on the aSelector argument. */ - void RunOnControllerThread(UpdaterQueueSelector aSelector, - already_AddRefed aTask); + void RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER + UpdaterQueueSelector aSelector, +#endif + already_AddRefed aTask); protected: virtual ~APZUpdater(); +#ifdef MOZ_BUILD_WEBRENDER bool UsingWebRenderUpdaterThread() const; static already_AddRefed GetUpdater( const wr::WrWindowId& aWindowId); void ProcessQueue(); +#endif private: RefPtr mApz; bool mDestroyed; +#ifdef MOZ_BUILD_WEBRENDER bool mIsUsingWebRender; // Map from WRRoot id to WebRenderScrollData. This can only be touched on @@ -238,6 +296,7 @@ class APZUpdater { // is exactly one render root per task, there is no guaranteed ordering for // tasks with different render roots. std::deque mUpdaterQueue; +#endif // MOZ_BUILD_WEBRENDER }; } // namespace layers diff --git a/gfx/layers/apz/public/CompositorController.h b/gfx/layers/apz/public/CompositorController.h index af85c9d335..49a85094a0 100644 --- a/gfx/layers/apz/public/CompositorController.h +++ b/gfx/layers/apz/public/CompositorController.h @@ -7,7 +7,9 @@ #include "nsISupportsImpl.h" // for NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING #include "mozilla/Maybe.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif namespace mozilla { namespace layers { @@ -23,7 +25,10 @@ class CompositorController { * scheduled. */ virtual void ScheduleRenderOnCompositorThread( - const wr::RenderRootSet& aRenderRoots) = 0; +#ifdef MOZ_BUILD_WEBRENDER + const wr::RenderRootSet& aRenderRoots +#endif + ) = 0; virtual void ScheduleHideAllPluginWindows() = 0; virtual void ScheduleShowAllPluginWindows() = 0; diff --git a/gfx/layers/apz/public/IAPZCTreeManager.h b/gfx/layers/apz/public/IAPZCTreeManager.h index 4bbc49c828..c4d04c8951 100644 --- a/gfx/layers/apz/public/IAPZCTreeManager.h +++ b/gfx/layers/apz/public/IAPZCTreeManager.h @@ -7,7 +7,9 @@ #include // for uint64_t, uint32_t -#include "mozilla/layers/APZTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/APZTypes.h" +#endif #include "mozilla/layers/LayersTypes.h" // for TouchBehaviorFlags #include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid, etc #include "mozilla/layers/ZoomConstraints.h" // for ZoomConstraints @@ -54,9 +56,13 @@ class IAPZCTreeManager { * up. |aRect| must be given in CSS pixels, relative to the document. * |aFlags| is a combination of the ZoomToRectBehavior enum values. */ - virtual void ZoomToRect(const SLGuidAndRenderRoot& aGuid, - const CSSRect& aRect, - const uint32_t aFlags = DEFAULT_BEHAVIOR) = 0; + virtual void ZoomToRect( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const CSSRect& aRect, const uint32_t aFlags = DEFAULT_BEHAVIOR) = 0; /** * If we have touch listeners, this should always be called when we know @@ -80,7 +86,12 @@ class IAPZCTreeManager { * should be set to ScrollableLayerGuid::NULL_SCROLL_ID. */ virtual void SetTargetAPZC(uint64_t aInputBlockId, - const nsTArray& aTargets) = 0; +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) = 0; /** * Updates any zoom constraints contained in the tag. @@ -88,7 +99,11 @@ class IAPZCTreeManager { * the given |aGuid| are cleared. */ virtual void UpdateZoomConstraints( +#ifdef MOZ_BUILD_WEBRENDER const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif const Maybe& aConstraints) = 0; virtual void SetDPI(float aDpiValue) = 0; @@ -105,13 +120,29 @@ class IAPZCTreeManager { virtual void SetAllowedTouchBehavior( uint64_t aInputBlockId, const nsTArray& aValues) = 0; - virtual void StartScrollbarDrag(const SLGuidAndRenderRoot& aGuid, - const AsyncDragMetrics& aDragMetrics) = 0; - - virtual bool StartAutoscroll(const SLGuidAndRenderRoot& aGuid, - const ScreenPoint& aAnchorLocation) = 0; + virtual void StartScrollbarDrag( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const AsyncDragMetrics& aDragMetrics) = 0; - virtual void StopAutoscroll(const SLGuidAndRenderRoot& aGuid) = 0; + virtual bool StartAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const ScreenPoint& aAnchorLocation) = 0; + + virtual void StopAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif + ) = 0; /** * Function used to disable LongTap gestures. diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 3823c464b4..caa5609d97 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -33,7 +33,6 @@ #include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent, etc #include "mozilla/layers/LayerMetricsWrapper.h" #include "mozilla/layers/MatrixMessage.h" -#include "mozilla/layers/WebRenderScrollDataWrapper.h" #include "mozilla/MouseEvents.h" #include "mozilla/mozalloc.h" // for operator new #include "mozilla/Preferences.h" // for Preferences @@ -42,7 +41,10 @@ #include "mozilla/StaticPrefs_layout.h" #include "mozilla/TouchEvents.h" #include "mozilla/EventStateManager.h" // for WheelPrefs -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderScrollDataWrapper.h" +# include "mozilla/webrender/WebRenderAPI.h" +#endif #include "nsDebug.h" // for NS_WARNING #include "nsPoint.h" // for nsIntPoint #include "nsThreadUtils.h" // for NS_IsMainThread @@ -82,10 +84,18 @@ typedef CompositorBridgeParent::LayerTreeState LayerTreeState; struct APZCTreeManager::TreeBuildingState { TreeBuildingState(LayersId aRootLayersId, bool aIsFirstPaint, - WRRootId aOriginatingWrRootId, APZTestData* aTestData, - uint32_t aPaintSequence) +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aOriginatingWrRootId, +#else + LayersId aOriginatingLayersId, +#endif + APZTestData* aTestData, uint32_t aPaintSequence) : mIsFirstPaint(aIsFirstPaint), +#ifdef MOZ_BUILD_WEBRENDER mOriginatingWrRootId(aOriginatingWrRootId), +#else + mOriginatingLayersId(aOriginatingLayersId), +#endif mPaintLogger(aTestData, aPaintSequence) { CompositorBridgeParent::CallWithIndirectShadowTree( aRootLayersId, [this](LayerTreeState& aState) -> void { @@ -101,7 +111,11 @@ struct APZCTreeManager::TreeBuildingState { RefPtr mCompositorController; RefPtr mInProcessSharingController; const bool mIsFirstPaint; +#ifdef MOZ_BUILD_WEBRENDER const WRRootId mOriginatingWrRootId; +#else + const LayersId mOriginatingLayersId; +#endif const APZPaintLogHelper mPaintLogger; // State that is updated as we perform the tree build @@ -151,7 +165,9 @@ struct APZCTreeManager::TreeBuildingState { // to the RCD's APZC instance. Once it is set on the APZC instance, the value // is cleared back to Nothing(). Note that this is only used in the WebRender // codepath. +#ifdef MOZ_BUILD_WEBRENDER Maybe mZoomAnimationId; +#endif }; class APZCTreeManager::CheckerboardFlushObserver : public nsIObserver { @@ -338,10 +354,17 @@ void APZCTreeManager::NotifyLayerTreeRemoved(LayersId aLayersId) { } AsyncPanZoomController* APZCTreeManager::NewAPZCInstance( - LayersId aLayersId, GeckoContentController* aController, - wr::RenderRoot aRenderRoot) { + LayersId aLayersId, GeckoContentController* aController +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif +) { return new AsyncPanZoomController( - aLayersId, this, mInputQueue, aController, aRenderRoot, + aLayersId, this, mInputQueue, aController, +#ifdef MOZ_BUILD_WEBRENDER + aRenderRoot, +#endif AsyncPanZoomController::USE_GESTURE_DETECTOR); } @@ -367,7 +390,11 @@ template void // ScrollNode is a LayerMetricsWrapper or a WebRenderScrollDataWrapper APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot, bool aIsFirstPaint, +#ifdef MOZ_BUILD_WEBRENDER WRRootId aOriginatingWrRootId, +#else + LayersId aOriginatingLayersId, +#endif uint32_t aPaintSequenceNumber) { RecursiveMutexAutoLock lock(mTreeLock); @@ -377,13 +404,24 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot, if (StaticPrefs::apz_test_logging_enabled()) { MutexAutoLock lock(mTestDataLock); UniquePtr ptr = MakeUnique(); - auto result = mTestData.insert( - std::make_pair(aOriginatingWrRootId.mLayersId, std::move(ptr))); + auto result = mTestData.insert(std::make_pair( +#ifdef MOZ_BUILD_WEBRENDER + aOriginatingWrRootId.mLayersId, +#else + aOriginatingLayersId, +#endif + std::move(ptr))); testData = result.first->second.get(); + testData->StartNewPaint(aPaintSequenceNumber); } - TreeBuildingState state(mRootLayersId, aIsFirstPaint, aOriginatingWrRootId, + TreeBuildingState state(mRootLayersId, aIsFirstPaint, +#ifdef MOZ_BUILD_WEBRENDER + aOriginatingWrRootId, +#else + aOriginatingLayersId, +#endif testData, aPaintSequenceNumber); // We do this business with collecting the entire tree into an array because @@ -416,7 +454,9 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot, HitTestingTreeNode* parent = nullptr; HitTestingTreeNode* next = nullptr; LayersId layersId = mRootLayersId; +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot renderRoot = wr::RenderRoot::Default; +#endif ancestorTransforms.push(AncestorTransform()); state.mParentHasPerspective.push(false); @@ -446,20 +486,27 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot, HitTestingTreeNode* node = PrepareNodeForLayer( lock, aLayerMetrics, aLayerMetrics.Metrics(), layersId, - ancestorTransforms.top(), parent, next, state, renderRoot); + ancestorTransforms.top(), parent, next, state +#ifdef MOZ_BUILD_WEBRENDER + , + renderRoot +#endif + ); MOZ_ASSERT(node); AsyncPanZoomController* apzc = node->GetApzc(); aLayerMetrics.SetApzc(apzc); - // GetScrollbarAnimationId is only set when webrender is enabled, - // which limits the extra thumb mapping work to the webrender-enabled - // case where it is needed. - // Note also that when webrender is enabled, a "valid" animation id - // is always nonzero, so we don't need to worry about handling the - // case where WR is enabled and the animation id is zero. + // GetScrollbarAnimationId is only set when webrender is enabled, + // which limits the extra thumb mapping work to the webrender-enabled + // case where it is needed. + // Note also that when webrender is enabled, a "valid" animation id + // is always nonzero, so we don't need to worry about handling the + // case where WR is enabled and the animation id is zero. +#ifdef MOZ_BUILD_WEBRENDER if (node->IsScrollThumbNode() && node->GetScrollbarAnimationId()) { state.mScrollThumbs.push_back(node); } +#endif if (apzc && node->IsPrimaryHolder()) { state.mScrollTargets[apzc->GetGuid()] = node; } @@ -493,10 +540,12 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot, if (Maybe newLayersId = aLayerMetrics.GetReferentId()) { layersId = *newLayersId; } +#ifdef MOZ_BUILD_WEBRENDER if (Maybe newRenderRoot = aLayerMetrics.GetReferentRenderRoot()) { renderRoot = *newRenderRoot; } +#endif indents.push(gfx::TreeAutoIndent(mApzcTreeLog)); state.mParentHasPerspective.push( @@ -563,6 +612,7 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot, // We do not support tree structures where the root node has siblings. MOZ_ASSERT(!(mRootNode && mRootNode->GetPrevSibling())); +#ifdef MOZ_BUILD_WEBRENDER { // scope lock and update our mApzcMap before we destroy all the unused // APZC instances MutexAutoLock lock(mMapLock); @@ -589,6 +639,7 @@ APZCTreeManager::UpdateHitTestingTreeImpl(const ScrollNode& aRoot, target->IsAncestorOf(thumb)); } } +#endif for (size_t i = 0; i < state.mNodesToDestroy.Length(); i++) { APZCTM_LOG("Destroying node at %p with APZC %p\n", @@ -626,18 +677,22 @@ void APZCTreeManager::UpdateHitTestingTree(Layer* aRoot, bool aIsFirstPaint, LayerMetricsWrapper root(aRoot); UpdateHitTestingTreeImpl(root, aIsFirstPaint, +#ifdef MOZ_BUILD_WEBRENDER WRRootId::NonWebRender(aOriginatingLayersId), +#else + aOriginatingLayersId, +#endif aPaintSequenceNumber); } +#ifdef MOZ_BUILD_WEBRENDER void APZCTreeManager::UpdateHitTestingTree( - const WebRenderScrollDataWrapper& aScrollWrapper, - bool aIsFirstPaint, WRRootId aOriginatingWrRootId, - uint32_t aPaintSequenceNumber) { + const WebRenderScrollDataWrapper& aScrollWrapper, bool aIsFirstPaint, + WRRootId aOriginatingWrRootId, uint32_t aPaintSequenceNumber) { AssertOnUpdaterThread(); - UpdateHitTestingTreeImpl(aScrollWrapper, aIsFirstPaint, - aOriginatingWrRootId, aPaintSequenceNumber); + UpdateHitTestingTreeImpl(aScrollWrapper, aIsFirstPaint, aOriginatingWrRootId, + aPaintSequenceNumber); } void APZCTreeManager::SampleForWebRender(wr::TransactionWrapper& aTxn, @@ -738,6 +793,7 @@ void APZCTreeManager::SampleForWebRender(wr::TransactionWrapper& aTxn, } } } +#endif // MOZ_BUILD_WEBRENDER // Compute the clip region to be used for a layer with an APZC. This function // is only called for layers which actually have scrollable metrics and an APZC. @@ -841,14 +897,25 @@ static EventRegionsOverride GetEventRegionsOverride(HitTestingTreeNode* aParent, return result; } -void APZCTreeManager::StartScrollbarDrag(const SLGuidAndRenderRoot& aGuid, - const AsyncDragMetrics& aDragMetrics) { +void APZCTreeManager::StartScrollbarDrag( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const AsyncDragMetrics& aDragMetrics) { APZThreadUtils::AssertOnControllerThread(); RefPtr apzc = +#ifdef MOZ_BUILD_WEBRENDER GetTargetAPZC(aGuid.mScrollableLayerGuid); if (!apzc) { NotifyScrollbarDragRejected(aGuid.mScrollableLayerGuid); +#else + GetTargetAPZC(aGuid); + if (!apzc) { + NotifyScrollbarDragRejected(aGuid); +#endif return; } @@ -856,19 +923,31 @@ void APZCTreeManager::StartScrollbarDrag(const SLGuidAndRenderRoot& aGuid, mInputQueue->ConfirmDragBlock(inputBlockId, apzc, aDragMetrics); } -bool APZCTreeManager::StartAutoscroll(const SLGuidAndRenderRoot& aGuid, - const ScreenPoint& aAnchorLocation) { +bool APZCTreeManager::StartAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const ScreenPoint& aAnchorLocation) { APZThreadUtils::AssertOnControllerThread(); - RefPtr apzc = - GetTargetAPZC(aGuid.mScrollableLayerGuid); + RefPtr apzc = GetTargetAPZC(aGuid +#ifdef MOZ_BUILD_WEBRENDER + .mScrollableLayerGuid +#endif + ); if (!apzc) { if (XRE_IsGPUProcess()) { // If we're in the compositor process, the "return false" will be // ignored because the query comes over the PAPZCTreeManager protocol // via an async message. In this case, send an explicit rejection // message to content. - NotifyAutoscrollRejected(aGuid.mScrollableLayerGuid); + NotifyAutoscrollRejected(aGuid +#ifdef MOZ_BUILD_WEBRENDER + .mScrollableLayerGuid +#endif + ); } return false; } @@ -877,11 +956,21 @@ bool APZCTreeManager::StartAutoscroll(const SLGuidAndRenderRoot& aGuid, return true; } -void APZCTreeManager::StopAutoscroll(const SLGuidAndRenderRoot& aGuid) { +void APZCTreeManager::StopAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif +) { APZThreadUtils::AssertOnControllerThread(); if (RefPtr apzc = - GetTargetAPZC(aGuid.mScrollableLayerGuid)) { + GetTargetAPZC(aGuid +#ifdef MOZ_BUILD_WEBRENDER + .mScrollableLayerGuid +#endif + )) { apzc->StopAutoscroll(); } } @@ -918,11 +1007,11 @@ template void SetHitTestData(HitTestingTreeNode* aNode, HitTestingTreeNode* aParent, const ScrollNode& aLayer, const Maybe& aClipRegion) { - aNode->SetHitTestData( - GetEventRegions(aLayer), aLayer.GetVisibleRegion(), - aLayer.GetTransformTyped(), aClipRegion, - GetEventRegionsOverride(aParent, aLayer), aLayer.IsBackfaceHidden(), - !!aLayer.IsAsyncZoomContainer()); + aNode->SetHitTestData(GetEventRegions(aLayer), aLayer.GetVisibleRegion(), + aLayer.GetTransformTyped(), aClipRegion, + GetEventRegionsOverride(aParent, aLayer), + aLayer.IsBackfaceHidden(), + !!aLayer.IsAsyncZoomContainer()); } template @@ -930,8 +1019,12 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( const RecursiveMutexAutoLock& aProofOfTreeLock, const ScrollNode& aLayer, const FrameMetrics& aMetrics, LayersId aLayersId, const AncestorTransform& aAncestorTransform, HitTestingTreeNode* aParent, - HitTestingTreeNode* aNextSibling, TreeBuildingState& aState, - wr::RenderRoot aRenderRoot) { + HitTestingTreeNode* aNextSibling, TreeBuildingState& aState +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif +) { bool needsApzc = true; if (!aMetrics.IsScrollable()) { needsApzc = false; @@ -954,9 +1047,11 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( bool parentHasPerspective = aState.mParentHasPerspective.top(); +#ifdef MOZ_BUILD_WEBRENDER if (Maybe zoomAnimationId = aLayer.GetZoomAnimationId()) { aState.mZoomAnimationId = zoomAnimationId; } +#endif RefPtr node = nullptr; if (!needsApzc) { @@ -969,8 +1064,11 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( (!parentHasPerspective && aLayer.GetClipRect()) ? Some(ParentLayerIntRegion(*aLayer.GetClipRect())) : Nothing()); - node->SetScrollbarData(aLayer.GetScrollbarAnimationId(), - aLayer.GetScrollbarData()); + node->SetScrollbarData( +#ifdef MOZ_BUILD_WEBRENDER + aLayer.GetScrollbarAnimationId(), +#endif + aLayer.GetScrollbarData()); node->SetFixedPosData(aLayer.GetFixedPositionScrollContainerId(), aLayer.GetFixedPositionSides()); return node; @@ -1046,7 +1144,12 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( // a destroyed APZC and so we need to throw that out and make a new one. bool newApzc = (apzc == nullptr || apzc->IsDestroyed()); if (newApzc) { - apzc = NewAPZCInstance(aLayersId, geckoContentController, aRenderRoot); + apzc = NewAPZCInstance(aLayersId, geckoContentController +#ifdef MOZ_BUILD_WEBRENDER + , + aRenderRoot +#endif + ); apzc->SetCompositorController(aState.mCompositorController.get()); if (crossProcessSharingController) { apzc->SetMetricsSharingController(crossProcessSharingController); @@ -1067,10 +1170,12 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( node->SetLastChild(nullptr); } +#ifdef MOZ_BUILD_WEBRENDER if (aMetrics.IsRootContent()) { apzc->SetZoomAnimationId(aState.mZoomAnimationId); aState.mZoomAnimationId = Nothing(); } +#endif APZCTM_LOG( "Using APZC %p for layer %p with identifiers %" PRIx64 " %" PRId64 "\n", @@ -1078,7 +1183,12 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( apzc->NotifyLayersUpdated( aLayer.Metadata(), aState.mIsFirstPaint, - WRRootId(aLayersId, aRenderRoot) == aState.mOriginatingWrRootId); +#ifdef MOZ_BUILD_WEBRENDER + WRRootId(aLayersId, aRenderRoot) == aState.mOriginatingWrRootId +#else + aLayersId == aState.mOriginatingLayersId +#endif + ); // Since this is the first time we are encountering an APZC with this guid, // the node holding it must be the primary holder. It may be newly-created @@ -1102,7 +1212,13 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( // that originated the update, because the only identifying information // we are logging about APZCs is the scroll id, and otherwise we could // confuse APZCs from different layer trees with the same scroll id. - if (aLayersId == aState.mOriginatingWrRootId.mLayersId) { + if (aLayersId == +#ifdef MOZ_BUILD_WEBRENDER + aState.mOriginatingWrRootId.mLayersId +#else + aState.mOriginatingLayersId +#endif + ) { if (apzc->HasNoParentWithSameLayersId()) { aState.mPaintLogger.LogTestData(aMetrics.GetScrollId(), "hasNoParentWithSameLayersId", true); @@ -1194,8 +1310,11 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( // Note: if layer properties must be propagated to nodes, RecvUpdate in // LayerTransactionParent.cpp must ensure that APZ will be notified // when those properties change. - node->SetScrollbarData(aLayer.GetScrollbarAnimationId(), - aLayer.GetScrollbarData()); + node->SetScrollbarData( +#ifdef MOZ_BUILD_WEBRENDER + aLayer.GetScrollbarAnimationId(), +#endif + aLayer.GetScrollbarData()); node->SetFixedPosData(aLayer.GetFixedPositionScrollContainerId(), aLayer.GetFixedPositionSides()); return node; @@ -1719,10 +1838,12 @@ APZCTreeManager::HitTestResult APZCTreeManager::GetTouchInputBlockAPZC( * APZ-aware listeners. */ bool MayHaveApzAwareListeners(CompositorHitTestInfo aHitResult) { +#ifdef MOZ_BUILD_WEBRENDER // With WebRender, we can answer this accurately. if (gfx::gfxVars::UseWebRender()) { return aHitResult.contains(CompositorHitTestFlags::eApzAwareListeners); } +#endif // With non-WebRender, several hit results including eApzAwareListeners // get lumped together into the dispatch-to-content region. We err on // the side of false positives. @@ -2156,15 +2277,23 @@ void APZCTreeManager::SetKeyboardMap(const KeyboardMap& aKeyboardMap) { mKeyboardMap = aKeyboardMap; } -void APZCTreeManager::ZoomToRect(const SLGuidAndRenderRoot& aGuid, - const CSSRect& aRect, const uint32_t aFlags) { +void APZCTreeManager::ZoomToRect( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const CSSRect& aRect, const uint32_t aFlags) { // We could probably move this to run on the updater thread if needed, but // either way we should restrict it to a single thread. For now let's use the // controller thread. APZThreadUtils::AssertOnControllerThread(); - RefPtr apzc = - GetTargetAPZC(aGuid.mScrollableLayerGuid); + RefPtr apzc = GetTargetAPZC(aGuid +#ifdef MOZ_BUILD_WEBRENDER + .mScrollableLayerGuid +#endif + ); if (apzc) { apzc->ZoomToRect(aRect, aFlags); } @@ -2178,23 +2307,40 @@ void APZCTreeManager::ContentReceivedInputBlock(uint64_t aInputBlockId, } void APZCTreeManager::SetTargetAPZC( - uint64_t aInputBlockId, const nsTArray& aTargets) { - APZThreadUtils::AssertOnControllerThread(); + uint64_t aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif +) { RefPtr target = nullptr; if (aTargets.Length() > 0) { - target = GetTargetAPZC(aTargets[0].mScrollableLayerGuid); + target = GetTargetAPZC(aTargets[0] +#ifdef MOZ_BUILD_WEBRENDER + .mScrollableLayerGuid +#endif + ); } for (size_t i = 1; i < aTargets.Length(); i++) { RefPtr apzc = - GetTargetAPZC(aTargets[i].mScrollableLayerGuid); + GetTargetAPZC(aTargets[i] +#ifdef MOZ_BUILD_WEBRENDER + .mScrollableLayerGuid +#endif + ); target = GetZoomableTarget(target, apzc); } mInputQueue->SetConfirmedTargetApzc(aInputBlockId, target); } void APZCTreeManager::UpdateZoomConstraints( +#ifdef MOZ_BUILD_WEBRENDER const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif const Maybe& aConstraints) { if (!GetUpdater()->IsUpdaterThread()) { // This can happen if we're in the UI process and got a call directly from @@ -2204,8 +2350,13 @@ void APZCTreeManager::UpdateZoomConstraints( // enabled, since the call will go over PAPZCTreeManager and arrive on the // compositor thread in the GPU process. GetUpdater()->RunOnUpdaterThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(aGuid.GetWRRootId()), - NewRunnableMethod>( + NewRunnableMethod>( "APZCTreeManager::UpdateZoomConstraints", this, &APZCTreeManager::UpdateZoomConstraints, aGuid, aConstraints)); return; @@ -2213,7 +2364,11 @@ void APZCTreeManager::UpdateZoomConstraints( AssertOnUpdaterThread(); +#ifdef MOZ_BUILD_WEBRENDER ScrollableLayerGuid guid = aGuid.mScrollableLayerGuid; +#else + ScrollableLayerGuid guid = aGuid; +#endif RecursiveMutexAutoLock lock(mTreeLock); RefPtr node = GetTargetNode(guid, nullptr); MOZ_ASSERT(!node || node->GetApzc()); // any node returned must have an APZC @@ -2569,12 +2724,15 @@ APZCTreeManager::HitTestResult APZCTreeManager::GetTargetAPZC( const ScreenPoint& aPoint) { RecursiveMutexAutoLock lock(mTreeLock); +#ifdef MOZ_BUILD_WEBRENDER if (gfx::gfxVars::UseWebRender()) { return GetAPZCAtPointWR(aPoint, lock); } +#endif return GetAPZCAtPoint(aPoint, lock); } +#ifdef MOZ_BUILD_WEBRENDER APZCTreeManager::HitTestResult APZCTreeManager::GetAPZCAtPointWR( const ScreenPoint& aHitTestPoint, const RecursiveMutexAutoLock& aProofOfTreeLock) { @@ -2665,6 +2823,7 @@ APZCTreeManager::HitTestResult APZCTreeManager::GetAPZCAtPointWR( return hit; } +#endif RefPtr APZCTreeManager::BuildOverscrollHandoffChain( @@ -3293,6 +3452,7 @@ LayerToParentLayerMatrix4x4 APZCTreeManager::ComputeTransformForNode( return aNode->GetTransform() * AsyncTransformMatrix(); } +#ifdef MOZ_BUILD_WEBRENDER already_AddRefed APZCTreeManager::GetWebRenderAPI( wr::RenderRoot aRenderRoot) const { RefPtr api; @@ -3316,6 +3476,7 @@ already_AddRefed APZCTreeManager::GetWebRenderAPIAtPoint( }); return api.forget(); } +#endif /*static*/ already_AddRefed APZCTreeManager::GetContentController( @@ -3354,7 +3515,8 @@ void APZCTreeManager::SendSubtreeTransformsToChromeMainThread( // to the root of the tree. For now, aiming for separation // of concerns rather than minimum number of multiplications. ForEachNode( - mRootNode.get(), [&](HitTestingTreeNode* aNode) { + mRootNode.get(), + [&](HitTestingTreeNode* aNode) { bool atAncestor = (aAncestor && aNode->GetApzc() == aAncestor); MOZ_ASSERT(!(underAncestor && atAncestor)); underAncestor |= atAncestor; @@ -3367,7 +3529,8 @@ void APZCTreeManager::SendSubtreeTransformsToChromeMainThread( messages.AppendElement( MatrixMessage(aNode->GetTransformToGecko(), layersId)); } - }, [&](HitTestingTreeNode* aNode) { + }, + [&](HitTestingTreeNode* aNode) { bool atAncestor = (aAncestor && aNode->GetApzc() == aAncestor); if (atAncestor) { MOZ_ASSERT(underAncestor); diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index bdb4575183..75d9683f90 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -34,11 +34,13 @@ namespace mozilla { class MultiTouchInput; +#ifdef MOZ_BUILD_WEBRENDER namespace wr { class TransactionWrapper; class WebRenderAPI; struct WrTransformProperty; } // namespace wr +#endif namespace layers { @@ -57,7 +59,9 @@ class InputQueue; class GeckoContentController; class HitTestingTreeNode; class HitTestingTreeNodeAutoLock; +#ifdef MOZ_BUILD_WEBRENDER class WebRenderScrollDataWrapper; +#endif struct AncestorTransform; struct ScrollThumbData; @@ -183,7 +187,8 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { * * @param aRoot The root of the (full) layer tree * @param aOriginatingLayersId The layers id of the subtree that triggered - * this repaint, and to which aIsFirstPaint applies. + * this repaint, and to which aIsFirstPaint + * applies. * @param aIsFirstPaint True if the layers update that this is called in * response to included a first-paint. If this is true, * the part of the tree that is affected by the @@ -194,10 +199,11 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { * process' layer subtree has its own sequence * numbers. */ - void UpdateHitTestingTree(Layer* aRoot, - bool aIsFirstPaint, LayersId aOriginatingLayersId, + void UpdateHitTestingTree(Layer* aRoot, bool aIsFirstPaint, + LayersId aOriginatingLayersId, uint32_t aPaintSequenceNumber); +#ifdef MOZ_BUILD_WEBRENDER /** * Same as the above UpdateHitTestingTree, except slightly modified to take * the scrolling data passed over PWebRenderBridge instead of the raw layer @@ -223,6 +229,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { void SampleForWebRender(wr::TransactionWrapper& aTxn, const TimeStamp& aSampleTime, wr::RenderRoot aRenderRoot); +#endif /** * Refer to the documentation of APZInputBridge::ReceiveInputEvent() and @@ -241,8 +248,13 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { * up. |aRect| must be given in CSS pixels, relative to the document. * |aFlags| is a combination of the ZoomToRectBehavior enum values. */ - void ZoomToRect(const SLGuidAndRenderRoot& aGuid, const CSSRect& aRect, - const uint32_t aFlags = DEFAULT_BEHAVIOR) override; + void ZoomToRect( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const CSSRect& aRect, const uint32_t aFlags = DEFAULT_BEHAVIOR) override; /** * If we have touch listeners, this should always be called when we know @@ -273,7 +285,12 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { * arrive. */ void SetTargetAPZC(uint64_t aInputBlockId, - const nsTArray& aTargets) override; +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) override; /** * Updates any zoom constraints contained in the tag. @@ -281,7 +298,11 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { * the given |aGuid| are cleared. */ void UpdateZoomConstraints( +#ifdef MOZ_BUILD_WEBRENDER const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif const Maybe& aConstraints) override; /** @@ -422,13 +443,29 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { ParentLayerPoint DispatchFling(AsyncPanZoomController* aApzc, const FlingHandoffState& aHandoffState); - void StartScrollbarDrag(const SLGuidAndRenderRoot& aGuid, - const AsyncDragMetrics& aDragMetrics) override; - - bool StartAutoscroll(const SLGuidAndRenderRoot& aGuid, - const ScreenPoint& aAnchorLocation) override; + void StartScrollbarDrag( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const AsyncDragMetrics& aDragMetrics) override; - void StopAutoscroll(const SLGuidAndRenderRoot& aGuid) override; + bool StartAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const ScreenPoint& aAnchorLocation) override; + + void StopAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif + ) override; /* * Build the chain of APZCs that will handle overscroll for a pan starting at @@ -517,6 +554,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { // Assert that the current thread is the updater thread for this APZCTM. void AssertOnUpdaterThread(); +#ifdef MOZ_BUILD_WEBRENDER // Returns a pointer to the WebRenderAPI this APZCTreeManager is for, for // the provided RenderRoot (since an APZCTreeManager can cover multiple // RenderRoots). This might be null (for example, if WebRender is not @@ -531,6 +569,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { // This might be null (for example, if WebRender is not enabled). already_AddRefed GetWebRenderAPIAtPoint( const ScreenPoint& aPoint) const; +#endif protected: // Protected destructor, to discourage deletion outside of Release(): @@ -549,8 +588,12 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { // Protected hooks for gtests subclass virtual AsyncPanZoomController* NewAPZCInstance( - LayersId aLayersId, GeckoContentController* aController, - wr::RenderRoot aRenderRoot); + LayersId aLayersId, GeckoContentController* aController +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif + ); public: // Public hook for gtests subclass @@ -638,7 +681,11 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { /* Helpers */ template void UpdateHitTestingTreeImpl(const ScrollNode& aRoot, bool aIsFirstPaint, +#ifdef MOZ_BUILD_WEBRENDER WRRootId aOriginatingWrRootId, +#else + LayersId aOriginatingLayersId, +#endif uint32_t aPaintSequenceNumber); void AttachNodeToTree(HitTestingTreeNode* aNode, HitTestingTreeNode* aParent, @@ -729,8 +776,12 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { const RecursiveMutexAutoLock& aProofOfTreeLock, const ScrollNode& aLayer, const FrameMetrics& aMetrics, LayersId aLayersId, const AncestorTransform& aAncestorTransform, HitTestingTreeNode* aParent, - HitTestingTreeNode* aNextSibling, TreeBuildingState& aState, - wr::RenderRoot aRenderRoot); + HitTestingTreeNode* aNextSibling, TreeBuildingState& aState +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif + ); template Maybe ComputeClipRegion(const ScrollNode& aLayer); diff --git a/gfx/layers/apz/src/APZSampler.cpp b/gfx/layers/apz/src/APZSampler.cpp index 6ab619f95c..2ed11250f2 100644 --- a/gfx/layers/apz/src/APZSampler.cpp +++ b/gfx/layers/apz/src/APZSampler.cpp @@ -13,27 +13,40 @@ #include "mozilla/layers/LayerMetricsWrapper.h" #include "mozilla/layers/SynchronousTask.h" #include "TreeTraversal.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderAPI.h" +#endif namespace mozilla { namespace layers { +#ifdef MOZ_BUILD_WEBRENDER StaticMutex APZSampler::sWindowIdLock; StaticAutoPtr>> APZSampler::sWindowIdMap; - -APZSampler::APZSampler(const RefPtr& aApz, - bool aIsUsingWebRender) - : mApz(aApz), +#endif + +APZSampler::APZSampler(const RefPtr& aApz +#ifdef MOZ_BUILD_WEBRENDER + , + bool aIsUsingWebRender +#endif + ) + : mApz(aApz) +#ifdef MOZ_BUILD_WEBRENDER + , mIsUsingWebRender(aIsUsingWebRender), mThreadIdLock("APZSampler::mThreadIdLock"), - mSampleTimeLock("APZSampler::mSampleTimeLock") { + mSampleTimeLock("APZSampler::mSampleTimeLock") +#endif +{ MOZ_ASSERT(aApz); mApz->SetSampler(this); } APZSampler::~APZSampler() { mApz->SetSampler(nullptr); } +#ifdef MOZ_BUILD_WEBRENDER void APZSampler::Destroy() { StaticMutexAutoLock lock(sWindowIdLock); if (mWindowId) { @@ -93,6 +106,7 @@ void APZSampler::SampleForWebRender(wr::TransactionWrapper& aTxn, } mApz->SampleForWebRender(aTxn, sampleTime, aRenderRoot); } +#endif // MOZ_BUILD_WEBRENDER bool APZSampler::SampleAnimations(const LayerMetricsWrapper& aLayer, const TimeStamp& aSampleTime) { @@ -217,6 +231,7 @@ void APZSampler::AssertOnSamplerThread() const { } bool APZSampler::IsSamplerThread() const { +#ifdef MOZ_BUILD_WEBRENDER if (mIsUsingWebRender) { // If the sampler thread id isn't set yet then we cannot be running on the // sampler thread (because we will have the thread id before we run any @@ -225,9 +240,11 @@ bool APZSampler::IsSamplerThread() const { MutexAutoLock lock(mThreadIdLock); return mSamplerThreadId && PlatformThread::CurrentId() == *mSamplerThreadId; } +#endif return CompositorThreadHolder::IsInCompositorThread(); } +#ifdef MOZ_BUILD_WEBRENDER /*static*/ already_AddRefed APZSampler::GetSampler( const wr::WrWindowId& aWindowId) { @@ -241,10 +258,12 @@ already_AddRefed APZSampler::GetSampler( } return sampler.forget(); } +#endif } // namespace layers } // namespace mozilla +#ifdef MOZ_BUILD_WEBRENDER void apz_register_sampler(mozilla::wr::WrWindowId aWindowId) { mozilla::layers::APZSampler::SetSamplerThread(aWindowId); } @@ -257,3 +276,4 @@ void apz_sample_transforms(mozilla::wr::WrWindowId aWindowId, } void apz_deregister_sampler(mozilla::wr::WrWindowId aWindowId) {} +#endif diff --git a/gfx/layers/apz/src/APZUpdater.cpp b/gfx/layers/apz/src/APZUpdater.cpp index 76a5702077..439bb3ea70 100644 --- a/gfx/layers/apz/src/APZUpdater.cpp +++ b/gfx/layers/apz/src/APZUpdater.cpp @@ -11,23 +11,35 @@ #include "mozilla/layers/APZThreadUtils.h" #include "mozilla/layers/CompositorThread.h" #include "mozilla/layers/SynchronousTask.h" -#include "mozilla/layers/WebRenderScrollDataWrapper.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderScrollDataWrapper.h" +# include "mozilla/webrender/WebRenderAPI.h" +#endif namespace mozilla { namespace layers { +#ifdef MOZ_BUILD_WEBRENDER StaticMutex APZUpdater::sWindowIdLock; StaticAutoPtr> APZUpdater::sWindowIdMap; - -APZUpdater::APZUpdater(const RefPtr& aApz, - bool aIsUsingWebRender) +#endif + +APZUpdater::APZUpdater(const RefPtr& aApz +#ifdef MOZ_BUILD_WEBRENDER + , + bool aIsUsingWebRender +#endif + ) : mApz(aApz), - mDestroyed(false), + mDestroyed(false) +#ifdef MOZ_BUILD_WEBRENDER + , mIsUsingWebRender(aIsUsingWebRender), mThreadIdLock("APZUpdater::ThreadIdLock"), - mQueueLock("APZUpdater::QueueLock") { + mQueueLock("APZUpdater::QueueLock") +#endif +{ MOZ_ASSERT(aApz); mApz->SetUpdater(this); } @@ -35,6 +47,7 @@ APZUpdater::APZUpdater(const RefPtr& aApz, APZUpdater::~APZUpdater() { mApz->SetUpdater(nullptr); +#ifdef MOZ_BUILD_WEBRENDER StaticMutexAutoLock lock(sWindowIdLock); if (mWindowId) { MOZ_ASSERT(sWindowIdMap); @@ -42,12 +55,14 @@ APZUpdater::~APZUpdater() { MOZ_ASSERT(sWindowIdMap->find(wr::AsUint64(*mWindowId)) == sWindowIdMap->end()); } +#endif } bool APZUpdater::HasTreeManager(const RefPtr& aApz) { return aApz.get() == mApz.get(); } +#ifdef MOZ_BUILD_WEBRENDER void APZUpdater::SetWebRenderWindowId(const wr::WindowId& aWindowId) { StaticMutexAutoLock lock(sWindowIdLock); MOZ_ASSERT(!mWindowId); @@ -128,33 +143,47 @@ void APZUpdater::ProcessPendingTasks(const wr::WrWindowId& aWindowId) { updater->ProcessQueue(); } } +#endif // MOZ_BUILD_WEBRENDER -void APZUpdater::ClearTree(LayersId aRootLayersId) { +void APZUpdater::ClearTree( +#ifdef MOZ_BUILD_WEBRENDER + LayersId aRootLayersId +#endif +) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); RefPtr self = this; RunOnUpdaterThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(aRootLayersId, wr::RenderRoot::Default), +#endif NS_NewRunnableFunction("APZUpdater::ClearTree", [=]() { self->mApz->ClearTree(); self->mDestroyed = true; - // Once ClearTree is called on the APZCTreeManager, we - // are in a shutdown phase. After this point it's ok if - // WebRender cannot get a hold of the updater via the - // window id, and it's a good point to remove the mapping - // and avoid leaving a dangling pointer to this object. + // Once ClearTree is called on the APZCTreeManager, we + // are in a shutdown phase. After this point it's ok if + // WebRender cannot get a hold of the updater via the + // window id, and it's a good point to remove the mapping + // and avoid leaving a dangling pointer to this object. +#ifdef MOZ_BUILD_WEBRENDER StaticMutexAutoLock lock(sWindowIdLock); if (self->mWindowId) { MOZ_ASSERT(sWindowIdMap); sWindowIdMap->erase(wr::AsUint64(*(self->mWindowId))); } +#endif })); } void APZUpdater::UpdateFocusState(LayersId aRootLayerTreeId, +#ifdef MOZ_BUILD_WEBRENDER WRRootId aOriginatingWrRootId, +#else + LayersId aOriginatingLayersId, +#endif const FocusTarget& aFocusTarget) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector selector(aOriginatingWrRootId); if (aFocusTarget.mData.is()) { const FocusTarget::ScrollTargets& targets = @@ -163,22 +192,30 @@ void APZUpdater::UpdateFocusState(LayersId aRootLayerTreeId, selector.mRenderRoots += targets.mVerticalRenderRoot; } RunOnUpdaterThread(selector, +#else + RunOnUpdaterThread( +#endif NewRunnableMethod( "APZUpdater::UpdateFocusState", mApz, &APZCTreeManager::UpdateFocusState, aRootLayerTreeId, - aOriginatingWrRootId.mLayersId, aFocusTarget)); +#ifdef MOZ_BUILD_WEBRENDER + aOriginatingWrRootId.mLayersId, +#else + aOriginatingLayersId, +#endif + aFocusTarget)); } -void APZUpdater::UpdateHitTestingTree(Layer* aRoot, - bool aIsFirstPaint, +void APZUpdater::UpdateHitTestingTree(Layer* aRoot, bool aIsFirstPaint, LayersId aOriginatingWrRootId, uint32_t aPaintSequenceNumber) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); AssertOnUpdaterThread(); - mApz->UpdateHitTestingTree(aRoot, aIsFirstPaint, - aOriginatingWrRootId, aPaintSequenceNumber); + mApz->UpdateHitTestingTree(aRoot, aIsFirstPaint, aOriginatingWrRootId, + aPaintSequenceNumber); } +#ifdef MOZ_BUILD_WEBRENDER void APZUpdater::UpdateScrollDataAndTreeState( WRRootId aRootLayerTreeId, WRRootId aOriginatingWrRootId, const wr::Epoch& aEpoch, WebRenderScrollData&& aScrollData) { @@ -240,41 +277,84 @@ void APZUpdater::UpdateScrollOffsets(WRRootId aRootLayerTreeId, aPaintSequenceNumber); })); } +#endif -void APZUpdater::NotifyLayerTreeAdopted(WRRootId aWrRootId, - const RefPtr& aOldUpdater) { +void APZUpdater::NotifyLayerTreeAdopted( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId, +#else + LayersId aLayersId, +#endif + const RefPtr& aOldUpdater) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); RunOnUpdaterThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(aWrRootId), +#endif NewRunnableMethod>( "APZUpdater::NotifyLayerTreeAdopted", mApz, - &APZCTreeManager::NotifyLayerTreeAdopted, aWrRootId.mLayersId, + &APZCTreeManager::NotifyLayerTreeAdopted, +#ifdef MOZ_BUILD_WEBRENDER + aWrRootId.mLayersId, +#else + aLayersId, +#endif aOldUpdater ? aOldUpdater->mApz : nullptr)); } -void APZUpdater::NotifyLayerTreeRemoved(WRRootId aWrRootId) { +void APZUpdater::NotifyLayerTreeRemoved( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId +#else + LayersId aLayersId +#endif +) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); RefPtr self = this; RunOnUpdaterThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(aWrRootId), +#endif NS_NewRunnableFunction("APZUpdater::NotifyLayerTreeRemoved", [=]() { +#ifdef MOZ_BUILD_WEBRENDER self->mEpochData.erase(aWrRootId); self->mScrollData.erase(aWrRootId); - self->mApz->NotifyLayerTreeRemoved(aWrRootId.mLayersId); +#endif + self->mApz->NotifyLayerTreeRemoved( +#ifdef MOZ_BUILD_WEBRENDER + aWrRootId.mLayersId +#else + aLayersId +#endif + ); })); } -bool APZUpdater::GetAPZTestData(WRRootId aWrRootId, APZTestData* aOutData) { +bool APZUpdater::GetAPZTestData( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId, +#else + LayersId aLayersId, +#endif + APZTestData* aOutData) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); RefPtr apz = mApz; bool ret = false; SynchronousTask waiter("APZUpdater::GetAPZTestData"); RunOnUpdaterThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(aWrRootId), +#endif NS_NewRunnableFunction("APZUpdater::GetAPZTestData", [&]() { AutoCompleteTask notifier(&waiter); - ret = apz->GetAPZTestData(aWrRootId.mLayersId, aOutData); + ret = apz->GetAPZTestData( +#ifdef MOZ_BUILD_WEBRENDER + aWrRootId.mLayersId, +#else + aLayersId, +#endif + aOutData); })); // Wait until the task posted above has run and populated aOutData and ret @@ -284,15 +364,26 @@ bool APZUpdater::GetAPZTestData(WRRootId aWrRootId, APZTestData* aOutData) { } void APZUpdater::SetTestAsyncScrollOffset( - WRRootId aWrRootId, const ScrollableLayerGuid::ViewID& aScrollId, - const CSSPoint& aOffset) { +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId, +#else + LayersId aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, const CSSPoint& aOffset) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); RefPtr apz = mApz; RunOnUpdaterThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(aWrRootId), +#endif NS_NewRunnableFunction("APZUpdater::SetTestAsyncScrollOffset", [=]() { - RefPtr apzc = - apz->GetTargetAPZC(aWrRootId.mLayersId, aScrollId); + RefPtr apzc = apz->GetTargetAPZC( +#ifdef MOZ_BUILD_WEBRENDER + aWrRootId.mLayersId, +#else + aLayersId, +#endif + aScrollId); if (apzc) { apzc->SetTestAsyncScrollOffset(aOffset); } else { @@ -301,16 +392,28 @@ void APZUpdater::SetTestAsyncScrollOffset( })); } -void APZUpdater::SetTestAsyncZoom(WRRootId aWrRootId, - const ScrollableLayerGuid::ViewID& aScrollId, - const LayerToParentLayerScale& aZoom) { +void APZUpdater::SetTestAsyncZoom( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId, +#else + LayersId aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); RefPtr apz = mApz; RunOnUpdaterThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(aWrRootId), +#endif NS_NewRunnableFunction("APZUpdater::SetTestAsyncZoom", [=]() { - RefPtr apzc = - apz->GetTargetAPZC(aWrRootId.mLayersId, aScrollId); + RefPtr apzc = apz->GetTargetAPZC( +#ifdef MOZ_BUILD_WEBRENDER + aWrRootId.mLayersId, +#else + aLayersId, +#endif + aScrollId); if (apzc) { apzc->SetTestAsyncZoom(aZoom); } else { @@ -319,11 +422,13 @@ void APZUpdater::SetTestAsyncZoom(WRRootId aWrRootId, })); } +#ifdef MOZ_BUILD_WEBRENDER const WebRenderScrollData* APZUpdater::GetScrollData(WRRootId aWrRootId) const { AssertOnUpdaterThread(); auto it = mScrollData.find(aWrRootId); return (it == mScrollData.end() ? nullptr : &(it->second)); } +#endif void APZUpdater::AssertOnUpdaterThread() const { if (APZThreadUtils::GetThreadAssertionsEnabled()) { @@ -331,8 +436,11 @@ void APZUpdater::AssertOnUpdaterThread() const { } } -void APZUpdater::RunOnUpdaterThread(UpdaterQueueSelector aSelector, - already_AddRefed aTask) { +void APZUpdater::RunOnUpdaterThread( +#ifdef MOZ_BUILD_WEBRENDER + UpdaterQueueSelector aSelector, +#endif + already_AddRefed aTask) { RefPtr task = aTask; // In the scenario where UsingWebRenderUpdaterThread() is true, this function @@ -347,6 +455,7 @@ void APZUpdater::RunOnUpdaterThread(UpdaterQueueSelector aSelector, return; } +#ifdef MOZ_BUILD_WEBRENDER if (UsingWebRenderUpdaterThread()) { // If the updater thread is a WebRender thread, and we're not on it // right now, save the task in the queue. We will run tasks from the queue @@ -424,6 +533,7 @@ void APZUpdater::RunOnUpdaterThread(UpdaterQueueSelector aSelector, } return; } +#endif // MOZ_BUILD_WEBRENDER if (MessageLoop* loop = CompositorThreadHolder::Loop()) { loop->PostTask(task.forget()); @@ -434,6 +544,7 @@ void APZUpdater::RunOnUpdaterThread(UpdaterQueueSelector aSelector, } bool APZUpdater::IsUpdaterThread() const { +#ifdef MOZ_BUILD_WEBRENDER if (UsingWebRenderUpdaterThread()) { // If the updater thread id isn't set yet then we cannot be running on the // updater thread (because we will have the thread id before we run any @@ -442,21 +553,29 @@ bool APZUpdater::IsUpdaterThread() const { MutexAutoLock lock(mThreadIdLock); return mUpdaterThreadId && PlatformThread::CurrentId() == *mUpdaterThreadId; } +#endif return CompositorThreadHolder::IsInCompositorThread(); } -void APZUpdater::RunOnControllerThread(UpdaterQueueSelector aSelector, - already_AddRefed aTask) { +void APZUpdater::RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER + UpdaterQueueSelector aSelector, +#endif + already_AddRefed aTask) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); RefPtr task = aTask; - RunOnUpdaterThread(aSelector, - NewRunnableFunction("APZUpdater::RunOnControllerThread", - &APZThreadUtils::RunOnControllerThread, - std::move(task))); + RunOnUpdaterThread( +#ifdef MOZ_BUILD_WEBRENDER + aSelector, +#endif + NewRunnableFunction("APZUpdater::RunOnControllerThread", + &APZThreadUtils::RunOnControllerThread, + std::move(task))); } +#ifdef MOZ_BUILD_WEBRENDER bool APZUpdater::UsingWebRenderUpdaterThread() const { return mIsUsingWebRender; } @@ -571,12 +690,14 @@ bool APZUpdater::EpochState::IsBlocked() const { } return mBuilt && (*mBuilt < mRequired); } +#endif // MOZ_BUILD_WEBRENDER } // namespace layers } // namespace mozilla // Rust callback implementations +#ifdef MOZ_BUILD_WEBRENDER void apz_register_updater(mozilla::wr::WrWindowId aWindowId) { mozilla::layers::APZUpdater::SetUpdaterThread(aWindowId); } @@ -599,3 +720,4 @@ void apz_deregister_updater(mozilla::wr::WrWindowId aWindowId) { // Run anything that's still left. mozilla::layers::APZUpdater::ProcessPendingTasks(aWindowId); } +#endif diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 6a5105df57..1d50d8e866 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -835,10 +835,15 @@ void AsyncPanZoomController::InitializeGlobalState() { AsyncPanZoomController::AsyncPanZoomController( LayersId aLayersId, APZCTreeManager* aTreeManager, const RefPtr& aInputQueue, - GeckoContentController* aGeckoContentController, wr::RenderRoot aRenderRoot, + GeckoContentController* aGeckoContentController, +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRoot aRenderRoot, +#endif GestureBehavior aGestures) : mLayersId(aLayersId), +#ifdef MOZ_BUILD_WEBRENDER mRenderRoot(aRenderRoot), +#endif mGeckoContentController(aGeckoContentController), mRefPtrMonitor("RefPtrMonitor"), // mTreeManager must be initialized before GetFrameTime() is called @@ -3767,7 +3772,10 @@ const ScreenMargin AsyncPanZoomController::CalculatePendingDisplayPort( void AsyncPanZoomController::ScheduleComposite() { if (mCompositorController) { mCompositorController->ScheduleRenderOnCompositorThread( - wr::RenderRootSet(mRenderRoot)); +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRootSet(mRenderRoot) +#endif + ); } } @@ -3926,8 +3934,7 @@ void AsyncPanZoomController::RequestContentRepaint( NewRunnableMethod( "layers::APZCTreeManager::SendSubtreeTransformsToChromeMainThread", GetApzcTreeManager(), - &APZCTreeManager::SendSubtreeTransformsToChromeMainThread, - this)); + &APZCTreeManager::SendSubtreeTransformsToChromeMainThread, this)); } bool AsyncPanZoomController::UpdateAnimation( @@ -5293,6 +5300,7 @@ bool AsyncPanZoomController::MaybeAdjustDestinationForScrollSnapping( return false; } +#ifdef MOZ_BUILD_WEBRENDER void AsyncPanZoomController::SetZoomAnimationId( const Maybe& aZoomAnimationId) { mZoomAnimationId = aZoomAnimationId; @@ -5301,6 +5309,7 @@ void AsyncPanZoomController::SetZoomAnimationId( Maybe AsyncPanZoomController::GetZoomAnimationId() const { return mZoomAnimationId; } +#endif } // namespace layers } // namespace mozilla diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index dad5196d04..7b58417feb 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -45,7 +45,9 @@ namespace layers { class AsyncDragMetrics; class APZCTreeManager; struct ScrollableLayerGuid; +#ifdef MOZ_BUILD_WEBRENDER struct SLGuidAndRenderRoot; +#endif class CompositorController; class MetricsSharingController; class GestureEventListener; @@ -194,7 +196,9 @@ class AsyncPanZoomController { AsyncPanZoomController(LayersId aLayersId, APZCTreeManager* aTreeManager, const RefPtr& aInputQueue, GeckoContentController* aController, +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot aRenderRoot, +#endif GestureBehavior aGestures = DEFAULT_GESTURES); // -------------------------------------------------------------------------- @@ -912,7 +916,9 @@ class AsyncPanZoomController { void OnTouchEndOrCancel(); LayersId mLayersId; +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot mRenderRoot; +#endif RefPtr mCompositorController; RefPtr mMetricsSharingController; @@ -1030,6 +1036,7 @@ class AsyncPanZoomController { UniquePtr mOverscrollEffect; +#ifdef MOZ_BUILD_WEBRENDER // Zoom animation id, used for zooming in WebRender. This should only be // set on the APZC instance for the root content document (i.e. the one we // support zooming on), and is only used if WebRender is enabled. The @@ -1038,6 +1045,7 @@ class AsyncPanZoomController { // associated with this id, we can adjust the scaling that WebRender applies, // thereby controlling the zoom. Maybe mZoomAnimationId; +#endif // Position on screen where user first put their finger down. ExternalPoint mStartTouch; @@ -1059,8 +1067,10 @@ class AsyncPanZoomController { return callable(mLastContentPaintMetrics); } +#ifdef MOZ_BUILD_WEBRENDER void SetZoomAnimationId(const Maybe& aZoomAnimationId); Maybe GetZoomAnimationId() const; +#endif /* =================================================================== * The functions and members in this section are used to expose @@ -1590,7 +1600,9 @@ class AsyncPanZoomController { LayersId GetLayersId() const { return mLayersId; } +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot GetRenderRoot() const { return mRenderRoot; } +#endif bool IsPinchZooming() const { return mState == PINCHING; } diff --git a/gfx/layers/apz/src/FocusTarget.cpp b/gfx/layers/apz/src/FocusTarget.cpp index 1142ccf9c0..bb02c61ff6 100644 --- a/gfx/layers/apz/src/FocusTarget.cpp +++ b/gfx/layers/apz/src/FocusTarget.cpp @@ -11,8 +11,8 @@ #include "mozilla/layout/RenderFrame.h" // For RenderFrame #include "mozilla/PresShell.h" // For PresShell #include "mozilla/StaticPrefs_apz.h" -#include "nsIContentInlines.h" // for nsINode::IsEditable() -#include "nsLayoutUtils.h" // for nsLayoutUtils +#include "nsIContentInlines.h" // for nsINode::IsEditable() +#include "nsLayoutUtils.h" // for nsLayoutUtils #define ENABLE_FT_LOGGING 0 // #define ENABLE_FT_LOGGING 1 @@ -218,6 +218,7 @@ FocusTarget::FocusTarget(PresShell* aRootPresShell, ScrollTargets target; target.mHorizontal = nsLayoutUtils::FindIDForScrollableFrame(horizontal); target.mVertical = nsLayoutUtils::FindIDForScrollableFrame(vertical); +#ifdef MOZ_BUILD_WEBRENDER if (XRE_IsContentProcess()) { target.mHorizontalRenderRoot = gfxUtils::GetContentRenderRoot(); target.mVerticalRenderRoot = gfxUtils::GetContentRenderRoot(); @@ -231,6 +232,7 @@ FocusTarget::FocusTarget(PresShell* aRootPresShell, vertical->GetScrolledFrame()) : wr::RenderRoot::Default; } +#endif mData = AsVariant(target); FT_LOG("Creating scroll target with seq=%" PRIu64 ", kl=%d, h=%" PRIu64 diff --git a/gfx/layers/apz/src/FocusTarget.h b/gfx/layers/apz/src/FocusTarget.h index 88d595a59a..f1f8f4f1b3 100644 --- a/gfx/layers/apz/src/FocusTarget.h +++ b/gfx/layers/apz/src/FocusTarget.h @@ -9,8 +9,10 @@ #include "mozilla/DefineEnum.h" // for MOZ_DEFINE_ENUM #include "mozilla/layers/ScrollableLayerGuid.h" // for ViewID -#include "mozilla/webrender/WebRenderTypes.h" // for RenderRoot -#include "mozilla/Variant.h" // for Variant +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" // for RenderRoot +#endif +#include "mozilla/Variant.h" // for Variant namespace mozilla { @@ -28,13 +30,16 @@ class FocusTarget final { public: struct ScrollTargets { ScrollableLayerGuid::ViewID mHorizontal; - wr::RenderRoot mHorizontalRenderRoot; ScrollableLayerGuid::ViewID mVertical; +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRoot mHorizontalRenderRoot; wr::RenderRoot mVerticalRenderRoot; +#endif bool operator==(const ScrollTargets& aRhs) const { bool ret = (mHorizontal == aRhs.mHorizontal && mVertical == aRhs.mVertical); +#ifdef MOZ_BUILD_WEBRENDER if (ret) { // The render root is a function of where the scrollable frame is in // the DOM/layout tree, so if the ViewIDs match then the render roots @@ -42,6 +47,7 @@ class FocusTarget final { MOZ_ASSERT(mHorizontalRenderRoot == aRhs.mHorizontalRenderRoot && mVerticalRenderRoot == aRhs.mVerticalRenderRoot); } +#endif return ret; } }; diff --git a/gfx/layers/apz/src/HitTestingTreeNode.cpp b/gfx/layers/apz/src/HitTestingTreeNode.cpp index 5cac48dc0b..9d6303ade2 100644 --- a/gfx/layers/apz/src/HitTestingTreeNode.cpp +++ b/gfx/layers/apz/src/HitTestingTreeNode.cpp @@ -5,7 +5,7 @@ #include "HitTestingTreeNode.h" #include "AsyncPanZoomController.h" // for AsyncPanZoomController -#include "LayersLogging.h" // for Stringify +#include "LayersLogging.h" // for Stringify #include "mozilla/StaticPrefs_layout.h" #include "mozilla/gfx/Point.h" // for Point4D #include "mozilla/layers/APZUtils.h" // for CompleteAsyncTransform @@ -92,9 +92,13 @@ void HitTestingTreeNode::SetLastChild(HitTestingTreeNode* aChild) { } void HitTestingTreeNode::SetScrollbarData( +#ifdef MOZ_BUILD_WEBRENDER const Maybe& aScrollbarAnimationId, +#endif const ScrollbarData& aScrollbarData) { +#ifdef MOZ_BUILD_WEBRENDER mScrollbarAnimationId = aScrollbarAnimationId; +#endif mScrollbarData = aScrollbarData; } @@ -124,9 +128,11 @@ ScrollableLayerGuid::ViewID HitTestingTreeNode::GetScrollTargetId() const { return mScrollbarData.mTargetViewId; } +#ifdef MOZ_BUILD_WEBRENDER Maybe HitTestingTreeNode::GetScrollbarAnimationId() const { return mScrollbarAnimationId; } +#endif const ScrollbarData& HitTestingTreeNode::GetScrollbarData() const { return mScrollbarData; @@ -325,9 +331,9 @@ LayerToScreenMatrix4x4 HitTestingTreeNode::GetTransformToGecko() const { LayerToParentLayerMatrix4x4 thisToParent = mTransform * AsyncTransformMatrix(); if (mApzc) { - thisToParent = thisToParent * - ViewAs( - mApzc->GetTransformToLastDispatchedPaint()); + thisToParent = + thisToParent * ViewAs( + mApzc->GetTransformToLastDispatchedPaint()); } ParentLayerToScreenMatrix4x4 parentToRoot = ViewAs( diff --git a/gfx/layers/apz/src/HitTestingTreeNode.h b/gfx/layers/apz/src/HitTestingTreeNode.h index 753e55dea4..ef37bba84d 100644 --- a/gfx/layers/apz/src/HitTestingTreeNode.h +++ b/gfx/layers/apz/src/HitTestingTreeNode.h @@ -109,8 +109,11 @@ class HitTestingTreeNode { /* Scrollbar info */ - void SetScrollbarData(const Maybe& aScrollbarAnimationId, - const ScrollbarData& aScrollbarData); + void SetScrollbarData( +#ifdef MOZ_BUILD_WEBRENDER + const Maybe& aScrollbarAnimationId, +#endif + const ScrollbarData& aScrollbarData); bool MatchesScrollDragMetrics(const AsyncDragMetrics& aDragMetrics) const; bool IsScrollbarNode() const; // Scroll thumb or scrollbar container layer. // This can only be called if IsScrollbarNode() is true @@ -118,7 +121,9 @@ class HitTestingTreeNode { bool IsScrollThumbNode() const; // Scroll thumb container layer. ScrollableLayerGuid::ViewID GetScrollTargetId() const; const ScrollbarData& GetScrollbarData() const; +#ifdef MOZ_BUILD_WEBRENDER Maybe GetScrollbarAnimationId() const; +#endif /* Fixed pos info */ @@ -168,10 +173,12 @@ class HitTestingTreeNode { LayersId mLayersId; +#ifdef MOZ_BUILD_WEBRENDER // This is only set if WebRender is enabled, and only for HTTNs // where IsScrollThumbNode() returns true. It holds the animation id that we // use to move the thumb node to reflect async scrolling. Maybe mScrollbarAnimationId; +#endif // This is set for scrollbar Container and Thumb layers. ScrollbarData mScrollbarData; diff --git a/gfx/layers/apz/test/gtest/APZCBasicTester.h b/gfx/layers/apz/test/gtest/APZCBasicTester.h index c9935bec69..ef56d2a8a0 100644 --- a/gfx/layers/apz/test/gtest/APZCBasicTester.h +++ b/gfx/layers/apz/test/gtest/APZCBasicTester.h @@ -27,8 +27,13 @@ class APZCBasicTester : public APZCTesterBase { APZThreadUtils::SetControllerThread(MessageLoop::current()); tm = new TestAPZCTreeManager(mcc); +#ifdef MOZ_BUILD_WEBRENDER updater = new APZUpdater(tm, false); sampler = new APZSampler(tm, false); +#else + updater = new APZUpdater(tm); + sampler = new APZSampler(tm); +#endif apzc = new TestAsyncPanZoomController( LayersId{0}, mcc, tm, wr::RenderRoot::Default, mGestureBehavior); apzc->SetFrameMetrics(TestFrameMetrics()); diff --git a/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h b/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h index 6d4d39a55f..15188a7a54 100644 --- a/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h +++ b/gfx/layers/apz/test/gtest/APZCTreeManagerTester.h @@ -24,8 +24,13 @@ class APZCTreeManagerTester : public APZCTesterBase { APZThreadUtils::SetControllerThread(MessageLoop::current()); manager = new TestAPZCTreeManager(mcc); +#ifdef MOZ_BUILD_WEBRENDER updater = new APZUpdater(manager, false); sampler = new APZSampler(manager, false); +#else + updater = new APZUpdater(manager); + sampler = new APZSampler(manager); +#endif } virtual void TearDown() { diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index 97921b955c..89d02bfc83 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -14,8 +14,10 @@ #include "mozilla/IntegerPrintfMacros.h" #include "mozilla/layers/LayerTransactionChild.h" #include "mozilla/layers/ShadowLayers.h" -#include "mozilla/layers/WebRenderLayerManager.h" -#include "mozilla/layers/WebRenderBridgeChild.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderLayerManager.h" +# include "mozilla/layers/WebRenderBridgeChild.h" +#endif #include "mozilla/PresShell.h" #include "mozilla/TouchEvents.h" #include "nsContainerFrame.h" @@ -662,9 +664,14 @@ using FrameForPointOption = nsLayoutUtils::FrameForPointOption; static bool PrepareForSetTargetAPZCNotification( nsIWidget* aWidget, const LayersId& aLayersId, nsIFrame* aRootFrame, const LayoutDeviceIntPoint& aRefPoint, +#ifdef MOZ_BUILD_WEBRENDER nsTArray* aTargets) { SLGuidAndRenderRoot guid(aLayersId, 0, ScrollableLayerGuid::NULL_SCROLL_ID, wr::RenderRoot::Default); +#else + nsTArray* aTargets) { + ScrollableLayerGuid guid(aLayersId, 0, ScrollableLayerGuid::NULL_SCROLL_ID); +#endif nsPoint point = nsLayoutUtils::GetEventCoordinatesRelativeTo( aWidget, aRefPoint, aRootFrame); EnumSet options; @@ -687,11 +694,13 @@ static bool PrepareForSetTargetAPZCNotification( scrollAncestor ? GetDisplayportElementFor(scrollAncestor) : GetRootDocumentElementFor(aWidget); +#ifdef MOZ_BUILD_WEBRENDER if (XRE_IsContentProcess()) { guid.mRenderRoot = gfxUtils::GetContentRenderRoot(); } else { guid.mRenderRoot = gfxUtils::RecursivelyGetRenderRootForElement(dpElement); } +#endif #ifdef APZCCH_LOGGING nsAutoString dpElementDesc; @@ -704,8 +713,12 @@ static bool PrepareForSetTargetAPZCNotification( #endif bool guidIsValid = APZCCallbackHelper::GetOrCreateScrollIdentifiers( +#ifdef MOZ_BUILD_WEBRENDER dpElement, &(guid.mScrollableLayerGuid.mPresShellId), &(guid.mScrollableLayerGuid.mScrollId)); +#else + dpElement, &(guid.mPresShellId), &(guid.mScrollId)); +#endif aTargets->AppendElement(guid); if (!guidIsValid || nsLayoutUtils::HasDisplayPort(dpElement)) { @@ -738,18 +751,25 @@ static bool PrepareForSetTargetAPZCNotification( static void SendLayersDependentApzcTargetConfirmation( PresShell* aPresShell, uint64_t aInputBlockId, - const nsTArray& aTargets) { +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif +) { LayerManager* lm = aPresShell->GetLayerManager(); if (!lm) { return; } +#ifdef MOZ_BUILD_WEBRENDER if (WebRenderLayerManager* wrlm = lm->AsWebRenderLayerManager()) { if (WebRenderBridgeChild* wrbc = wrlm->WrBridge()) { wrbc->SendSetConfirmedTargetAPZC(aInputBlockId, aTargets); } return; } +#endif ShadowLayerForwarder* lf = lm->AsShadowForwarder(); if (!lf) { @@ -768,11 +788,17 @@ static void SendLayersDependentApzcTargetConfirmation( DisplayportSetListener::DisplayportSetListener( nsIWidget* aWidget, PresShell* aPresShell, const uint64_t& aInputBlockId, - const nsTArray& aTargets) +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) : mWidget(aWidget), mPresShell(aPresShell), mInputBlockId(aInputBlockId), - mTargets(aTargets) {} + mTargets(aTargets) { +} DisplayportSetListener::~DisplayportSetListener() {} @@ -839,7 +865,11 @@ APZCCallbackHelper::SendSetTargetAPZCNotification(nsIWidget* aWidget, rootFrame = UpdateRootFrameForTouchTargetDocument(rootFrame); bool waitForRefresh = false; +#ifdef MOZ_BUILD_WEBRENDER nsTArray targets; +#else + nsTArray targets; +#endif if (const WidgetTouchEvent* touchEvent = aEvent.AsTouchEvent()) { for (size_t i = 0; i < touchEvent->mTouches.Length(); i++) { diff --git a/gfx/layers/apz/util/APZCCallbackHelper.h b/gfx/layers/apz/util/APZCCallbackHelper.h index 5e8e85588e..6dcf2f6286 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.h +++ b/gfx/layers/apz/util/APZCCallbackHelper.h @@ -37,7 +37,12 @@ class DisplayportSetListener : public nsAPostRefreshObserver { public: DisplayportSetListener(nsIWidget* aWidget, PresShell* aPresShell, const uint64_t& aInputBlockId, - const nsTArray& aTargets); +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ); virtual ~DisplayportSetListener(); bool Register(); void DidRefresh() override; @@ -46,7 +51,11 @@ class DisplayportSetListener : public nsAPostRefreshObserver { RefPtr mWidget; RefPtr mPresShell; uint64_t mInputBlockId; +#ifdef MOZ_BUILD_WEBRENDER nsTArray mTargets; +#else + nsTArray mTargets; +#endif }; /* This class contains some helper methods that facilitate implementing the diff --git a/gfx/layers/apz/util/ChromeProcessController.cpp b/gfx/layers/apz/util/ChromeProcessController.cpp index b56c811246..148e710e58 100644 --- a/gfx/layers/apz/util/ChromeProcessController.cpp +++ b/gfx/layers/apz/util/ChromeProcessController.cpp @@ -149,11 +149,18 @@ void ChromeProcessController::HandleDoubleTap( if (APZCCallbackHelper::GetOrCreateScrollIdentifiers( document->GetDocumentElement(), &presShellId, &viewId)) { APZThreadUtils::RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER NewRunnableMethod( "IAPZCTreeManager::ZoomToRect", mAPZCTreeManager, &IAPZCTreeManager::ZoomToRect, SLGuidAndRenderRoot(aGuid.mLayersId, presShellId, viewId, wr::RenderRoot::Default), +#else + NewRunnableMethod( + "IAPZCTreeManager::ZoomToRect", mAPZCTreeManager, + &IAPZCTreeManager::ZoomToRect, + ScrollableLayerGuid(aGuid.mLayersId, presShellId, viewId), +#endif zoomToRect, ZoomToRectBehavior::DEFAULT_BEHAVIOR)); } } diff --git a/gfx/layers/client/CanvasClient.cpp b/gfx/layers/client/CanvasClient.cpp index 94955d69b6..342b0b8e27 100644 --- a/gfx/layers/client/CanvasClient.cpp +++ b/gfx/layers/client/CanvasClient.cpp @@ -62,8 +62,12 @@ void CanvasClientBridge::UpdateAsync(AsyncCanvasRenderer* aRenderer) { mAsyncHandle = asyncID; } -void CanvasClient2D::UpdateFromTexture(TextureClient* aTexture, - wr::RenderRoot aRenderRoot) { +void CanvasClient2D::UpdateFromTexture(TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif +) { MOZ_ASSERT(aTexture); if (!aTexture->IsSharedWithCompositor()) { @@ -82,16 +86,30 @@ void CanvasClient2D::UpdateFromTexture(TextureClient* aTexture, t->mPictureRect = nsIntRect(nsIntPoint(0, 0), aTexture->GetSize()); t->mFrameID = mFrameID; - GetForwarder()->UseTextures(this, textures, Some(aRenderRoot)); + GetForwarder()->UseTextures(this, textures +#ifdef MOZ_BUILD_WEBRENDER + , + Some(aRenderRoot) +#endif + ); aTexture->SyncWithObject(GetForwarder()->GetSyncObject()); } void CanvasClient2D::Update(gfx::IntSize aSize, - ShareableCanvasRenderer* aCanvasRenderer, - wr::RenderRoot aRenderRoot) { + ShareableCanvasRenderer* aCanvasRenderer +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif +) { mBufferProviderTexture = nullptr; - AutoRemoveTexture autoRemove(this, aRenderRoot); + AutoRemoveTexture autoRemove(this +#ifdef MOZ_BUILD_WEBRENDER + , + aRenderRoot +#endif + ); if (mBackBuffer && (mBackBuffer->IsReadLocked() || mBackBuffer->GetSize() != aSize)) { autoRemove.mTexture = mBackBuffer; @@ -151,7 +169,12 @@ void CanvasClient2D::Update(gfx::IntSize aSize, t->mTextureClient = mBackBuffer; t->mPictureRect = nsIntRect(nsIntPoint(0, 0), mBackBuffer->GetSize()); t->mFrameID = mFrameID; - GetForwarder()->UseTextures(this, textures, Some(aRenderRoot)); + GetForwarder()->UseTextures(this, textures +#ifdef MOZ_BUILD_WEBRENDER + , + Some(aRenderRoot) +#endif + ); mBackBuffer->SyncWithObject(GetForwarder()->GetSyncObject()); } @@ -171,6 +194,7 @@ already_AddRefed CanvasClient2D::CreateTextureClientForCanvas( } #ifdef XP_WIN +# ifdef MOZ_BUILD_WEBRENDER // With WebRender, host side uses data of TextureClient longer. // Then back buffer reuse in CanvasClient2D::Update() does not work. It causes // a lot of TextureClient allocations. @@ -180,6 +204,7 @@ already_AddRefed CanvasClient2D::CreateTextureClientForCanvas( return GetTextureClientRecycler()->CreateOrRecycle( aFormat, aSize, BackendSelector::Canvas, aFlags); } +# endif return CreateTextureClientForDrawing(aFormat, aSize, BackendSelector::Canvas, aFlags); #else @@ -248,9 +273,11 @@ class TexClientFactory { if (!areRGBAFormatsBroken) { gfx::SurfaceFormat format = mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::R8G8B8X8; +#ifdef MOZ_BUILD_WEBRENDER if (gfxVars::UseWebRender() && format == gfx::SurfaceFormat::R8G8B8X8) { MOZ_CRASH("R8G8B8X8 is not supported on WebRender"); } +#endif ret = Create(format); } @@ -372,8 +399,12 @@ static already_AddRefed CloneSurface( } void CanvasClientSharedSurface::Update(gfx::IntSize aSize, - ShareableCanvasRenderer* aCanvasRenderer, - wr::RenderRoot aRenderRoot) { + ShareableCanvasRenderer* aCanvasRenderer +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif +) { Renderer renderer; renderer.construct(aCanvasRenderer); UpdateRenderer(aSize, renderer); @@ -482,7 +513,11 @@ void CanvasClientSharedSurface::UpdateRenderer(gfx::IntSize aSize, mNewFront = newFront; } -void CanvasClientSharedSurface::Updated(wr::RenderRoot aRenderRoot) { +void CanvasClientSharedSurface::Updated( +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRoot aRenderRoot +#endif +) { if (!mNewFront) { return; } @@ -502,7 +537,12 @@ void CanvasClientSharedSurface::Updated(wr::RenderRoot aRenderRoot) { t->mTextureClient = mFront; t->mPictureRect = nsIntRect(nsIntPoint(0, 0), mFront->GetSize()); t->mFrameID = mFrameID; - forwarder->UseTextures(this, textures, Some(aRenderRoot)); + forwarder->UseTextures(this, textures +#ifdef MOZ_BUILD_WEBRENDER + , + Some(aRenderRoot) +#endif + ); } void CanvasClientSharedSurface::OnDetach() { ClearSurfaces(); } diff --git a/gfx/layers/client/CanvasClient.h b/gfx/layers/client/CanvasClient.h index 3dd503cf28..b55e3291d0 100644 --- a/gfx/layers/client/CanvasClient.h +++ b/gfx/layers/client/CanvasClient.h @@ -61,8 +61,12 @@ class CanvasClient : public CompositableClient { virtual void Clear(){}; virtual void Update(gfx::IntSize aSize, - ShareableCanvasRenderer* aCanvasRenderer, - wr::RenderRoot aRenderRoot) = 0; + ShareableCanvasRenderer* aCanvasRenderer +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif + ) = 0; bool AddTextureClient(TextureClient* aTexture) override { ++mFrameID; @@ -71,10 +75,20 @@ class CanvasClient : public CompositableClient { virtual void UpdateAsync(AsyncCanvasRenderer* aRenderer) {} - virtual void UpdateFromTexture(TextureClient* aTexture, - wr::RenderRoot aRenderRoot) {} + virtual void UpdateFromTexture(TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif + ) { + } - virtual void Updated(wr::RenderRoot aRenderRoot) {} + virtual void Updated( +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRoot aRenderRoot +#endif + ) { + } protected: int32_t mFrameID; @@ -95,11 +109,19 @@ class CanvasClient2D : public CanvasClient { mBackBuffer = mFrontBuffer = mBufferProviderTexture = nullptr; } - void Update(gfx::IntSize aSize, ShareableCanvasRenderer* aCanvasRenderer, - wr::RenderRoot aRenderRoot) override; + void Update(gfx::IntSize aSize, ShareableCanvasRenderer* aCanvasRenderer +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif + ) override; - void UpdateFromTexture(TextureClient* aBuffer, - wr::RenderRoot aRenderRoot) override; + void UpdateFromTexture(TextureClient* aBuffer +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif + ) override; bool AddTextureClient(TextureClient* aTexture) override { return CanvasClient::AddTextureClient(aTexture); @@ -145,13 +167,21 @@ class CanvasClientSharedSurface : public CanvasClient { void Clear() override { ClearSurfaces(); } - void Update(gfx::IntSize aSize, ShareableCanvasRenderer* aCanvasRenderer, - wr::RenderRoot aRenderRoot) override; + void Update(gfx::IntSize aSize, ShareableCanvasRenderer* aCanvasRenderer +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif + ) override; void UpdateRenderer(gfx::IntSize aSize, Renderer& aRenderer); void UpdateAsync(AsyncCanvasRenderer* aRenderer) override; - void Updated(wr::RenderRoot aRenderRoot) override; + void Updated( +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRoot aRenderRoot +#endif + ) override; void OnDetach() override; }; @@ -171,8 +201,13 @@ class CanvasClientBridge final : public CanvasClient { return TextureInfo(CompositableType::IMAGE); } - void Update(gfx::IntSize aSize, ShareableCanvasRenderer* aCanvasRenderer, - wr::RenderRoot aRenderRoot) override {} + void Update(gfx::IntSize aSize, ShareableCanvasRenderer* aCanvasRenderer +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RenderRoot aRenderRoot +#endif + ) override { + } void UpdateAsync(AsyncCanvasRenderer* aRenderer) override; diff --git a/gfx/layers/client/ClientImageLayer.cpp b/gfx/layers/client/ClientImageLayer.cpp index 0bd8e83aed..d826bed678 100644 --- a/gfx/layers/client/ClientImageLayer.cpp +++ b/gfx/layers/client/ClientImageLayer.cpp @@ -115,8 +115,12 @@ void ClientImageLayer::RenderLayer() { return; } - if (!mImageClient || - !mImageClient->UpdateImage(mContainer, GetContentFlags(), Nothing())) { + if (!mImageClient || !mImageClient->UpdateImage(mContainer, GetContentFlags() +#ifdef MOZ_BUILD_WEBRENDER + , + Nothing() +#endif + )) { CompositableType type = GetImageClientType(); if (type == CompositableType::UNKNOWN) { return; @@ -132,7 +136,12 @@ void ClientImageLayer::RenderLayer() { mImageClient->Connect(); ClientManager()->AsShadowForwarder()->Attach(mImageClient, this); } - if (!mImageClient->UpdateImage(mContainer, GetContentFlags(), Nothing())) { + if (!mImageClient->UpdateImage(mContainer, GetContentFlags() +#ifdef MOZ_BUILD_WEBRENDER + , + Nothing() +#endif + )) { return; } } diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 489bd8c02d..c56b5dc4ef 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -612,12 +612,16 @@ void ClientLayerManager::MakeSnapshotIfRequired() { void ClientLayerManager::FlushRendering() { if (mWidget) { if (CompositorBridgeChild* remoteRenderer = mWidget->GetRemoteRenderer()) { +#ifdef MOZ_BUILD_WEBRENDER if (mWidget->SynchronouslyRepaintOnResize() || StaticPrefs::layers_force_synchronous_resize()) { remoteRenderer->SendFlushRendering(); } else { remoteRenderer->SendFlushRenderingAsync(); } +#else + remoteRenderer->SendFlushRendering(); +#endif } } } diff --git a/gfx/layers/client/CompositableClient.cpp b/gfx/layers/client/CompositableClient.cpp index 710aa57a50..5acefdfb96 100644 --- a/gfx/layers/client/CompositableClient.cpp +++ b/gfx/layers/client/CompositableClient.cpp @@ -124,9 +124,18 @@ void CompositableClient::HandleMemoryPressure() { } } -void CompositableClient::RemoveTexture( - TextureClient* aTexture, const Maybe& aRenderRoot) { - mForwarder->RemoveTextureFromCompositable(this, aTexture, aRenderRoot); +void CompositableClient::RemoveTexture(TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif +) { + mForwarder->RemoveTextureFromCompositable(this, aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + aRenderRoot +#endif + ); } TextureClientRecycleAllocator* CompositableClient::GetTextureClientRecycler() { @@ -198,7 +207,12 @@ void CompositableClient::DumpTextureClient(std::stringstream& aStream, AutoRemoveTexture::~AutoRemoveTexture() { if (mCompositable && mTexture && mCompositable->IsConnected()) { - mCompositable->RemoveTexture(mTexture, Some(mRenderRoot)); + mCompositable->RemoveTexture(mTexture +#ifdef MOZ_BUILD_WEBRENDER + , + Some(mRenderRoot) +#endif + ); } } diff --git a/gfx/layers/client/CompositableClient.h b/gfx/layers/client/CompositableClient.h index a6934690c7..42b4db779c 100644 --- a/gfx/layers/client/CompositableClient.h +++ b/gfx/layers/client/CompositableClient.h @@ -14,8 +14,10 @@ #include "mozilla/layers/CompositorTypes.h" #include "mozilla/layers/LayersTypes.h" // for LayersBackend, TextureDumpMode #include "mozilla/layers/TextureClient.h" // for TextureClient -#include "mozilla/webrender/WebRenderTypes.h" // for RenderRoot -#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" // for RenderRoot +#endif +#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc namespace mozilla { namespace layers { @@ -155,8 +157,12 @@ class CompositableClient { * * See AutoRemoveTexture to automatically invoke this at the end of a scope. */ - virtual void RemoveTexture(TextureClient* aTexture, - const Maybe& aRenderRoot); + virtual void RemoveTexture(TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ); void InitIPDL(const CompositableHandle& aHandle); @@ -188,11 +194,18 @@ class CompositableClient { */ struct AutoRemoveTexture { AutoRemoveTexture(CompositableClient* aCompositable, +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot aRenderRoot, +#endif TextureClient* aTexture = nullptr) : mTexture(aTexture), - mCompositable(aCompositable), - mRenderRoot(aRenderRoot) {} + mCompositable(aCompositable) +#ifdef MOZ_BUILD_WEBRENDER + , + mRenderRoot(aRenderRoot) +#endif + { + } ~AutoRemoveTexture(); @@ -200,7 +213,9 @@ struct AutoRemoveTexture { private: CompositableClient* mCompositable; +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot mRenderRoot; +#endif }; } // namespace layers diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index 655dbe7203..d86ba2aef1 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -3,10 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/layers/ContentClient.h" -#include "BasicLayers.h" // for BasicLayerManager -#include "gfxContext.h" // for gfxContext, etc -#include "gfxPlatform.h" // for gfxPlatform -#include "gfxEnv.h" // for gfxEnv +#include "BasicLayers.h" // for BasicLayerManager +#include "gfxContext.h" // for gfxContext, etc +#include "gfxPlatform.h" // for gfxPlatform +#include "gfxEnv.h" // for gfxEnv #include "gfxPoint.h" // for IntSize, gfxPoint #include "gfxUtils.h" // for gfxUtils @@ -144,10 +144,12 @@ ContentClient::PaintState ContentClient::BeginPaint(PaintedLayer* aLayer, // We need to disable rotation if we're going to be resampled when // drawing, because we might sample across the rotation boundary. // Also disable buffer rotation when using webrender. - bool canHaveRotation = - gfxPlatform::BufferRotationEnabled() && - !(aFlags & (PAINT_WILL_RESAMPLE | PAINT_NO_ROTATION)) && - !(aLayer->Manager()->AsWebRenderLayerManager()); + bool canHaveRotation = gfxPlatform::BufferRotationEnabled() && + !(aFlags & (PAINT_WILL_RESAMPLE | PAINT_NO_ROTATION)) +#ifdef MOZ_BUILD_WEBRENDER + && !(aLayer->Manager()->AsWebRenderLayerManager()) +#endif + ; bool canDrawRotated = aFlags & PAINT_CAN_DRAW_ROTATED; OpenMode readMode = result.mAsyncPaint ? OpenMode::OPEN_READ_ASYNC : OpenMode::OPEN_READ; @@ -713,7 +715,12 @@ void ContentClientRemoteBuffer::Updated(const nsIntRegion& aRegionToDraw, IntSize size = remoteBuffer->GetClient()->GetSize(); t->mPictureRect = nsIntRect(0, 0, size.width, size.height); - GetForwarder()->UseTextures(this, textures, Nothing()); + GetForwarder()->UseTextures(this, textures +#ifdef MOZ_BUILD_WEBRENDER + , + Nothing() +#endif + ); } // This forces a synchronous transaction, so we can swap buffers now diff --git a/gfx/layers/client/ImageClient.cpp b/gfx/layers/client/ImageClient.cpp index deeb1751cc..8b54c6a5d1 100644 --- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -62,9 +62,18 @@ already_AddRefed ImageClient::CreateImageClient( return result.forget(); } -void ImageClient::RemoveTexture(TextureClient* aTexture, - const Maybe& aRenderRoot) { - GetForwarder()->RemoveTextureFromCompositable(this, aTexture, aRenderRoot); +void ImageClient::RemoveTexture(TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif +) { + GetForwarder()->RemoveTextureFromCompositable(this, aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + aRenderRoot +#endif + ); } ImageClientSingle::ImageClientSingle(CompositableForwarder* aFwd, @@ -82,7 +91,12 @@ void ImageClientSingle::FlushAllImages() { // the texture actually presents in a content render root, as the only // risk would be if the content render root has not / is not going to // generate a frame before the texture gets cleared. - RemoveTexture(b.mTextureClient, Some(wr::RenderRoot::Default)); + RemoveTexture(b.mTextureClient +#ifdef MOZ_BUILD_WEBRENDER + , + Some(wr::RenderRoot::Default) +#endif + ); } mBuffers.Clear(); } @@ -160,8 +174,12 @@ already_AddRefed ImageClient::CreateTextureClientForImage( } bool ImageClientSingle::UpdateImage(ImageContainer* aContainer, - uint32_t aContentFlags, - const Maybe& aRenderRoot) { + uint32_t aContentFlags +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif +) { AutoTArray images; uint32_t generationCounter; aContainer->GetCurrentImages(&images, &generationCounter); @@ -185,7 +203,12 @@ bool ImageClientSingle::UpdateImage(ImageContainer* aContainer, // We return true because the caller would attempt to recreate the // ImageClient otherwise, and that isn't going to help. for (auto& b : mBuffers) { - RemoveTexture(b.mTextureClient, aRenderRoot); + RemoveTexture(b.mTextureClient +#ifdef MOZ_BUILD_WEBRENDER + , + aRenderRoot +#endif + ); } mBuffers.Clear(); return true; @@ -249,10 +272,20 @@ bool ImageClientSingle::UpdateImage(ImageContainer* aContainer, texture->SyncWithObject(GetForwarder()->GetSyncObject()); } - GetForwarder()->UseTextures(this, textures, aRenderRoot); + GetForwarder()->UseTextures(this, textures +#ifdef MOZ_BUILD_WEBRENDER + , + aRenderRoot +#endif + ); for (auto& b : mBuffers) { - RemoveTexture(b.mTextureClient, aRenderRoot); + RemoveTexture(b.mTextureClient +#ifdef MOZ_BUILD_WEBRENDER + , + aRenderRoot +#endif + ); } mBuffers.SwapElements(newBuffers); @@ -285,8 +318,12 @@ ImageClientBridge::ImageClientBridge(CompositableForwarder* aFwd, : ImageClient(aFwd, aFlags, CompositableType::IMAGE_BRIDGE) {} bool ImageClientBridge::UpdateImage(ImageContainer* aContainer, - uint32_t aContentFlags, - const Maybe& aRenderRoot) { + uint32_t aContentFlags +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif +) { if (!GetForwarder() || !mLayer) { return false; } diff --git a/gfx/layers/client/ImageClient.h b/gfx/layers/client/ImageClient.h index ec87789955..42ce403633 100644 --- a/gfx/layers/client/ImageClient.h +++ b/gfx/layers/client/ImageClient.h @@ -51,8 +51,12 @@ class ImageClient : public CompositableClient { * returns false if this is the wrong kind of ImageClient for aContainer. * Note that returning true does not necessarily imply success */ - virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags, - const Maybe& aRenderRoot) = 0; + virtual bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ) = 0; void SetLayer(ClientLayer* aLayer) { mLayer = aLayer; } ClientLayer* GetLayer() const { return mLayer; } @@ -63,8 +67,12 @@ class ImageClient : public CompositableClient { */ virtual void FlushAllImages() {} - virtual void RemoveTexture(TextureClient* aTexture, - const Maybe& aRenderRoot) override; + virtual void RemoveTexture(TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ) override; virtual ImageClientSingle* AsImageClientSingle() { return nullptr; } @@ -94,8 +102,12 @@ class ImageClientSingle : public ImageClient { ImageClientSingle(CompositableForwarder* aFwd, TextureFlags aFlags, CompositableType aType); - bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag, - const Maybe& aRenderRoot) override; + bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ) override; void OnDetach() override; @@ -128,8 +140,12 @@ class ImageClientBridge : public ImageClient { public: ImageClientBridge(CompositableForwarder* aFwd, TextureFlags aFlags); - bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags, - const Maybe& aRenderRoot) override; + bool UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ) override; bool Connect(ImageContainer* aImageContainer) override { return false; } TextureInfo GetTextureInfo() const override { return TextureInfo(mType); } diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index f21ef5a9b7..5d7f6d3069 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -888,9 +888,11 @@ bool TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) { return false; } +#ifdef MOZ_BUILD_WEBRENDER // Try external image id allocation. mExternalImageId = aForwarder->GetTextureForwarder()->GetNextExternalImageId(); +#endif nsIEventTarget* target = nullptr; // Get the layers id if the forwarder is a ShadowLayerForwarder. @@ -905,7 +907,11 @@ bool TextureClient::InitIPDLActor(CompositableForwarder* aForwarder) { PTextureChild* actor = aForwarder->GetTextureForwarder()->CreateTexture( desc, readLockDescriptor, aForwarder->GetCompositorBackendType(), - GetFlags(), mSerial, mExternalImageId, target); + GetFlags(), mSerial, +#ifdef MOZ_BUILD_WEBRENDER + mExternalImageId, +#endif + target); if (!actor) { gfxCriticalNote << static_cast(desc.type()) << ", " @@ -962,9 +968,11 @@ bool TextureClient::InitIPDLActor(KnowsCompositor* aKnowsCompositor) { return false; } +#ifdef MOZ_BUILD_WEBRENDER // Try external image id allocation. mExternalImageId = aKnowsCompositor->GetTextureForwarder()->GetNextExternalImageId(); +#endif ReadLockDescriptor readLockDescriptor = null_t(); if (mReadLock) { @@ -973,7 +981,12 @@ bool TextureClient::InitIPDLActor(KnowsCompositor* aKnowsCompositor) { PTextureChild* actor = fwd->CreateTexture( desc, readLockDescriptor, aKnowsCompositor->GetCompositorBackendType(), - GetFlags(), mSerial, mExternalImageId); + GetFlags(), mSerial +#ifdef MOZ_BUILD_WEBRENDER + , + mExternalImageId +#endif + ); if (!actor) { gfxCriticalNote << static_cast(desc.type()) << ", " << static_cast( diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index 190d249ce9..238bcb72af 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -25,7 +25,9 @@ #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor #include "mozilla/mozalloc.h" // for operator delete #include "mozilla/gfx/CriticalSection.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "nsCOMPtr.h" // for already_AddRefed #include "nsISupportsImpl.h" // for TextureImage::AddRef, etc #include "GfxTexturesReporter.h" @@ -631,7 +633,9 @@ class TextureClient : public AtomicRefCountedWithFinalize { // must only be called from the PaintThread. void DropPaintThreadRef(); +#ifdef MOZ_BUILD_WEBRENDER wr::MaybeExternalImageId GetExternalImageKey() { return mExternalImageId; } +#endif private: static void TextureClientRecycleCallback(TextureClient* aClient, @@ -723,11 +727,13 @@ class TextureClient : public AtomicRefCountedWithFinalize { // When non-zero, texture data must not be freed. mozilla::Atomic mPaintThreadRefs; +#ifdef MOZ_BUILD_WEBRENDER // External image id. It is unique if it is allocated. // The id is allocated in TextureClient::InitIPDLActor(). // Its allocation is supported by // CompositorBridgeChild and ImageBridgeChild for now. wr::MaybeExternalImageId mExternalImageId; +#endif // Used to assign serial ids of TextureClient. static mozilla::Atomic sSerialCounter; diff --git a/gfx/layers/composite/CompositableHost.cpp b/gfx/layers/composite/CompositableHost.cpp index bbddc6cca0..5e9476ad0c 100644 --- a/gfx/layers/composite/CompositableHost.cpp +++ b/gfx/layers/composite/CompositableHost.cpp @@ -13,7 +13,9 @@ #include "mozilla/gfx/gfxVars.h" #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor #include "mozilla/layers/TextureHost.h" // for TextureHost, etc -#include "mozilla/layers/WebRenderImageHost.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderImageHost.h" +#endif #include "mozilla/RefPtr.h" // for nsRefPtr #include "nsDebug.h" // for NS_WARNING #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc @@ -104,7 +106,12 @@ void CompositableHost::RemoveMaskEffect() { /* static */ already_AddRefed CompositableHost::Create( - const TextureInfo& aTextureInfo, bool aUseWebRender) { + const TextureInfo& aTextureInfo +#ifdef MOZ_BUILD_WEBRENDER + , + bool aUseWebRender +#endif +) { RefPtr result; switch (aTextureInfo.mCompositableType) { case CompositableType::IMAGE_BRIDGE: @@ -114,21 +121,25 @@ already_AddRefed CompositableHost::Create( result = new TiledContentHost(aTextureInfo); break; case CompositableType::IMAGE: - if (aUseWebRender) { +#ifdef MOZ_BUILD_WEBRENDER + if (aUseWebRender) result = new WebRenderImageHost(aTextureInfo); - } else { + else +#endif result = new ImageHost(aTextureInfo); - } break; case CompositableType::CONTENT_SINGLE: - if (aUseWebRender) { +#ifdef MOZ_BUILD_WEBRENDER + if (aUseWebRender) result = new WebRenderImageHost(aTextureInfo); - } else { + else +#endif result = new ContentHostSingleBuffered(aTextureInfo); - } break; case CompositableType::CONTENT_DOUBLE: +#ifdef MOZ_BUILD_WEBRENDER MOZ_ASSERT(!aUseWebRender); +#endif result = new ContentHostDoubleBuffered(aTextureInfo); break; default: diff --git a/gfx/layers/composite/CompositableHost.h b/gfx/layers/composite/CompositableHost.h index 18689f2b89..5479cc11f9 100644 --- a/gfx/layers/composite/CompositableHost.h +++ b/gfx/layers/composite/CompositableHost.h @@ -43,7 +43,9 @@ class Compositor; class ThebesBufferData; class TiledContentHost; class CompositableParentManager; +#ifdef MOZ_BUILD_WEBRENDER class WebRenderImageHost; +#endif class ContentHost; class ContentHostTexture; class HostLayerManager; @@ -87,7 +89,12 @@ class CompositableHost { explicit CompositableHost(const TextureInfo& aTextureInfo); static already_AddRefed Create( - const TextureInfo& aTextureInfo, bool aUseWebRender); + const TextureInfo& aTextureInfo +#ifdef MOZ_BUILD_WEBRENDER + , + bool aUseWebRender +#endif + ); virtual CompositableType GetType() = 0; @@ -128,7 +135,10 @@ class CompositableHost { return gfx::IntSize(); } +#ifdef MOZ_BUILD_WEBRENDER const TextureInfo& GetTextureInfo() const { return mTextureInfo; } + virtual WebRenderImageHost* AsWebRenderImageHost() { return nullptr; } +#endif /** * Adds a mask effect using this texture as the mask, if possible. @@ -147,7 +157,6 @@ class CompositableHost { virtual ContentHostTexture* AsContentHostTexture() { return nullptr; } virtual ImageHost* AsImageHost() { return nullptr; } virtual TiledContentHost* AsTiledContentHost() { return nullptr; } - virtual WebRenderImageHost* AsWebRenderImageHost() { return nullptr; } typedef uint32_t AttachFlags; static const AttachFlags NO_FLAGS = 0; diff --git a/gfx/layers/composite/GPUVideoTextureHost.cpp b/gfx/layers/composite/GPUVideoTextureHost.cpp index 7e9b2636f1..ba057f6561 100644 --- a/gfx/layers/composite/GPUVideoTextureHost.cpp +++ b/gfx/layers/composite/GPUVideoTextureHost.cpp @@ -101,6 +101,7 @@ bool GPUVideoTextureHost::HasIntermediateBuffer() const { return mWrappedTextureHost->HasIntermediateBuffer(); } +#ifdef MOZ_BUILD_WEBRENDER void GPUVideoTextureHost::CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) { MOZ_ASSERT(mWrappedTextureHost); @@ -130,6 +131,7 @@ void GPUVideoTextureHost::PushDisplayItems( mWrappedTextureHost->PushDisplayItems(aBuilder, aBounds, aClip, aFilter, aImageKeys); } +#endif } // namespace layers } // namespace mozilla diff --git a/gfx/layers/composite/GPUVideoTextureHost.h b/gfx/layers/composite/GPUVideoTextureHost.h index 6e821c36d0..b488822218 100644 --- a/gfx/layers/composite/GPUVideoTextureHost.h +++ b/gfx/layers/composite/GPUVideoTextureHost.h @@ -46,6 +46,7 @@ class GPUVideoTextureHost : public TextureHost { bool HasIntermediateBuffer() const override; +#ifdef MOZ_BUILD_WEBRENDER void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; @@ -60,6 +61,7 @@ class GPUVideoTextureHost : public TextureHost { const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip, wr::ImageRendering aFilter, const Range& aImageKeys) override; +#endif protected: GPUVideoTextureHost(TextureFlags aFlags, TextureHost* aWrappedTextureHost); diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index d6739b8d1e..59e822252c 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -23,10 +23,12 @@ # include "mozilla/layers/TextureSync.h" #endif #include "mozilla/layers/GPUVideoTextureHost.h" -#include "mozilla/layers/WebRenderTextureHost.h" -#include "mozilla/webrender/RenderBufferTextureHost.h" -#include "mozilla/webrender/RenderThread.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderTextureHost.h" +# include "mozilla/webrender/RenderBufferTextureHost.h" +# include "mozilla/webrender/RenderThread.h" +# include "mozilla/webrender/WebRenderAPI.h" +#endif #include "nsAString.h" #include "mozilla/RefPtr.h" // for nsRefPtr #include "nsPrintfCString.h" // for nsPrintfCString @@ -74,8 +76,12 @@ namespace layers { */ class TextureParent : public ParentActor { public: - TextureParent(HostIPCAllocator* aAllocator, uint64_t aSerial, - const wr::MaybeExternalImageId& aExternalImageId); + TextureParent(HostIPCAllocator* aAllocator, uint64_t aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif + ); virtual ~TextureParent(); @@ -98,9 +104,12 @@ class TextureParent : public ParentActor { RefPtr mTextureHost; // mSerial is unique in TextureClient's process. const uint64_t mSerial; +#ifdef MOZ_BUILD_WEBRENDER wr::MaybeExternalImageId mExternalImageId; +#endif }; +#ifdef MOZ_BUILD_WEBRENDER static bool WrapWithWebRenderTextureHost(ISurfaceAllocator* aDeallocator, LayersBackend aBackend, TextureFlags aFlags) { @@ -112,15 +121,24 @@ static bool WrapWithWebRenderTextureHost(ISurfaceAllocator* aDeallocator, } return true; } +#endif //////////////////////////////////////////////////////////////////////////////// PTextureParent* TextureHost::CreateIPDLActor( HostIPCAllocator* aAllocator, const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, LayersBackend aLayersBackend, - TextureFlags aFlags, uint64_t aSerial, - const wr::MaybeExternalImageId& aExternalImageId) { - TextureParent* actor = - new TextureParent(aAllocator, aSerial, aExternalImageId); + TextureFlags aFlags, uint64_t aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif +) { + TextureParent* actor = new TextureParent(aAllocator, aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + aExternalImageId +#endif + ); if (!actor->Init(aSharedData, aReadLock, aLayersBackend, aFlags)) { actor->ActorDestroy(ipc::IProtocol::ActorDestroyReason::FailedConstructor); delete actor; @@ -165,8 +183,12 @@ void TextureHost::SetLastFwdTransactionId(uint64_t aTransactionId) { already_AddRefed TextureHost::Create( const SurfaceDescriptor& aDesc, const ReadLockDescriptor& aReadLock, - ISurfaceAllocator* aDeallocator, LayersBackend aBackend, - TextureFlags aFlags, wr::MaybeExternalImageId& aExternalImageId) { + ISurfaceAllocator* aDeallocator, LayersBackend aBackend, TextureFlags aFlags +#ifdef MOZ_BUILD_WEBRENDER + , + wr::MaybeExternalImageId& aExternalImageId +#endif +) { RefPtr result; switch (aDesc.type()) { @@ -229,11 +251,13 @@ already_AddRefed TextureHost::Create( gfxCriticalNote << "TextureHost creation failure type=" << aDesc.type(); } +#ifdef MOZ_BUILD_WEBRENDER if (result && WrapWithWebRenderTextureHost(aDeallocator, aBackend, aFlags)) { MOZ_ASSERT(aExternalImageId.isSome()); result = new WebRenderTextureHost(aDesc, aFlags, result, aExternalImageId.ref()); } +#endif if (result) { result->DeserializeReadLock(aReadLock, aDeallocator); @@ -569,6 +593,7 @@ void BufferTextureHost::Unlock() { mLocked = false; } +#ifdef MOZ_BUILD_WEBRENDER void BufferTextureHost::CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) { RefPtr texture = @@ -636,6 +661,7 @@ void BufferTextureHost::PushDisplayItems( wr::ToWrColorRange(desc.colorRange()), aFilter); } } +#endif // MOZ_BUILD_WEBRENDER void TextureHost::DeserializeReadLock(const ReadLockDescriptor& aDesc, ISurfaceAllocator* aAllocator) { @@ -1171,11 +1197,19 @@ size_t MemoryTextureHost::GetBufferSize() { } TextureParent::TextureParent(HostIPCAllocator* aSurfaceAllocator, - uint64_t aSerial, - const wr::MaybeExternalImageId& aExternalImageId) + uint64_t aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif + ) : mSurfaceAllocator(aSurfaceAllocator), - mSerial(aSerial), - mExternalImageId(aExternalImageId) { + mSerial(aSerial) +#ifdef MOZ_BUILD_WEBRENDER + , + mExternalImageId(aExternalImageId) +#endif +{ MOZ_COUNT_CTOR(TextureParent); } @@ -1193,7 +1227,12 @@ bool TextureParent::Init(const SurfaceDescriptor& aSharedData, const LayersBackend& aBackend, const TextureFlags& aFlags) { mTextureHost = TextureHost::Create(aSharedData, aReadLock, mSurfaceAllocator, - aBackend, aFlags, mExternalImageId); + aBackend, aFlags +#ifdef MOZ_BUILD_WEBRENDER + , + mExternalImageId +#endif + ); if (mTextureHost) { mTextureHost->mActor = this; } diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index 9674f77128..916ec92675 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -22,7 +22,9 @@ #include "mozilla/mozalloc.h" // for operator delete #include "mozilla/Range.h" #include "mozilla/UniquePtr.h" // for UniquePtr -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "nsCOMPtr.h" // for already_AddRefed #include "nsDebug.h" // for NS_WARNING #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc @@ -65,7 +67,9 @@ class TextureSourceBasic; class DataTextureSource; class PTextureParent; class TextureParent; +#ifdef MOZ_BUILD_WEBRENDER class WebRenderTextureHost; +#endif class WrappingTextureSourceYCbCrBasic; /** @@ -403,7 +407,12 @@ class TextureHost : public AtomicRefCountedWithFinalize { static already_AddRefed Create( const SurfaceDescriptor& aDesc, const ReadLockDescriptor& aReadLock, ISurfaceAllocator* aDeallocator, LayersBackend aBackend, - TextureFlags aFlags, wr::MaybeExternalImageId& aExternalImageId); + TextureFlags aFlags +#ifdef MOZ_BUILD_WEBRENDER + , + wr::MaybeExternalImageId& aExternalImageId +#endif + ); /** * Lock the texture host for compositing. @@ -562,8 +571,12 @@ class TextureHost : public AtomicRefCountedWithFinalize { static PTextureParent* CreateIPDLActor( HostIPCAllocator* aAllocator, const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aDescriptor, LayersBackend aLayersBackend, - TextureFlags aFlags, uint64_t aSerial, - const wr::MaybeExternalImageId& aExternalImageId); + TextureFlags aFlags, uint64_t aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif + ); static bool DestroyIPDLActor(PTextureParent* actor); /** @@ -636,9 +649,11 @@ class TextureHost : public AtomicRefCountedWithFinalize { virtual MacIOSurfaceTextureHostOGL* AsMacIOSurfaceTextureHost() { return nullptr; } - virtual WebRenderTextureHost* AsWebRenderTextureHost() { return nullptr; } virtual SurfaceTextureHost* AsSurfaceTextureHost() { return nullptr; } +#ifdef MOZ_BUILD_WEBRENDER + virtual WebRenderTextureHost* AsWebRenderTextureHost() { return nullptr; } + // Create the corresponding RenderTextureHost type of this texture, and // register the RenderTextureHost into render thread. virtual void CreateRenderTexture( @@ -675,6 +690,7 @@ class TextureHost : public AtomicRefCountedWithFinalize { MOZ_ASSERT_UNREACHABLE( "No PushDisplayItems() implementation for this TextureHost type."); } +#endif /** * Some API's can use the cross-process IOSurface directly, such as OpenVR @@ -784,6 +800,7 @@ class BufferTextureHost : public TextureHost { const BufferDescriptor& GetBufferDescriptor() const { return mDescriptor; } +#ifdef MOZ_BUILD_WEBRENDER void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; @@ -798,6 +815,7 @@ class BufferTextureHost : public TextureHost { const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip, wr::ImageRendering aFilter, const Range& aImageKeys) override; +#endif void ReadUnlock() override; bool IsDirectMap() override { diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index 7a51f3909a..56c41e2a67 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -16,9 +16,11 @@ #include "mozilla/gfx/Logging.h" #include "mozilla/gfx/gfxVars.h" #include "mozilla/layers/CompositorBridgeChild.h" -#include "mozilla/webrender/RenderD3D11TextureHostOGL.h" -#include "mozilla/webrender/RenderThread.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/RenderD3D11TextureHostOGL.h" +# include "mozilla/webrender/RenderThread.h" +# include "mozilla/webrender/WebRenderAPI.h" +#endif namespace mozilla { @@ -554,12 +556,14 @@ void D3D11TextureData::GetDXGIResource(IDXGIResource** aOutResource) { TextureFlags D3D11TextureData::GetTextureFlags() const { TextureFlags flags = TextureFlags::NO_FLAGS; +#ifdef MOZ_BUILD_WEBRENDER // With WebRender, resource open happens asynchronously on RenderThread. // During opening the resource on host side, TextureClient needs to be alive. // With WAIT_HOST_USAGE_END, keep TextureClient alive during host side usage. if (gfx::gfxVars::UseWebRender()) { flags |= TextureFlags::WAIT_HOST_USAGE_END; } +#endif return flags; } @@ -696,12 +700,14 @@ void DXGIYCbCrTextureData::Deallocate(LayersIPCChannel*) { TextureFlags DXGIYCbCrTextureData::GetTextureFlags() const { TextureFlags flags = TextureFlags::DEALLOCATE_MAIN_THREAD; +#ifdef MOZ_BUILD_WEBRENDER // With WebRender, resource open happens asynchronously on RenderThread. // During opening the resource on host side, TextureClient needs to be alive. // With WAIT_HOST_USAGE_END, keep TextureClient alive during host side usage. if (gfx::gfxVars::UseWebRender()) { flags |= TextureFlags::WAIT_HOST_USAGE_END; } +#endif return flags; } @@ -872,6 +878,7 @@ bool DXGITextureHostD3D11::LockInternal() { } already_AddRefed DXGITextureHostD3D11::GetAsSurface() { +#ifdef MOZ_BUILD_WEBRENDER if (!gfxVars::UseWebRender()) { return nullptr; } @@ -928,6 +935,9 @@ already_AddRefed DXGITextureHostD3D11::GetAsSurface() { (uint8_t*)mappedSubresource.pData, mappedSubresource.RowPitch); context->Unmap(cpuTexture, 0); return surf.forget(); +#else + return nullptr; +#endif // MOZ_BUILD_WEBRENDER } bool DXGITextureHostD3D11::EnsureTextureSource() { @@ -973,6 +983,7 @@ bool DXGITextureHostD3D11::AcquireTextureSource( return true; } +#ifdef MOZ_BUILD_WEBRENDER void DXGITextureHostD3D11::CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) { RefPtr texture = @@ -1084,6 +1095,7 @@ void DXGITextureHostD3D11::PushDisplayItems( } } } +#endif // MOZ_BUILD_WEBRENDER DXGIYCbCrTextureHostD3D11::DXGIYCbCrTextureHostD3D11( TextureFlags aFlags, const SurfaceDescriptorDXGIYCbCr& aDescriptor) @@ -1235,6 +1247,7 @@ bool DXGIYCbCrTextureHostD3D11::BindTextureSource( return !!aTexture; } +#ifdef MOZ_BUILD_WEBRENDER void DXGIYCbCrTextureHostD3D11::CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) { RefPtr texture = @@ -1291,6 +1304,7 @@ void DXGIYCbCrTextureHostD3D11::PushDisplayItems( wr::ToWrColorDepth(mColorDepth), wr::ToWrYuvColorSpace(mYUVColorSpace), wr::ToWrColorRange(mColorRange), aFilter); } +#endif bool DXGIYCbCrTextureHostD3D11::AcquireTextureSource( CompositableTextureSourceRef& aTexture) { @@ -1675,10 +1689,12 @@ bool SyncObjectD3D11Client::IsSyncObjectValid() { dev = DeviceManagerDx::Get()->GetContentDevice(); } +#ifdef MOZ_BUILD_WEBRENDER // Update mDevice if the ContentDevice initialization is detected. if (!mDevice && dev && NS_IsMainThread() && gfxVars::UseWebRender()) { mDevice = dev; } +#endif if (!dev || (NS_IsMainThread() && dev != mDevice)) { return false; diff --git a/gfx/layers/d3d11/TextureD3D11.h b/gfx/layers/d3d11/TextureD3D11.h index ecf72e704d..9b8713726a 100644 --- a/gfx/layers/d3d11/TextureD3D11.h +++ b/gfx/layers/d3d11/TextureD3D11.h @@ -343,6 +343,7 @@ class DXGITextureHostD3D11 : public TextureHost { already_AddRefed GetAsSurface() override; +#ifdef MOZ_BUILD_WEBRENDER void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; @@ -357,6 +358,7 @@ class DXGITextureHostD3D11 : public TextureHost { const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip, wr::ImageRendering aFilter, const Range& aImageKeys) override; +#endif protected: bool LockInternal(); @@ -411,6 +413,7 @@ class DXGIYCbCrTextureHostD3D11 : public TextureHost { return nullptr; } +#ifdef MOZ_BUILD_WEBRENDER void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; @@ -425,6 +428,7 @@ class DXGIYCbCrTextureHostD3D11 : public TextureHost { const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip, wr::ImageRendering aFilter, const Range& aImageKeys) override; +#endif private: bool EnsureTextureSource(); diff --git a/gfx/layers/ipc/APZCTreeManagerChild.cpp b/gfx/layers/ipc/APZCTreeManagerChild.cpp index ea8502c199..7a308fab7b 100644 --- a/gfx/layers/ipc/APZCTreeManagerChild.cpp +++ b/gfx/layers/ipc/APZCTreeManagerChild.cpp @@ -46,9 +46,13 @@ void APZCTreeManagerChild::SetKeyboardMap(const KeyboardMap& aKeyboardMap) { SendSetKeyboardMap(aKeyboardMap); } -void APZCTreeManagerChild::ZoomToRect(const SLGuidAndRenderRoot& aGuid, - const CSSRect& aRect, - const uint32_t aFlags) { +void APZCTreeManagerChild::ZoomToRect( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const CSSRect& aRect, const uint32_t aFlags) { SendZoomToRect(aGuid, aRect, aFlags); } @@ -58,12 +62,22 @@ void APZCTreeManagerChild::ContentReceivedInputBlock(uint64_t aInputBlockId, } void APZCTreeManagerChild::SetTargetAPZC( - uint64_t aInputBlockId, const nsTArray& aTargets) { + uint64_t aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif +) { SendSetTargetAPZC(aInputBlockId, aTargets); } void APZCTreeManagerChild::UpdateZoomConstraints( +#ifdef MOZ_BUILD_WEBRENDER const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif const Maybe& aConstraints) { if (mIPCOpen) { SendUpdateZoomConstraints(aGuid, aConstraints); @@ -78,16 +92,32 @@ void APZCTreeManagerChild::SetAllowedTouchBehavior( } void APZCTreeManagerChild::StartScrollbarDrag( - const SLGuidAndRenderRoot& aGuid, const AsyncDragMetrics& aDragMetrics) { +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const AsyncDragMetrics& aDragMetrics) { SendStartScrollbarDrag(aGuid, aDragMetrics); } -bool APZCTreeManagerChild::StartAutoscroll(const SLGuidAndRenderRoot& aGuid, - const ScreenPoint& aAnchorLocation) { +bool APZCTreeManagerChild::StartAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const ScreenPoint& aAnchorLocation) { return SendStartAutoscroll(aGuid, aAnchorLocation); } -void APZCTreeManagerChild::StopAutoscroll(const SLGuidAndRenderRoot& aGuid) { +void APZCTreeManagerChild::StopAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif +) { SendStopAutoscroll(aGuid); } diff --git a/gfx/layers/ipc/APZCTreeManagerChild.h b/gfx/layers/ipc/APZCTreeManagerChild.h index 7d2e411b41..296d5e38ce 100644 --- a/gfx/layers/ipc/APZCTreeManagerChild.h +++ b/gfx/layers/ipc/APZCTreeManagerChild.h @@ -28,17 +28,31 @@ class APZCTreeManagerChild : public IAPZCTreeManager, void SetKeyboardMap(const KeyboardMap& aKeyboardMap) override; - void ZoomToRect(const SLGuidAndRenderRoot& aGuid, const CSSRect& aRect, - const uint32_t aFlags = DEFAULT_BEHAVIOR) override; + void ZoomToRect( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const CSSRect& aRect, const uint32_t aFlags = DEFAULT_BEHAVIOR) override; void ContentReceivedInputBlock(uint64_t aInputBlockId, bool aPreventDefault) override; void SetTargetAPZC(uint64_t aInputBlockId, - const nsTArray& aTargets) override; +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) override; void UpdateZoomConstraints( +#ifdef MOZ_BUILD_WEBRENDER const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif const Maybe& aConstraints) override; void SetDPI(float aDpiValue) override; @@ -47,13 +61,29 @@ class APZCTreeManagerChild : public IAPZCTreeManager, uint64_t aInputBlockId, const nsTArray& aValues) override; - void StartScrollbarDrag(const SLGuidAndRenderRoot& aGuid, - const AsyncDragMetrics& aDragMetrics) override; - - bool StartAutoscroll(const SLGuidAndRenderRoot& aGuid, - const ScreenPoint& aAnchorLocation) override; + void StartScrollbarDrag( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const AsyncDragMetrics& aDragMetrics) override; - void StopAutoscroll(const SLGuidAndRenderRoot& aGuid) override; + bool StartAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const ScreenPoint& aAnchorLocation) override; + + void StopAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif + ) override; void SetLongTapEnabled(bool aTapGestureEnabled) override; diff --git a/gfx/layers/ipc/APZCTreeManagerParent.cpp b/gfx/layers/ipc/APZCTreeManagerParent.cpp index 72ee34611d..63ebea39f5 100644 --- a/gfx/layers/ipc/APZCTreeManagerParent.cpp +++ b/gfx/layers/ipc/APZCTreeManagerParent.cpp @@ -12,9 +12,18 @@ namespace mozilla { namespace layers { APZCTreeManagerParent::APZCTreeManagerParent( - WRRootId aWrRootId, RefPtr aAPZCTreeManager, - RefPtr aAPZUpdater) - : mWrRootId(aWrRootId), +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId, +#else + LayersId aLayersId, +#endif + RefPtr aAPZCTreeManager, RefPtr aAPZUpdater) + : +#ifdef MOZ_BUILD_WEBRENDER + mWrRootId(aWrRootId), +#else + mLayersId(aLayersId), +#endif mTreeManager(std::move(aAPZCTreeManager)), mUpdater(std::move(aAPZUpdater)) { MOZ_ASSERT(mTreeManager != nullptr); @@ -36,7 +45,9 @@ void APZCTreeManagerParent::ChildAdopted( mozilla::ipc::IPCResult APZCTreeManagerParent::RecvSetKeyboardMap( const KeyboardMap& aKeyboardMap) { mUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(mWrRootId), +#endif NewRunnableMethod( "layers::IAPZCTreeManager::SetKeyboardMap", mTreeManager, &IAPZCTreeManager::SetKeyboardMap, aKeyboardMap)); @@ -45,15 +56,24 @@ mozilla::ipc::IPCResult APZCTreeManagerParent::RecvSetKeyboardMap( } mozilla::ipc::IPCResult APZCTreeManagerParent::RecvZoomToRect( - const SLGuidAndRenderRoot& aGuid, const CSSRect& aRect, - const uint32_t& aFlags) { +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const CSSRect& aRect, const uint32_t& aFlags) { if (!IsGuidValid(aGuid)) { return IPC_FAIL_NO_REASON(this); } mUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(aGuid.GetWRRootId()), - NewRunnableMethod( + NewRunnableMethod( "layers::IAPZCTreeManager::ZoomToRect", mTreeManager, &IAPZCTreeManager::ZoomToRect, aGuid, aRect, aFlags)); return IPC_OK(); @@ -62,7 +82,9 @@ mozilla::ipc::IPCResult APZCTreeManagerParent::RecvZoomToRect( mozilla::ipc::IPCResult APZCTreeManagerParent::RecvContentReceivedInputBlock( const uint64_t& aInputBlockId, const bool& aPreventDefault) { mUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(mWrRootId), +#endif NewRunnableMethod( "layers::IAPZCTreeManager::ContentReceivedInputBlock", mTreeManager, &IAPZCTreeManager::ContentReceivedInputBlock, aInputBlockId, @@ -72,18 +94,35 @@ mozilla::ipc::IPCResult APZCTreeManagerParent::RecvContentReceivedInputBlock( } mozilla::ipc::IPCResult APZCTreeManagerParent::RecvSetTargetAPZC( - const uint64_t& aInputBlockId, nsTArray&& aTargets) { + const uint64_t& aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + nsTArray&& aTargets +#else + nsTArray&& aTargets +#endif +) { +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector selector(mWrRootId.mLayersId); +#endif for (size_t i = 0; i < aTargets.Length(); i++) { if (!IsGuidValid(aTargets[i])) { return IPC_FAIL_NO_REASON(this); } +#ifdef MOZ_BUILD_WEBRENDER selector.mRenderRoots += aTargets[i].mRenderRoot; +#endif } mUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER selector, - NewRunnableMethod>>( +#endif + NewRunnableMethod>>( "layers::IAPZCTreeManager::SetTargetAPZC", mTreeManager, &IAPZCTreeManager::SetTargetAPZC, aInputBlockId, aTargets)); @@ -91,12 +130,15 @@ mozilla::ipc::IPCResult APZCTreeManagerParent::RecvSetTargetAPZC( } mozilla::ipc::IPCResult APZCTreeManagerParent::RecvUpdateZoomConstraints( +#ifdef MOZ_BUILD_WEBRENDER const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif const MaybeZoomConstraints& aConstraints) { if (!IsGuidValid(aGuid)) { return IPC_FAIL_NO_REASON(this); } - mTreeManager->UpdateZoomConstraints(aGuid, aConstraints); return IPC_OK(); } @@ -104,7 +146,9 @@ mozilla::ipc::IPCResult APZCTreeManagerParent::RecvUpdateZoomConstraints( mozilla::ipc::IPCResult APZCTreeManagerParent::RecvSetDPI( const float& aDpiValue) { mUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(mWrRootId), +#endif NewRunnableMethod("layers::IAPZCTreeManager::SetDPI", mTreeManager, &IAPZCTreeManager::SetDPI, aDpiValue)); return IPC_OK(); @@ -113,7 +157,9 @@ mozilla::ipc::IPCResult APZCTreeManagerParent::RecvSetDPI( mozilla::ipc::IPCResult APZCTreeManagerParent::RecvSetAllowedTouchBehavior( const uint64_t& aInputBlockId, nsTArray&& aValues) { mUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(mWrRootId), +#endif NewRunnableMethod>>( "layers::IAPZCTreeManager::SetAllowedTouchBehavior", mTreeManager, @@ -124,22 +170,40 @@ mozilla::ipc::IPCResult APZCTreeManagerParent::RecvSetAllowedTouchBehavior( } mozilla::ipc::IPCResult APZCTreeManagerParent::RecvStartScrollbarDrag( - const SLGuidAndRenderRoot& aGuid, const AsyncDragMetrics& aDragMetrics) { +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const AsyncDragMetrics& aDragMetrics) { if (!IsGuidValid(aGuid)) { return IPC_FAIL_NO_REASON(this); } mUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(aGuid.GetWRRootId()), - NewRunnableMethod( - "layers::IAPZCTreeManager::StartScrollbarDrag", mTreeManager, - &IAPZCTreeManager::StartScrollbarDrag, aGuid, aDragMetrics)); +#endif + NewRunnableMethod< +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot, +#else + ScrollableLayerGuid, +#endif + AsyncDragMetrics>("layers::IAPZCTreeManager::StartScrollbarDrag", + mTreeManager, &IAPZCTreeManager::StartScrollbarDrag, + aGuid, aDragMetrics)); return IPC_OK(); } mozilla::ipc::IPCResult APZCTreeManagerParent::RecvStartAutoscroll( - const SLGuidAndRenderRoot& aGuid, const ScreenPoint& aAnchorLocation) { +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const ScreenPoint& aAnchorLocation) { // Unlike RecvStartScrollbarDrag(), this message comes from the parent // process (via nsBaseWidget::mAPZC) rather than from the child process // (via BrowserChild::mApzcTreeManager), so there is no need to check the @@ -148,23 +212,43 @@ mozilla::ipc::IPCResult APZCTreeManagerParent::RecvStartAutoscroll( // sending the child process's layers id). mUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(mWrRootId), - NewRunnableMethod( - "layers::IAPZCTreeManager::StartAutoscroll", mTreeManager, - &IAPZCTreeManager::StartAutoscroll, aGuid, aAnchorLocation)); +#endif + NewRunnableMethod< +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot, +#else + ScrollableLayerGuid, +#endif + ScreenPoint>("layers::IAPZCTreeManager::StartAutoscroll", + mTreeManager, &IAPZCTreeManager::StartAutoscroll, aGuid, + aAnchorLocation)); return IPC_OK(); } mozilla::ipc::IPCResult APZCTreeManagerParent::RecvStopAutoscroll( - const SLGuidAndRenderRoot& aGuid) { +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif +) { // See RecvStartAutoscroll() for why we don't check the layers id. mUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(mWrRootId), - NewRunnableMethod( - "layers::IAPZCTreeManager::StopAutoscroll", mTreeManager, - &IAPZCTreeManager::StopAutoscroll, aGuid)); +#endif + NewRunnableMethod< +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot +#else + ScrollableLayerGuid +#endif + >("layers::IAPZCTreeManager::StopAutoscroll", mTreeManager, + &IAPZCTreeManager::StopAutoscroll, aGuid)); return IPC_OK(); } @@ -172,7 +256,9 @@ mozilla::ipc::IPCResult APZCTreeManagerParent::RecvStopAutoscroll( mozilla::ipc::IPCResult APZCTreeManagerParent::RecvSetLongTapEnabled( const bool& aLongTapEnabled) { mUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(mWrRootId), +#endif NewRunnableMethod( "layers::IAPZCTreeManager::SetLongTapEnabled", mTreeManager, &IAPZCTreeManager::SetLongTapEnabled, aLongTapEnabled)); @@ -180,7 +266,9 @@ mozilla::ipc::IPCResult APZCTreeManagerParent::RecvSetLongTapEnabled( return IPC_OK(); } -bool APZCTreeManagerParent::IsGuidValid(const SLGuidAndRenderRoot& aGuid) { +bool APZCTreeManagerParent::IsGuidValid( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid) { if (aGuid.mScrollableLayerGuid.mLayersId != mWrRootId.mLayersId) { NS_ERROR("Unexpected layers id"); return false; @@ -194,6 +282,13 @@ bool APZCTreeManagerParent::IsGuidValid(const SLGuidAndRenderRoot& aGuid) { return false; } } +#else + const ScrollableLayerGuid& aGuid) { + if (aGuid.mLayersId != mLayersId) { + NS_ERROR("Unexpected layers id"); + return false; + } +#endif return true; } diff --git a/gfx/layers/ipc/APZCTreeManagerParent.h b/gfx/layers/ipc/APZCTreeManagerParent.h index aa6812c507..745dd24531 100644 --- a/gfx/layers/ipc/APZCTreeManagerParent.h +++ b/gfx/layers/ipc/APZCTreeManagerParent.h @@ -15,12 +15,22 @@ class APZUpdater; class APZCTreeManagerParent : public PAPZCTreeManagerParent { public: - APZCTreeManagerParent(WRRootId aWrRootId, - RefPtr aAPZCTreeManager, - RefPtr mAPZUpdater); + APZCTreeManagerParent( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId aWrRootId, +#else + LayersId aLayersId, +#endif + RefPtr aAPZCTreeManager, RefPtr mAPZUpdater); virtual ~APZCTreeManagerParent(); - LayersId GetLayersId() const { return mWrRootId.mLayersId; } + LayersId GetLayersId() const { +#ifdef MOZ_BUILD_WEBRENDER + return mWrRootId.mLayersId; +#else + return mLayersId; +#endif + } /** * Called when the layer tree that this protocol is connected to @@ -31,18 +41,32 @@ class APZCTreeManagerParent : public PAPZCTreeManagerParent { mozilla::ipc::IPCResult RecvSetKeyboardMap(const KeyboardMap& aKeyboardMap); - mozilla::ipc::IPCResult RecvZoomToRect(const SLGuidAndRenderRoot& aGuid, - const CSSRect& aRect, - const uint32_t& aFlags); + mozilla::ipc::IPCResult RecvZoomToRect( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const CSSRect& aRect, const uint32_t& aFlags); mozilla::ipc::IPCResult RecvContentReceivedInputBlock( const uint64_t& aInputBlockId, const bool& aPreventDefault); mozilla::ipc::IPCResult RecvSetTargetAPZC( - const uint64_t& aInputBlockId, nsTArray&& aTargets); + const uint64_t& aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + nsTArray&& aTargets +#else + nsTArray&& aTargets +#endif + ); mozilla::ipc::IPCResult RecvUpdateZoomConstraints( +#ifdef MOZ_BUILD_WEBRENDER const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif const MaybeZoomConstraints& aConstraints); mozilla::ipc::IPCResult RecvSetDPI(const float& aDpiValue); @@ -51,21 +75,42 @@ class APZCTreeManagerParent : public PAPZCTreeManagerParent { const uint64_t& aInputBlockId, nsTArray&& aValues); mozilla::ipc::IPCResult RecvStartScrollbarDrag( - const SLGuidAndRenderRoot& aGuid, const AsyncDragMetrics& aDragMetrics); +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const AsyncDragMetrics& aDragMetrics); mozilla::ipc::IPCResult RecvStartAutoscroll( - const SLGuidAndRenderRoot& aGuid, const ScreenPoint& aAnchorLocation); - - mozilla::ipc::IPCResult RecvStopAutoscroll(const SLGuidAndRenderRoot& aGuid); +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid, +#else + const ScrollableLayerGuid& aGuid, +#endif + const ScreenPoint& aAnchorLocation); + + mozilla::ipc::IPCResult RecvStopAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif + ); mozilla::ipc::IPCResult RecvSetLongTapEnabled(const bool& aTapGestureEnabled); void ActorDestroy(ActorDestroyReason aWhy) override {} private: +#ifdef MOZ_BUILD_WEBRENDER bool IsGuidValid(const SLGuidAndRenderRoot& aGuid); WRRootId mWrRootId; +#else + bool IsGuidValid(const ScrollableLayerGuid& aGuid); + LayersId mLayersId; +#endif RefPtr mTreeManager; RefPtr mUpdater; }; diff --git a/gfx/layers/ipc/CompositableForwarder.h b/gfx/layers/ipc/CompositableForwarder.h index f81badd7dc..5485b5fcec 100644 --- a/gfx/layers/ipc/CompositableForwarder.h +++ b/gfx/layers/ipc/CompositableForwarder.h @@ -86,8 +86,12 @@ class CompositableForwarder : public KnowsCompositor { * into. */ virtual void RemoveTextureFromCompositable( - CompositableClient* aCompositable, TextureClient* aTexture, - const Maybe& aRenderRoot) = 0; + CompositableClient* aCompositable, TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ) = 0; struct TimedTextureClient { TimedTextureClient() @@ -109,8 +113,12 @@ class CompositableForwarder : public KnowsCompositor { * into. */ virtual void UseTextures(CompositableClient* aCompositable, - const nsTArray& aTextures, - const Maybe& aRenderRoot) = 0; + const nsTArray& aTextures +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ) = 0; virtual void UseComponentAlphaTextures(CompositableClient* aCompositable, TextureClient* aClientOnBlack, TextureClient* aClientOnWhite) = 0; diff --git a/gfx/layers/ipc/CompositableTransactionParent.cpp b/gfx/layers/ipc/CompositableTransactionParent.cpp index 11376d05ef..01cd17e7dd 100644 --- a/gfx/layers/ipc/CompositableTransactionParent.cpp +++ b/gfx/layers/ipc/CompositableTransactionParent.cpp @@ -253,8 +253,12 @@ void CompositableParentManager::DestroyActor(const OpDestroy& aOp) { } RefPtr CompositableParentManager::AddCompositable( - const CompositableHandle& aHandle, const TextureInfo& aInfo, - bool aUseWebRender) { + const CompositableHandle& aHandle, const TextureInfo& aInfo +#ifdef MOZ_BUILD_WEBRENDER + , + bool aUseWebRender +#endif +) { if (mCompositables.find(aHandle.Value()) != mCompositables.end()) { NS_ERROR("Client should not allocate duplicate handles"); return nullptr; @@ -264,8 +268,12 @@ RefPtr CompositableParentManager::AddCompositable( return nullptr; } - RefPtr host = - CompositableHost::Create(aInfo, aUseWebRender); + RefPtr host = CompositableHost::Create(aInfo +#ifdef MOZ_BUILD_WEBRENDER + , + aUseWebRender +#endif + ); if (!host) { return nullptr; } @@ -275,12 +283,18 @@ RefPtr CompositableParentManager::AddCompositable( } RefPtr CompositableParentManager::FindCompositable( - const CompositableHandle& aHandle, bool aAllowDisablingWebRender) { + const CompositableHandle& aHandle +#ifdef MOZ_BUILD_WEBRENDER + , + bool aAllowDisablingWebRender +#endif +) { auto iter = mCompositables.find(aHandle.Value()); if (iter == mCompositables.end()) { return nullptr; } +#ifdef MOZ_BUILD_WEBRENDER RefPtr host = iter->second; if (!aAllowDisablingWebRender) { return host; @@ -302,6 +316,9 @@ RefPtr CompositableParentManager::FindCompositable( mCompositables[aHandle.Value()] = newHost; return newHost; +#else + return iter->second; +#endif } void CompositableParentManager::ReleaseCompositable( diff --git a/gfx/layers/ipc/CompositableTransactionParent.h b/gfx/layers/ipc/CompositableTransactionParent.h index 325199c7a6..5f306669a8 100644 --- a/gfx/layers/ipc/CompositableTransactionParent.h +++ b/gfx/layers/ipc/CompositableTransactionParent.h @@ -34,10 +34,17 @@ class CompositableParentManager : public HostIPCAllocator { uint64_t GetFwdTransactionId() { return mFwdTransactionId; } RefPtr AddCompositable(const CompositableHandle& aHandle, - const TextureInfo& aInfo, - bool aUseWebRender); + const TextureInfo& aInfo +#ifdef MOZ_BUILD_WEBRENDER + , bool aUseWebRender +#endif + ); RefPtr FindCompositable( - const CompositableHandle& aHandle, bool aAllowDisablingWebRender = false); + const CompositableHandle& aHandle +#ifdef MOZ_BUILD_WEBRENDER + , bool aAllowDisablingWebRender = false +#endif + ); protected: /** diff --git a/gfx/layers/ipc/CompositorBridgeChild.cpp b/gfx/layers/ipc/CompositorBridgeChild.cpp index 55c3774a22..4640b70a04 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.cpp +++ b/gfx/layers/ipc/CompositorBridgeChild.cpp @@ -22,7 +22,9 @@ #include "mozilla/layers/PTextureChild.h" #include "mozilla/layers/TextureClient.h" // for TextureClient #include "mozilla/layers/TextureClientPool.h" // for TextureClientPool -#include "mozilla/layers/WebRenderBridgeChild.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderBridgeChild.h" +#endif #include "mozilla/layers/SyncObject.h" // for SyncObjectClient #include "mozilla/gfx/gfxVars.h" #include "mozilla/gfx/GPUProcessManager.h" @@ -163,6 +165,7 @@ void CompositorBridgeChild::Destroy() { layers->Destroy(); } +#ifdef MOZ_BUILD_WEBRENDER AutoTArray wrBridges; ManagedPWebRenderBridgeChild(wrBridges); for (int i = wrBridges.Length() - 1; i >= 0; --i) { @@ -170,6 +173,7 @@ void CompositorBridgeChild::Destroy() { static_cast(wrBridges[i]); wrBridge->Destroy(/* aIsSync */ false); } +#endif AutoTArray apzChildren; ManagedPAPZChild(apzChildren); @@ -783,8 +787,12 @@ bool CompositorBridgeChild::SendAllPluginsCaptured() { PTextureChild* CompositorBridgeChild::AllocPTextureChild( const SurfaceDescriptor&, const ReadLockDescriptor&, const LayersBackend&, - const TextureFlags&, const LayersId&, const uint64_t& aSerial, - const wr::MaybeExternalImageId& aExternalImageId) { + const TextureFlags&, const LayersId&, const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif +) { return TextureClient::CreateIPDLActor(); } @@ -911,19 +919,32 @@ CompositorBridgeChild::GetTileLockAllocator() { PTextureChild* CompositorBridgeChild::CreateTexture( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, LayersBackend aLayersBackend, TextureFlags aFlags, uint64_t aSerial, - wr::MaybeExternalImageId& aExternalImageId, nsIEventTarget* aTarget) { +#ifdef MOZ_BUILD_WEBRENDER + wr::MaybeExternalImageId& aExternalImageId, +#endif + nsIEventTarget* aTarget) { PTextureChild* textureChild = AllocPTextureChild(aSharedData, aReadLock, aLayersBackend, aFlags, - LayersId{0} /* FIXME */, aSerial, aExternalImageId); + LayersId{0} /* FIXME */, aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + aExternalImageId +#endif + ); // Do the DOM labeling. if (aTarget) { SetEventTargetForActor(textureChild, aTarget); } - return SendPTextureConstructor( - textureChild, aSharedData, aReadLock, aLayersBackend, aFlags, - LayersId{0} /* FIXME? */, aSerial, aExternalImageId); + return SendPTextureConstructor(textureChild, aSharedData, aReadLock, + aLayersBackend, aFlags, + LayersId{0} /* FIXME? */, aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + aExternalImageId +#endif + ); } bool CompositorBridgeChild::AllocUnsafeShmem( @@ -1001,6 +1022,7 @@ bool CompositorBridgeChild::DeallocPAPZCTreeManagerChild( void CompositorBridgeChild::WillEndTransaction() { ResetShmemCounter(); } +#ifdef MOZ_BUILD_WEBRENDER PWebRenderBridgeChild* CompositorBridgeChild::AllocPWebRenderBridgeChild( const wr::PipelineId& aPipelineId, const LayoutDeviceIntSize&) { WebRenderBridgeChild* child = new WebRenderBridgeChild(aPipelineId); @@ -1015,6 +1037,7 @@ bool CompositorBridgeChild::DeallocPWebRenderBridgeChild( child->ReleaseIPDLReference(); return true; } +#endif void CompositorBridgeChild::ClearSharedFrameMetricsData(LayersId aLayersId) { for (auto iter = mFrameMetricsTable.Iter(); !iter.Done(); iter.Next()) { @@ -1035,6 +1058,7 @@ uint64_t CompositorBridgeChild::GetNextResourceId() { return id; } +#ifdef MOZ_BUILD_WEBRENDER wr::MaybeExternalImageId CompositorBridgeChild::GetNextExternalImageId() { return Some(wr::ToExternalImageId(GetNextResourceId())); } @@ -1042,6 +1066,7 @@ wr::MaybeExternalImageId CompositorBridgeChild::GetNextExternalImageId() { wr::PipelineId CompositorBridgeChild::GetNextPipelineId() { return wr::AsPipelineId(GetNextResourceId()); } +#endif void CompositorBridgeChild::FlushAsyncPaints() { MOZ_ASSERT(NS_IsMainThread()); diff --git a/gfx/layers/ipc/CompositorBridgeChild.h b/gfx/layers/ipc/CompositorBridgeChild.h index a0dafdae10..02853443d7 100644 --- a/gfx/layers/ipc/CompositorBridgeChild.h +++ b/gfx/layers/ipc/CompositorBridgeChild.h @@ -13,7 +13,9 @@ #include "mozilla/layers/PCompositorBridgeChild.h" #include "mozilla/layers/TextureForwarder.h" // for TextureForwarder #include "mozilla/layers/PaintThread.h" // for PaintThread -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "nsClassHashtable.h" // for nsClassHashtable #include "nsCOMPtr.h" // for nsCOMPtr #include "nsHashKeys.h" // for nsUint64HashKey @@ -106,8 +108,12 @@ class CompositorBridgeChild final : public PCompositorBridgeChild, PTextureChild* AllocPTextureChild( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, const LayersBackend& aLayersBackend, const TextureFlags& aFlags, - const LayersId& aId, const uint64_t& aSerial, - const wr::MaybeExternalImageId& aExternalImageId); + const LayersId& aId, const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif + ); bool DeallocPTextureChild(PTextureChild* actor); @@ -117,7 +123,9 @@ class CompositorBridgeChild final : public PCompositorBridgeChild, const ReadLockDescriptor& aReadLock, LayersBackend aLayersBackend, TextureFlags aFlags, uint64_t aSerial, +#ifdef MOZ_BUILD_WEBRENDER wr::MaybeExternalImageId& aExternalImageId, +#endif nsIEventTarget* aTarget) override; /** @@ -210,6 +218,7 @@ class CompositorBridgeChild final : public PCompositorBridgeChild, void WillEndTransaction(); +#ifdef MOZ_BUILD_WEBRENDER PWebRenderBridgeChild* AllocPWebRenderBridgeChild( const wr::PipelineId& aPipelineId, const LayoutDeviceIntSize&); bool DeallocPWebRenderBridgeChild(PWebRenderBridgeChild* aActor); @@ -217,6 +226,7 @@ class CompositorBridgeChild final : public PCompositorBridgeChild, wr::MaybeExternalImageId GetNextExternalImageId() override; wr::PipelineId GetNextPipelineId(); +#endif // Must only be called from the main thread. Ensures that any paints from // previous frames have been flushed. The main thread blocks until the diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index b116233ab9..a8ed25d5cc 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -29,12 +29,12 @@ #include "mozilla/StaticPrefs_layers.h" #include "mozilla/StaticPrefs_layout.h" #include "mozilla/dom/BrowserParent.h" -#include "mozilla/gfx/2D.h" // for DrawTarget -#include "mozilla/gfx/Point.h" // for IntSize -#include "mozilla/gfx/Rect.h" // for IntSize -#include "mozilla/gfx/gfxVars.h" // for gfxVars +#include "mozilla/gfx/2D.h" // for DrawTarget +#include "mozilla/gfx/Point.h" // for IntSize +#include "mozilla/gfx/Rect.h" // for IntSize +#include "mozilla/gfx/gfxVars.h" // for gfxVars #ifdef MOZ_VR -# include "VRManager.h" // for VRManager +# include "VRManager.h" // for VRManager #endif #include "mozilla/ipc/Transport.h" // for Transport #include "mozilla/gfx/gfxVars.h" @@ -62,9 +62,11 @@ #include "mozilla/layers/LayersTypes.h" #include "mozilla/layers/PLayerTransactionParent.h" #include "mozilla/layers/RemoteContentController.h" -#include "mozilla/layers/WebRenderBridgeParent.h" -#include "mozilla/layers/AsyncImagePipelineManager.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderBridgeParent.h" +# include "mozilla/layers/AsyncImagePipelineManager.h" +# include "mozilla/webrender/WebRenderAPI.h" +#endif #include "mozilla/media/MediaSystemResourceService.h" // for MediaSystemResourceService #include "mozilla/mozalloc.h" // for operator new, etc #include "mozilla/Telemetry.h" @@ -118,8 +120,6 @@ using namespace mozilla::gfx; using base::ProcessId; using base::Thread; -using mozilla::Telemetry::LABELS_CONTENT_FRAME_TIME_REASON; - /// Equivalent to asserting CompositorThreadHolder::IsInCompositorThread with /// the addition that it doesn't assert if the compositor thread holder is /// already gone during late shutdown. @@ -375,8 +375,13 @@ void CompositorBridgeParent::Initialize() { MOZ_ASSERT(!mApzSampler); MOZ_ASSERT(!mApzUpdater); mApzcTreeManager = new APZCTreeManager(mRootLayerTreeID); +#ifdef MOZ_BUILD_WEBRENDER mApzSampler = new APZSampler(mApzcTreeManager, mOptions.UseWebRender()); mApzUpdater = new APZUpdater(mApzcTreeManager, mOptions.UseWebRender()); +#else + mApzSampler = new APZSampler(mApzcTreeManager); + mApzUpdater = new APZUpdater(mApzcTreeManager); +#endif } mPaused = mOptions.InitiallyPaused(); @@ -396,9 +401,10 @@ void CompositorBridgeParent::Initialize() { LayerScope::SetPixelScale(mScale.scale); - if (!mOptions.UseWebRender()) { +#ifdef MOZ_BUILD_WEBRENDER + if (!mOptions.UseWebRender()) +#endif mCompositorScheduler = new CompositorVsyncScheduler(this, mWidget); - } } LayersId CompositorBridgeParent::RootLayerTreeId() { @@ -418,11 +424,12 @@ CompositorBridgeParent::~CompositorBridgeParent() { } void CompositorBridgeParent::ForceIsFirstPaint() { - if (mWrBridge) { +#ifdef MOZ_BUILD_WEBRENDER + if (mWrBridge) mWrBridge->ForceIsFirstPaint(); - } else { + else +#endif mCompositionManager->ForceIsFirstPaint(); - } } void CompositorBridgeParent::StopAndClearResources() { @@ -439,9 +446,15 @@ void CompositorBridgeParent::StopAndClearResources() { MOZ_ASSERT((mApzSampler != nullptr) == (mApzcTreeManager != nullptr)); MOZ_ASSERT((mApzUpdater != nullptr) == (mApzcTreeManager != nullptr)); if (mApzUpdater) { +#ifdef MOZ_BUILD_WEBRENDER mApzSampler->Destroy(); +#endif mApzSampler = nullptr; - mApzUpdater->ClearTree(mRootLayerTreeID); + mApzUpdater->ClearTree( +#ifdef MOZ_BUILD_WEBRENDER + mRootLayerTreeID +#endif + ); mApzUpdater = nullptr; mApzcTreeManager = nullptr; } @@ -459,6 +472,7 @@ void CompositorBridgeParent::StopAndClearResources() { mCompositionManager = nullptr; } +#ifdef MOZ_BUILD_WEBRENDER if (mWrBridge) { // Ensure we are not holding the sIndirectLayerTreesLock when destroying // the WebRenderBridgeParent instances because it may block on WR. @@ -497,6 +511,7 @@ void CompositorBridgeParent::StopAndClearResources() { mAsyncImageManager = nullptr; } } +#endif if (mCompositor) { mCompositor->DetachWidget(); @@ -567,10 +582,12 @@ CompositorBridgeParent::RecvWaitOnTransactionProcessed() { } mozilla::ipc::IPCResult CompositorBridgeParent::RecvFlushRendering() { +#ifdef MOZ_BUILD_WEBRENDER if (mWrBridge) { mWrBridge->FlushRendering(); return IPC_OK(); } +#endif if (mCompositorScheduler->NeedsComposite()) { CancelCurrentCompositeTask(); @@ -579,6 +596,7 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvFlushRendering() { return IPC_OK(); } +#ifdef MOZ_BUILD_WEBRENDER mozilla::ipc::IPCResult CompositorBridgeParent::RecvFlushRenderingAsync() { if (mWrBridge) { mWrBridge->FlushRendering(false); @@ -587,11 +605,14 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvFlushRenderingAsync() { return RecvFlushRendering(); } +#endif mozilla::ipc::IPCResult CompositorBridgeParent::RecvForcePresent() { +#ifdef MOZ_BUILD_WEBRENDER if (mWrBridge) { mWrBridge->ScheduleForcedGenerateFrame(); } +#endif // During the shutdown sequence mLayerManager may be null if (mLayerManager) { mLayerManager->ForcePresent(); @@ -617,8 +638,10 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvStartFrameTimeRecording( const int32_t& aBufferSize, uint32_t* aOutStartIndex) { if (mLayerManager) { *aOutStartIndex = mLayerManager->StartFrameTimeRecording(aBufferSize); +#ifdef MOZ_BUILD_WEBRENDER } else if (mWrBridge) { *aOutStartIndex = mWrBridge->StartFrameTimeRecording(aBufferSize); +#endif } else { *aOutStartIndex = 0; } @@ -629,8 +652,10 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvStopFrameTimeRecording( const uint32_t& aStartIndex, nsTArray* intervals) { if (mLayerManager) { mLayerManager->StopFrameTimeRecording(aStartIndex, *intervals); +#ifdef MOZ_BUILD_WEBRENDER } else if (mWrBridge) { mWrBridge->StopFrameTimeRecording(aStartIndex, *intervals); +#endif } return IPC_OK(); } @@ -660,11 +685,23 @@ void CompositorBridgeParent::ActorDestroy(ActorDestroyReason why) { } void CompositorBridgeParent::ScheduleRenderOnCompositorThread( - const wr::RenderRootSet& aRenderRoots) { +#ifdef MOZ_BUILD_WEBRENDER + const wr::RenderRootSet& aRenderRoots +#endif +) { MOZ_ASSERT(CompositorLoop()); - CompositorLoop()->PostTask(NewRunnableMethod( - "layers::CompositorBridgeParent::ScheduleComposition", this, - &CompositorBridgeParent::ScheduleComposition, aRenderRoots)); + CompositorLoop()->PostTask( + NewRunnableMethod +#ifdef MOZ_BUILD_WEBRENDER + +#endif + ("layers::CompositorBridgeParent::ScheduleComposition", this, + &CompositorBridgeParent::ScheduleComposition +#ifdef MOZ_BUILD_WEBRENDER + , + aRenderRoots +#endif + )); } void CompositorBridgeParent::InvalidateOnCompositorThread() { @@ -687,11 +724,13 @@ void CompositorBridgeParent::PauseComposition() { if (mCompositor) { mCompositor->Pause(); DidComposite(VsyncId(), now, now); +#ifdef MOZ_BUILD_WEBRENDER } else if (mWrBridge) { mWrBridge->Pause(); NotifyPipelineRendered(mWrBridge->PipelineId(), mWrBridge->GetCurrentEpoch(), VsyncId(), now, now, now); +#endif } } @@ -707,7 +746,10 @@ void CompositorBridgeParent::ResumeComposition() { Monitor2AutoLock lock(mResumeCompositionMonitor); bool resumed = - mOptions.UseWebRender() ? mWrBridge->Resume() : mCompositor->Resume(); +#ifdef MOZ_BUILD_WEBRENDER + mOptions.UseWebRender() ? mWrBridge->Resume() : +#endif + mCompositor->Resume(); if (!resumed) { #ifdef MOZ_WIDGET_ANDROID // We can't get a surface. This could be because the activity changed @@ -733,7 +775,11 @@ void CompositorBridgeParent::ResumeComposition() { void CompositorBridgeParent::ForceComposition() { // Cancel the orientation changed state to force composition mForceCompositionTask = nullptr; - ScheduleRenderOnCompositorThread(wr::RenderRootSet()); + ScheduleRenderOnCompositorThread( +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRootSet() +#endif + ); } void CompositorBridgeParent::CancelCurrentCompositeTask() { @@ -858,11 +904,15 @@ void CompositorBridgeParent::NotifyShadowTreeTransaction( if (mApzUpdater) { mApzUpdater->UpdateFocusState(mRootLayerTreeID, - WRRootId::NonWebRender(aId), aFocusTarget); +#ifdef MOZ_BUILD_WEBRENDER + WRRootId::NonWebRender(aId), +#else + aId, +#endif + aFocusTarget); if (aHitTestUpdate) { mApzUpdater->UpdateHitTestingTree( - mLayerManager->GetRoot(), aIsFirstPaint, aId, - aPaintSequenceNumber); + mLayerManager->GetRoot(), aIsFirstPaint, aId, aPaintSequenceNumber); } } @@ -874,17 +924,20 @@ void CompositorBridgeParent::NotifyShadowTreeTransaction( } void CompositorBridgeParent::ScheduleComposition( - const wr::RenderRootSet& aRenderRoots) { +#ifdef MOZ_BUILD_WEBRENDER + const wr::RenderRootSet& aRenderRoots +#endif +) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); if (mPaused) { return; } - - if (mWrBridge) { +#ifdef MOZ_BUILD_WEBRENDER + if (mWrBridge) mWrBridge->ScheduleGenerateFrame(aRenderRoots); - } else { + else +#endif mCompositorScheduler->ScheduleComposition(); - } } // Go down the composite layer tree, setting properties to match their @@ -1106,8 +1159,12 @@ PAPZCTreeManagerParent* CompositorBridgeParent::AllocPAPZCTreeManagerParent( MOZ_ASSERT(state.mParent.get() == this); MOZ_ASSERT(!state.mApzcTreeManagerParent); state.mApzcTreeManagerParent = new APZCTreeManagerParent( - WRRootId(mRootLayerTreeID, wr::RenderRoot::Default), mApzcTreeManager, - mApzUpdater); +#ifdef MOZ_BUILD_WEBRENDER + WRRootId(mRootLayerTreeID, wr::RenderRoot::Default), +#else + mRootLayerTreeID, +#endif + mApzcTreeManager, mApzUpdater); return state.mApzcTreeManagerParent; } @@ -1120,13 +1177,23 @@ bool CompositorBridgeParent::DeallocPAPZCTreeManagerParent( void CompositorBridgeParent::AllocateAPZCTreeManagerParent( const Monitor2AutoLock& aProofOfLayerTreeStateLock, - const WRRootId& aWrRootId, LayerTreeState& aState) { +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + LayerTreeState& aState) { MOZ_ASSERT(aState.mParent == this); MOZ_ASSERT(mApzcTreeManager); MOZ_ASSERT(mApzUpdater); MOZ_ASSERT(!aState.mApzcTreeManagerParent); - aState.mApzcTreeManagerParent = - new APZCTreeManagerParent(aWrRootId, mApzcTreeManager, mApzUpdater); + aState.mApzcTreeManagerParent = new APZCTreeManagerParent( +#ifdef MOZ_BUILD_WEBRENDER + aWrRootId, +#else + aLayersId, +#endif + mApzcTreeManager, mApzUpdater); } PAPZParent* CompositorBridgeParent::AllocPAPZParent(const LayersId& aLayersId) { @@ -1178,6 +1245,7 @@ CompositorBridgeParent::GetCompositorBridgeParentFromLayersId( return sIndirectLayerTrees[aLayersId].mParent; } +#ifdef MOZ_BUILD_WEBRENDER /*static*/ RefPtr CompositorBridgeParent::GetCompositorBridgeParentFromWindowId( @@ -1201,6 +1269,7 @@ CompositorBridgeParent::GetCompositorBridgeParentFromWindowId( } return nullptr; } +#endif bool CompositorBridgeParent::CanComposite() { return mLayerManager && mLayerManager->GetRoot() && !mPaused; @@ -1245,14 +1314,18 @@ void CompositorBridgeParent::ShadowLayersUpdated( if (mApzUpdater && !aInfo.isRepeatTransaction()) { mApzUpdater->UpdateFocusState(mRootLayerTreeID, +#ifdef MOZ_BUILD_WEBRENDER WRRootId::NonWebRender(mRootLayerTreeID), +#else + mRootLayerTreeID, +#endif aInfo.focusTarget()); if (aHitTestUpdate) { AutoResolveRefLayers resolve(mCompositionManager); - mApzUpdater->UpdateHitTestingTree(root, - aInfo.isFirstPaint(), mRootLayerTreeID, + mApzUpdater->UpdateHitTestingTree(root, aInfo.isFirstPaint(), + mRootLayerTreeID, aInfo.paintSequenceNumber()); } } @@ -1299,10 +1372,12 @@ bool CompositorBridgeParent::SetTestSampleTime(const LayersId& aId, mApzcTreeManager->SetTestSampleTime(mTestTime); } +#ifdef MOZ_BUILD_WEBRENDER if (mWrBridge) { mWrBridge->FlushRendering(); return true; } +#endif bool testComposite = mCompositionManager && mCompositorScheduler->NeedsComposite(); @@ -1368,60 +1443,123 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvGetFrameUniformity( } void CompositorBridgeParent::SetTestAsyncScrollOffset( - const WRRootId& aWrRootId, const ScrollableLayerGuid::ViewID& aScrollId, - const CSSPoint& aPoint) { +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, const CSSPoint& aPoint) { if (mApzUpdater) { +#ifdef MOZ_BUILD_WEBRENDER MOZ_ASSERT(aWrRootId.IsValid()); mApzUpdater->SetTestAsyncScrollOffset(aWrRootId, aScrollId, aPoint); +#else + mApzUpdater->SetTestAsyncScrollOffset(aLayersId, aScrollId, aPoint); +#endif } } void CompositorBridgeParent::SetTestAsyncZoom( - const WRRootId& aWrRootId, const ScrollableLayerGuid::ViewID& aScrollId, +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, const LayerToParentLayerScale& aZoom) { if (mApzUpdater) { +#ifdef MOZ_BUILD_WEBRENDER MOZ_ASSERT(aWrRootId.IsValid()); mApzUpdater->SetTestAsyncZoom(aWrRootId, aScrollId, aZoom); +#else + mApzUpdater->SetTestAsyncZoom(aLayersId, aScrollId, aZoom); +#endif } } -void CompositorBridgeParent::FlushApzRepaints(const WRRootId& aWrRootId) { +void CompositorBridgeParent::FlushApzRepaints( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId +#else + const LayersId& aLayersId +#endif +) { MOZ_ASSERT(mApzUpdater); +#ifdef MOZ_BUILD_WEBRENDER MOZ_ASSERT(aWrRootId.IsValid()); +#endif mApzUpdater->RunOnControllerThread( +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector(aWrRootId), - NS_NewRunnableFunction( - "layers::CompositorBridgeParent::FlushApzRepaints", - [=]() { APZCTreeManager::FlushApzRepaints(aWrRootId.mLayersId); })); +#endif + NS_NewRunnableFunction("layers::CompositorBridgeParent::FlushApzRepaints", + [=]() { + APZCTreeManager::FlushApzRepaints( +#ifdef MOZ_BUILD_WEBRENDER + aWrRootId.mLayersId +#else + aLayersId +#endif + ); + })); } -void CompositorBridgeParent::GetAPZTestData(const WRRootId& aWrRootId, - APZTestData* aOutData) { +void CompositorBridgeParent::GetAPZTestData( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + APZTestData* aOutData) { if (mApzUpdater) { +#ifdef MOZ_BUILD_WEBRENDER MOZ_ASSERT(aWrRootId.IsValid()); mApzUpdater->GetAPZTestData(aWrRootId, aOutData); +#else + mApzUpdater->GetAPZTestData(aLayersId, aOutData); +#endif } } void CompositorBridgeParent::SetConfirmedTargetAPZC( const LayersId& aLayersId, const uint64_t& aInputBlockId, - const nsTArray& aTargets) { +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif +) { if (!mApzcTreeManager || !mApzUpdater) { return; } // Need to specifically bind this since it's overloaded. - void (APZCTreeManager::*setTargetApzcFunc)( - uint64_t, const nsTArray&) = + void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray< +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot +#else + ScrollableLayerGuid +#endif + >&) = &APZCTreeManager::SetTargetAPZC; - RefPtr task = NewRunnableMethod< - uint64_t, StoreCopyPassByConstLRef>>( - "layers::CompositorBridgeParent::SetConfirmedTargetAPZC", - mApzcTreeManager.get(), setTargetApzcFunc, aInputBlockId, aTargets); + RefPtr task = + NewRunnableMethod>>( + "layers::CompositorBridgeParent::SetConfirmedTargetAPZC", + mApzcTreeManager.get(), setTargetApzcFunc, aInputBlockId, aTargets); +#ifdef MOZ_BUILD_WEBRENDER UpdaterQueueSelector selector(aLayersId); for (size_t i = 0; i < aTargets.Length(); i++) { selector.mRenderRoots += aTargets[i].mRenderRoot; } mApzUpdater->RunOnControllerThread(selector, task.forget()); +#else + mApzUpdater->RunOnControllerThread(task.forget()); +#endif } void CompositorBridgeParent::SetFixedLayerMargins(ScreenIntCoord aTop, @@ -1524,8 +1662,11 @@ RefPtr CompositorBridgeParent::NewCompositor( return nullptr; } - MOZ_ASSERT(!gfxVars::UseWebRender() || - aBackendHints[i] == LayersBackend::LAYERS_BASIC); + MOZ_ASSERT( +#ifdef MOZ_BUILD_WEBRENDER + !gfxVars::UseWebRender() || +#endif + aBackendHints[i] == LayersBackend::LAYERS_BASIC); if (compositor && compositor->Initialize(&failureReason)) { if (failureReason.IsEmpty()) { failureReason = "SUCCESS"; @@ -1703,7 +1844,9 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvAdoptChild( APZCTreeManagerParent* parent; bool scheduleComposition = false; RefPtr cpcp; +#ifdef MOZ_BUILD_WEBRENDER RefPtr childWrBridge; +#endif { // scope lock Monitor2AutoLock lock(*sIndirectLayerTreesLock); @@ -1728,10 +1871,12 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvAdoptChild( // wait composition complete. scheduleComposition = true; } +#ifdef MOZ_BUILD_WEBRENDER if (mWrBridge) { childWrBridge = sIndirectLayerTrees[child].mWrBridge; cpcp = sIndirectLayerTrees[child].mContentCompositorBridgeParent; } +#endif parent = sIndirectLayerTrees[child].mApzcTreeManagerParent; } @@ -1739,6 +1884,7 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvAdoptChild( ScheduleComposition(); } +#ifdef MOZ_BUILD_WEBRENDER if (childWrBridge) { MOZ_ASSERT(mWrBridge); nsTArray> apis; @@ -1753,6 +1899,7 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvAdoptChild( NotifyPipelineRendered(childWrBridge->PipelineId(), newEpoch, VsyncId(), now, now, now); } +#endif if (oldApzUpdater) { // We don't support moving a child from an APZ-enabled compositor to a @@ -1769,11 +1916,17 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvAdoptChild( parent->ChildAdopted(mApzcTreeManager, mApzUpdater); } mApzUpdater->NotifyLayerTreeAdopted( - WRRootId(child, gfxUtils::GetContentRenderRoot()), oldApzUpdater); +#ifdef MOZ_BUILD_WEBRENDER + WRRootId(child, gfxUtils::GetContentRenderRoot()), +#else + child, +#endif + oldApzUpdater); } return IPC_OK(); } +#ifdef MOZ_BUILD_WEBRENDER PWebRenderBridgeParent* CompositorBridgeParent::AllocPWebRenderBridgeParent( const wr::PipelineId& aPipelineId, const LayoutDeviceIntSize& aSize) { MOZ_ASSERT(wr::AsLayersId(aPipelineId) == mRootLayerTreeID); @@ -1782,12 +1935,12 @@ PWebRenderBridgeParent* CompositorBridgeParent::AllocPWebRenderBridgeParent( MOZ_ASSERT(!mCompositorScheduler); MOZ_ASSERT(mWidget); -#ifdef XP_WIN +# ifdef XP_WIN if (mWidget && (DeviceManagerDx::Get()->CanUseDComp() || gfxVars::UseWebRenderFlipSequentialWin())) { mWidget->AsWindows()->EnsureCompositorWindow(); } -#endif +# endif RefPtr widget = mWidget; wr::WrWindowId windowId = wr::NewWindowId(); @@ -1864,6 +2017,10 @@ void CompositorBridgeParent::NotifyMemoryPressure() { } } } +RefPtr CompositorBridgeParent::GetWebRenderBridgeParent() + const { + return mWrBridge; +} void CompositorBridgeParent::AccumulateMemoryReport(wr::MemoryReport* aReport) { if (mWrBridge) { @@ -1875,10 +2032,7 @@ void CompositorBridgeParent::AccumulateMemoryReport(wr::MemoryReport* aReport) { } } -RefPtr CompositorBridgeParent::GetWebRenderBridgeParent() - const { - return mWrBridge; -} +#endif // MOZ_BUILD_WEBRENDER Maybe CompositorBridgeParent::GetTestingTimeStamp() const { return mTestTime; @@ -1901,7 +2055,12 @@ static void EraseLayerState(LayersId aId) { if (apz) { apz->NotifyLayerTreeRemoved( - WRRootId(aId, gfxUtils::GetContentRenderRoot())); +#ifdef MOZ_BUILD_WEBRENDER + WRRootId(aId, gfxUtils::GetContentRenderRoot()) +#else + aId +#endif + ); } } @@ -2056,9 +2215,11 @@ CompositorBridgeParent::LayerTreeState::InProcessSharingController() const { void CompositorBridgeParent::DidComposite(const VsyncId& aId, TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd) { +#ifdef MOZ_BUILD_WEBRENDER if (mWrBridge) { MOZ_ASSERT(false); // This should never get called for a WR compositor } else { +#endif NotifyDidComposite(mPendingTransaction, aId, aCompositeStart, aCompositeEnd); #if defined(ENABLE_FRAME_LATENCY_LOG) @@ -2084,9 +2245,12 @@ void CompositorBridgeParent::DidComposite(const VsyncId& aId, mFwdTime = TimeStamp(); #endif mPendingTransaction = TransactionId{0}; +#ifdef MOZ_BUILD_WEBRENDER } +#endif } +#ifdef MOZ_BUILD_WEBRENDER void CompositorBridgeParent::NotifyDidSceneBuild( const nsTArray& aRenderRoots, RefPtr aInfo) { @@ -2158,13 +2322,16 @@ RefPtr CompositorBridgeParent::GetAsyncImagePipelineManager() const { return mAsyncImageManager; } +#endif // MOZ_BUILD_WEBRENDER void CompositorBridgeParent::NotifyDidComposite(TransactionId aTransactionId, VsyncId aId, TimeStamp& aCompositeStart, TimeStamp& aCompositeEnd) { +#ifdef MOZ_BUILD_WEBRENDER MOZ_ASSERT( !mWrBridge); // We should be going through NotifyPipelineRendered instead +#endif Unused << SendDidComposite(LayersId{0}, aTransactionId, aCompositeStart, aCompositeEnd); @@ -2285,11 +2452,19 @@ CompositorBridgeParent::GetGeckoContentControllerForRoot( PTextureParent* CompositorBridgeParent::AllocPTextureParent( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, const LayersBackend& aLayersBackend, const TextureFlags& aFlags, - const LayersId& aId, const uint64_t& aSerial, - const wr::MaybeExternalImageId& aExternalImageId) { + const LayersId& aId, const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif +) { return TextureHost::CreateIPDLActor(this, aSharedData, aReadLock, - aLayersBackend, aFlags, aSerial, - aExternalImageId); + aLayersBackend, aFlags, aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + aExternalImageId +#endif + ); } bool CompositorBridgeParent::DeallocPTextureParent(PTextureParent* actor) { @@ -2300,12 +2475,14 @@ bool CompositorBridgeParent::IsSameProcess() const { return OtherPid() == base::GetCurrentProcId(); } +#ifdef MOZ_BUILD_WEBRENDER void CompositorBridgeParent::NotifyWebRenderContextPurge() { MOZ_ASSERT(CompositorLoop() == MessageLoop::current()); RefPtr api = mWrBridge->GetWebRenderAPI(wr::RenderRoot::Default); api->ClearAllCaches(); } +#endif #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) //#define PLUGINS_LOG(...) printf_stderr("CP [%s]: ", __FUNCTION__); @@ -2490,12 +2667,19 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvAllPluginsCaptured() { #endif } -int32_t RecordContentFrameTime( - const VsyncId& aTxnId, const TimeStamp& aVsyncStart, - const TimeStamp& aTxnStart, const VsyncId& aCompositeId, - const TimeStamp& aCompositeEnd, const TimeDuration& aFullPaintTime, - const TimeDuration& aVsyncRate, bool aContainsSVGGroup, - bool aRecordUploadStats, wr::RendererStats* aStats /* = nullptr */) { +int32_t RecordContentFrameTime(const VsyncId& aTxnId, + const TimeStamp& aVsyncStart, + const TimeStamp& aTxnStart, + const VsyncId& aCompositeId, + const TimeStamp& aCompositeEnd, + const TimeDuration& aFullPaintTime, + const TimeDuration& aVsyncRate, + bool aContainsSVGGroup, bool aRecordUploadStats +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RendererStats* aStats /* = nullptr */ +#endif +) { double latencyMs = (aCompositeEnd - aTxnStart).ToMilliseconds(); double latencyNorm = latencyMs / aVsyncRate.ToMilliseconds(); int32_t fracLatencyNorm = lround(latencyNorm * 100.0); @@ -2521,100 +2705,11 @@ int32_t RecordContentFrameTime( } #endif - Telemetry::Accumulate(Telemetry::CONTENT_FRAME_TIME, fracLatencyNorm); - if (!(aTxnId == VsyncId()) && aVsyncStart) { latencyMs = (aCompositeEnd - aVsyncStart).ToMilliseconds(); latencyNorm = latencyMs / aVsyncRate.ToMilliseconds(); fracLatencyNorm = lround(latencyNorm * 100.0); - int32_t result = fracLatencyNorm; - Telemetry::Accumulate(Telemetry::CONTENT_FRAME_TIME_VSYNC, fracLatencyNorm); - - if (aContainsSVGGroup) { - Telemetry::Accumulate(Telemetry::CONTENT_FRAME_TIME_WITH_SVG, - fracLatencyNorm); - } - - // Record CONTENT_FRAME_TIME_REASON. - // - // Note that deseralizing a layers update (RecvUpdate) can delay the receipt - // of the composite vsync message - // (CompositorBridgeParent::CompositeToTarget), since they're using the same - // thread. This can mean that compositing might start significantly late, - // but this code will still detect it as having successfully started on the - // right vsync (which is somewhat correct). We'd now have reduced time left - // in the vsync interval to finish compositing, so the chances of a missed - // frame increases. This is effectively including the RecvUpdate work as - // part of the 'compositing' phase for this metric, but it isn't included in - // COMPOSITE_TIME, and *is* included in CONTENT_FULL_PAINT_TIME. - // - // Also of note is that when the root WebRenderBridgeParent decides to - // skip a composite (due to the Renderer being busy), that won't notify - // child WebRenderBridgeParents. That failure will show up as the - // composite starting late (since it did), but it's really a fault of a - // slow composite on the previous frame, not a slow - // CONTENT_FULL_PAINT_TIME. It would be nice to have a separate bucket for - // this category (scene was ready on the next vsync, but we chose not to - // composite), but I can't find a way to locate the right child - // WebRenderBridgeParents from the root. WebRender notifies us of the - // child pipelines contained within a render, after it finishes, but I - // can't see how to query what child pipeline would have been rendered, - // when we choose to not do it. - if (fracLatencyNorm < 200) { - // Success - Telemetry::AccumulateCategorical( - LABELS_CONTENT_FRAME_TIME_REASON::OnTime); - } else { - if (aCompositeId == VsyncId()) { - // aCompositeId is 0, possibly something got trigged from - // outside vsync? - Telemetry::AccumulateCategorical( - LABELS_CONTENT_FRAME_TIME_REASON::NoVsyncNoId); - } else if (aTxnId >= aCompositeId) { - // Vsync ids are nonsensical, maybe we're trying to catch up? - Telemetry::AccumulateCategorical( - LABELS_CONTENT_FRAME_TIME_REASON::NoVsync); - } else if (aCompositeId - aTxnId > 1) { - // Composite started late (and maybe took too long as well) - if (aFullPaintTime >= TimeDuration::FromMilliseconds(20)) { - Telemetry::AccumulateCategorical( - LABELS_CONTENT_FRAME_TIME_REASON::MissedCompositeLong); - } else if (aFullPaintTime >= TimeDuration::FromMilliseconds(10)) { - Telemetry::AccumulateCategorical( - LABELS_CONTENT_FRAME_TIME_REASON::MissedCompositeMid); - } else if (aFullPaintTime >= TimeDuration::FromMilliseconds(5)) { - Telemetry::AccumulateCategorical( - LABELS_CONTENT_FRAME_TIME_REASON::MissedCompositeLow); - } else { - Telemetry::AccumulateCategorical( - LABELS_CONTENT_FRAME_TIME_REASON::MissedComposite); - } - } else { - // Composite started on time, but must have taken too long. - Telemetry::AccumulateCategorical( - LABELS_CONTENT_FRAME_TIME_REASON::SlowComposite); - } - } - - if (aRecordUploadStats) { - if (aStats) { - latencyMs -= (double(aStats->resource_upload_time) / 1000000.0); - latencyNorm = latencyMs / aVsyncRate.ToMilliseconds(); - fracLatencyNorm = lround(latencyNorm * 100.0); - } - Telemetry::Accumulate( - Telemetry::CONTENT_FRAME_TIME_WITHOUT_RESOURCE_UPLOAD, - fracLatencyNorm); - - if (aStats) { - latencyMs -= (double(aStats->gpu_cache_upload_time) / 1000000.0); - latencyNorm = latencyMs / aVsyncRate.ToMilliseconds(); - fracLatencyNorm = lround(latencyNorm * 100.0); - } - Telemetry::Accumulate(Telemetry::CONTENT_FRAME_TIME_WITHOUT_UPLOAD, - fracLatencyNorm); - } - return result; + return fracLatencyNorm; } return 0; @@ -2630,9 +2725,11 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvBeginRecording( if (mLayerManager) { mLayerManager->SetCompositionRecorder( MakeUnique(aRecordingStart)); +#ifdef MOZ_BUILD_WEBRENDER } else if (mWrBridge) { mWrBridge->SetCompositionRecorder(MakeUnique( aRecordingStart, mWrBridge->PipelineId())); +#endif } mHaveCompositionRecorder = true; @@ -2650,8 +2747,10 @@ mozilla::ipc::IPCResult CompositorBridgeParent::RecvEndRecording( if (mLayerManager) { mLayerManager->WriteCollectedFrames(); +#ifdef MOZ_BUILD_WEBRENDER } else if (mWrBridge) { mWrBridge->WriteCollectedFrames(); +#endif } mHaveCompositionRecorder = false; diff --git a/gfx/layers/ipc/CompositorBridgeParent.h b/gfx/layers/ipc/CompositorBridgeParent.h index 6fc9dad9df..1c818b31a1 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.h +++ b/gfx/layers/ipc/CompositorBridgeParent.h @@ -18,7 +18,7 @@ #include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 #include "mozilla/Attributes.h" // for override #include "mozilla/Maybe.h" -#include "mozilla/Monitor2.h" // for Monitor +#include "mozilla/Monitor2.h" // for Monitor #include "mozilla/RefPtr.h" // for RefPtr #include "mozilla/TimeStamp.h" // for TimeStamp #include "mozilla/dom/ipc/IdType.h" @@ -35,8 +35,10 @@ #include "mozilla/layers/MetricsSharingController.h" #include "mozilla/layers/PCompositorBridgeParent.h" #include "mozilla/layers/APZTestData.h" -#include "mozilla/webrender/WebRenderTypes.h" -#include "mozilla/webrender/RenderThread.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +# include "mozilla/webrender/RenderThread.h" +#endif #include "mozilla/widget/CompositorWidget.h" #include "nsISupportsImpl.h" #include "ThreadSafeRefcountingWithMainThreadDestruction.h" @@ -70,7 +72,6 @@ class APZCTreeManagerParent; class APZSampler; class APZUpdater; class AsyncCompositionManager; -class AsyncImagePipelineManager; class Compositor; class CompositorAnimationStorage; class CompositorBridgeParent; @@ -83,7 +84,10 @@ class PAPZParent; class ContentCompositorBridgeParent; class CompositorThreadHolder; class InProcessCompositorSession; +#ifdef MOZ_BUILD_WEBRENDER +class AsyncImagePipelineManager; class WebRenderBridgeParent; +#endif struct ScopedLayerTreeRegistration { ScopedLayerTreeRegistration(APZCTreeManager* aApzctm, LayersId aLayersId, @@ -124,17 +128,43 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent, virtual void ApplyAsyncProperties(LayerTransactionParent* aLayerTree, TransformsToSkip aSkip) = 0; virtual void SetTestAsyncScrollOffset( - const WRRootId& aWrRootId, const ScrollableLayerGuid::ViewID& aScrollId, - const CSSPoint& aPoint) = 0; - virtual void SetTestAsyncZoom(const WRRootId& aWrRootId, - const ScrollableLayerGuid::ViewID& aScrollId, - const LayerToParentLayerScale& aZoom) = 0; - virtual void FlushApzRepaints(const WRRootId& aWrRootId) = 0; - virtual void GetAPZTestData(const WRRootId& aWrRootId, - APZTestData* aOutData) {} +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, const CSSPoint& aPoint) = 0; + virtual void SetTestAsyncZoom( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom) = 0; + virtual void FlushApzRepaints( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId +#else + const LayersId& aLayersId +#endif + ) = 0; + virtual void GetAPZTestData( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + APZTestData* aOutData) { + } virtual void SetConfirmedTargetAPZC( const LayersId& aLayersId, const uint64_t& aInputBlockId, - const nsTArray& aTargets) = 0; +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) = 0; virtual void UpdatePaintTime(LayerTransactionParent* aLayerTree, const TimeDuration& aPaintTime) {} virtual void RegisterPayloads(LayerTransactionParent* aLayerTree, @@ -191,8 +221,10 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent, MOZ_CRASH(); } +#ifdef MOZ_BUILD_WEBRENDER virtual void NotifyMemoryPressure() {} virtual void AccumulateMemoryReport(wr::MemoryReport*) {} +#endif protected: virtual ~CompositorBridgeParentBase(); @@ -214,14 +246,21 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent, virtual PTextureParent* AllocPTextureParent( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, const LayersBackend& aBackend, const TextureFlags& aTextureFlags, - const LayersId& id, const uint64_t& aSerial, - const MaybeExternalImageId& aExternalImageId) = 0; + const LayersId& id, const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const MaybeExternalImageId& aExternalImageId +#endif + ) = 0; virtual bool DeallocPTextureParent(PTextureParent* aActor) = 0; +#ifdef MOZ_BUILD_WEBRENDER virtual PWebRenderBridgeParent* AllocPWebRenderBridgeParent( const PipelineId& pipelineId, const LayoutDeviceIntSize& aSize) = 0; virtual bool DeallocPWebRenderBridgeParent( PWebRenderBridgeParent* aActor) = 0; + virtual mozilla::ipc::IPCResult RecvFlushRenderingAsync() = 0; +#endif virtual PCompositorWidgetParent* AllocPCompositorWidgetParent( const CompositorWidgetInitData& aInitData) = 0; @@ -230,7 +269,6 @@ class CompositorBridgeParentBase : public PCompositorBridgeParent, virtual mozilla::ipc::IPCResult RecvRemotePluginsReady() = 0; virtual mozilla::ipc::IPCResult RecvAdoptChild(const LayersId& id) = 0; - virtual mozilla::ipc::IPCResult RecvFlushRenderingAsync() = 0; virtual mozilla::ipc::IPCResult RecvForcePresent() = 0; virtual mozilla::ipc::IPCResult RecvNotifyRegionInvalidated( const nsIntRegion& region) = 0; @@ -323,7 +361,9 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, mozilla::ipc::IPCResult RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot, const gfx::IntRect& aRect) override; mozilla::ipc::IPCResult RecvFlushRendering() override; +#ifdef MOZ_BUILD_WEBRENDER mozilla::ipc::IPCResult RecvFlushRenderingAsync() override; +#endif mozilla::ipc::IPCResult RecvWaitOnTransactionProcessed() override; mozilla::ipc::IPCResult RecvForcePresent() override; @@ -351,8 +391,10 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, BeginRecordingResolver&& aResolve) override; mozilla::ipc::IPCResult RecvEndRecording(bool* aOutSuccess) override; +#ifdef MOZ_BUILD_WEBRENDER void NotifyMemoryPressure() override; void AccumulateMemoryReport(wr::MemoryReport*) override; +#endif void ActorDestroy(ActorDestroyReason why) override; @@ -365,18 +407,44 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, void ApplyAsyncProperties(LayerTransactionParent* aLayerTree, TransformsToSkip aSkip) override; CompositorAnimationStorage* GetAnimationStorage(); - void SetTestAsyncScrollOffset(const WRRootId& aWrRootId, - const ScrollableLayerGuid::ViewID& aScrollId, - const CSSPoint& aPoint) override; - void SetTestAsyncZoom(const WRRootId& aWrRootId, - const ScrollableLayerGuid::ViewID& aScrollId, - const LayerToParentLayerScale& aZoom) override; - void FlushApzRepaints(const WRRootId& aWrRootId) override; - void GetAPZTestData(const WRRootId& aWrRootId, - APZTestData* aOutData) override; - void SetConfirmedTargetAPZC( - const LayersId& aLayersId, const uint64_t& aInputBlockId, - const nsTArray& aTargets) override; + void SetTestAsyncScrollOffset( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, + const CSSPoint& aPoint) override; + void SetTestAsyncZoom( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom) override; + void FlushApzRepaints( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId +#else + const LayersId& aLayersId +#endif + ) override; + void GetAPZTestData( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + APZTestData* aOutData) override; + void SetConfirmedTargetAPZC(const LayersId& aLayersId, + const uint64_t& aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) override; AsyncCompositionManager* GetCompositionManager( LayerTransactionParent* aLayerTree) override { return mCompositionManager; @@ -386,12 +454,17 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, PTextureParent* AllocPTextureParent( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, const LayersBackend& aLayersBackend, const TextureFlags& aFlags, - const LayersId& aId, const uint64_t& aSerial, - const wr::MaybeExternalImageId& aExternalImageId) override; + const LayersId& aId, const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif + ) override; bool DeallocPTextureParent(PTextureParent* actor) override; bool IsSameProcess() const override; +#ifdef MOZ_BUILD_WEBRENDER void NotifyWebRenderContextPurge(); void NotifyPipelineRendered(const wr::PipelineId& aPipelineId, const wr::Epoch& aEpoch, @@ -402,6 +475,7 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, void NotifyDidSceneBuild(const nsTArray& aRenderRoots, RefPtr aInfo); RefPtr GetAsyncImagePipelineManager() const; +#endif PCompositorWidgetParent* AllocPCompositorWidgetParent( const CompositorWidgetInitData& aInitData) override; @@ -427,7 +501,10 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, // Can be called from any thread void ScheduleRenderOnCompositorThread( - const wr::RenderRootSet& aRenderRoots) override; +#ifdef MOZ_BUILD_WEBRENDER + const wr::RenderRootSet& aRenderRoots +#endif + ) override; void SchedulePauseOnCompositorThread(); void InvalidateOnCompositorThread(); /** @@ -438,7 +515,10 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, bool ScheduleResumeOnCompositorThread(int x, int y, int width, int height); void ScheduleComposition( - const wr::RenderRootSet& aRenderRoots = wr::RenderRootSet()); +#ifdef MOZ_BUILD_WEBRENDER + const wr::RenderRootSet& aRenderRoots = wr::RenderRootSet() +#endif + ); void NotifyShadowTreeTransaction(LayersId aId, bool aIsFirstPaint, const FocusTarget& aFocusTarget, @@ -502,7 +582,9 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, APZCTreeManagerParent* mApzcTreeManagerParent; RefPtr mParent; HostLayerManager* mLayerManager; +#ifdef MOZ_BUILD_WEBRENDER RefPtr mWrBridge; +#endif // Pointer to the ContentCompositorBridgeParent. Used by APZCs to share // their FrameMetrics with the corresponding child process that holds // the PCompositorBridgeChild @@ -594,7 +676,12 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, // ContentCompositorBridgeParent. void AllocateAPZCTreeManagerParent( const Monitor2AutoLock& aProofOfLayerTreeStateLock, - const WRRootId& aWrRootId, LayerTreeState& aLayerTreeStateToUpdate); +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + LayerTreeState& aLayerTreeStateToUpdate); PAPZParent* AllocPAPZParent(const LayersId& aLayersId) override; bool DeallocPAPZParent(PAPZParent* aActor) override; @@ -612,17 +699,19 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, return mVsyncRate; } +#ifdef MOZ_BUILD_WEBRENDER PWebRenderBridgeParent* AllocPWebRenderBridgeParent( const wr::PipelineId& aPipelineId, const LayoutDeviceIntSize& aSize) override; bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override; RefPtr GetWebRenderBridgeParent() const; + static RefPtr GetCompositorBridgeParentFromWindowId( + const wr::WindowId& aWindowId); +#endif Maybe GetTestingTimeStamp() const; static CompositorBridgeParent* GetCompositorBridgeParentFromLayersId( const LayersId& aLayersId); - static RefPtr GetCompositorBridgeParentFromWindowId( - const wr::WindowId& aWindowId); /** * This returns a reference to the IAPZCTreeManager "controller subinterface" @@ -636,7 +725,9 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, gfx::IntSize GetEGLSurfaceSize() { return mEGLSurfaceSize; } #endif // defined(MOZ_WIDGET_ANDROID) +#ifdef MOZ_BUILD_WEBRENDER WebRenderBridgeParent* GetWrBridge() { return mWrBridge; } +#endif private: void Initialize(); @@ -732,8 +823,10 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, RefPtr mLayerManager; RefPtr mCompositor; RefPtr mCompositionManager; +#ifdef MOZ_BUILD_WEBRENDER RefPtr mAsyncImageManager; RefPtr mWrBridge; +#endif widget::CompositorWidget* mWidget; Maybe mTestTime; CSSToLayoutDeviceScale mScale; @@ -795,12 +888,19 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase, DISALLOW_EVIL_CONSTRUCTORS(CompositorBridgeParent); }; -int32_t RecordContentFrameTime( - const VsyncId& aTxnId, const TimeStamp& aVsyncStart, - const TimeStamp& aTxnStart, const VsyncId& aCompositeId, - const TimeStamp& aCompositeEnd, const TimeDuration& aFullPaintTime, - const TimeDuration& aVsyncRate, bool aContainsSVGGroup, - bool aRecordUploadStats, wr::RendererStats* aStats = nullptr); +int32_t RecordContentFrameTime(const VsyncId& aTxnId, + const TimeStamp& aVsyncStart, + const TimeStamp& aTxnStart, + const VsyncId& aCompositeId, + const TimeStamp& aCompositeEnd, + const TimeDuration& aFullPaintTime, + const TimeDuration& aVsyncRate, + bool aContainsSVGGroup, bool aRecordUploadStats +#ifdef MOZ_BUILD_WEBRENDER + , + wr::RendererStats* aStats = nullptr +#endif +); } // namespace layers } // namespace mozilla diff --git a/gfx/layers/ipc/CompositorManagerChild.cpp b/gfx/layers/ipc/CompositorManagerChild.cpp index d01ef039b4..9de853121a 100644 --- a/gfx/layers/ipc/CompositorManagerChild.cpp +++ b/gfx/layers/ipc/CompositorManagerChild.cpp @@ -268,6 +268,7 @@ bool CompositorManagerChild::ShouldContinueFromReplyTimeout() { return false; } +#ifdef MOZ_BUILD_WEBRENDER mozilla::ipc::IPCResult CompositorManagerChild::RecvNotifyWebRenderError( const WebRenderError&& aError) { MOZ_ASSERT(XRE_IsParentProcess()); @@ -275,6 +276,7 @@ mozilla::ipc::IPCResult CompositorManagerChild::RecvNotifyWebRenderError( GPUProcessManager::Get()->NotifyWebRenderError(aError); return IPC_OK(); } +#endif } // namespace layers } // namespace mozilla diff --git a/gfx/layers/ipc/CompositorManagerChild.h b/gfx/layers/ipc/CompositorManagerChild.h index 967edf9dcf..99e7b41241 100644 --- a/gfx/layers/ipc/CompositorManagerChild.h +++ b/gfx/layers/ipc/CompositorManagerChild.h @@ -57,6 +57,7 @@ class CompositorManagerChild : public PCompositorManagerChild { uint32_t GetNamespace() const { return mNamespace; } +#ifdef MOZ_BUILD_WEBRENDER bool OwnsExternalImageId(const wr::ExternalImageId& aId) const { return mNamespace == static_cast(wr::AsUint64(aId) >> 32); } @@ -68,6 +69,10 @@ class CompositorManagerChild : public PCompositorManagerChild { return wr::ToExternalImageId(id); } + mozilla::ipc::IPCResult RecvNotifyWebRenderError( + const WebRenderError&& aError); +#endif + void ActorDestroy(ActorDestroyReason aReason) override; void HandleFatalError(const char* aMsg) const override; @@ -76,9 +81,6 @@ class CompositorManagerChild : public PCompositorManagerChild { bool ShouldContinueFromReplyTimeout() override; - mozilla::ipc::IPCResult RecvNotifyWebRenderError( - const WebRenderError&& aError); - private: static StaticRefPtr sInstance; diff --git a/gfx/layers/ipc/CompositorManagerParent.cpp b/gfx/layers/ipc/CompositorManagerParent.cpp index f95ad87128..adbb53180a 100644 --- a/gfx/layers/ipc/CompositorManagerParent.cpp +++ b/gfx/layers/ipc/CompositorManagerParent.cpp @@ -4,11 +4,13 @@ #include "mozilla/layers/CompositorManagerParent.h" #include "mozilla/gfx/GPUParent.h" -#include "mozilla/webrender/RenderThread.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/RenderThread.h" +# include "mozilla/layers/SharedSurfacesParent.h" +#endif #include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/ContentCompositorBridgeParent.h" #include "mozilla/layers/CompositorThread.h" -#include "mozilla/layers/SharedSurfacesParent.h" #include "mozilla/Unused.h" #include "nsAutoPtr.h" #include "VsyncSource.h" @@ -148,7 +150,9 @@ void CompositorManagerParent::BindComplete(bool aIsRoot) { } void CompositorManagerParent::ActorDestroy(ActorDestroyReason aReason) { +#ifdef MOZ_BUILD_WEBRENDER SharedSurfacesParent::DestroyProcess(OtherPid()); +#endif StaticMutexAutoLock lock(sMutex); if (sInstance == this) { @@ -256,6 +260,7 @@ CompositorManagerParent::AllocPCompositorBridgeParent( return nullptr; } +#ifdef MOZ_BUILD_WEBRENDER mozilla::ipc::IPCResult CompositorManagerParent::RecvAddSharedSurface( const wr::ExternalImageId& aId, const SurfaceDescriptorShared& aDesc) { SharedSurfacesParent::Add(aId, aDesc, OtherPid()); @@ -326,6 +331,7 @@ void CompositorManagerParent::NotifyWebRenderError(wr::WebRenderError aError) { } Unused << sInstance->SendNotifyWebRenderError(aError); } +#endif // MOZ_BUILD_WEBRENDER } // namespace layers } // namespace mozilla diff --git a/gfx/layers/ipc/CompositorManagerParent.h b/gfx/layers/ipc/CompositorManagerParent.h index 3efef248b8..d3ccf00a80 100644 --- a/gfx/layers/ipc/CompositorManagerParent.h +++ b/gfx/layers/ipc/CompositorManagerParent.h @@ -38,6 +38,7 @@ class CompositorManagerParent final : public PCompositorManagerParent { bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize); +#ifdef MOZ_BUILD_WEBRENDER mozilla::ipc::IPCResult RecvAddSharedSurface( const wr::ExternalImageId& aId, const SurfaceDescriptorShared& aDesc); mozilla::ipc::IPCResult RecvRemoveSharedSurface( @@ -48,6 +49,7 @@ class CompositorManagerParent final : public PCompositorManagerParent { mozilla::ipc::IPCResult RecvNotifyMemoryPressure(); mozilla::ipc::IPCResult RecvReportMemory(ReportMemoryResolver&&); +#endif void BindComplete(bool aIsRoot); void ActorDestroy(ActorDestroyReason aReason) override; @@ -55,7 +57,9 @@ class CompositorManagerParent final : public PCompositorManagerParent { already_AddRefed AllocPCompositorBridgeParent( const CompositorBridgeOptions& aOpt); +#ifdef MOZ_BUILD_WEBRENDER static void NotifyWebRenderError(wr::WebRenderError aError); +#endif private: static StaticRefPtr sInstance; diff --git a/gfx/layers/ipc/ContentCompositorBridgeParent.cpp b/gfx/layers/ipc/ContentCompositorBridgeParent.cpp index d006ff137f..e63dc7b5db 100644 --- a/gfx/layers/ipc/ContentCompositorBridgeParent.cpp +++ b/gfx/layers/ipc/ContentCompositorBridgeParent.cpp @@ -25,8 +25,11 @@ #include "mozilla/layers/LayerTreeOwnerTracker.h" #include "mozilla/layers/PLayerTransactionParent.h" #include "mozilla/layers/RemoteContentController.h" -#include "mozilla/layers/WebRenderBridgeParent.h" -#include "mozilla/layers/AsyncImagePipelineManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderBridgeParent.h" +# include "mozilla/layers/AsyncImagePipelineManager.h" +#endif + #include "mozilla/mozalloc.h" // for operator new, etc #include "nsDebug.h" // for NS_ASSERTION, etc #include "nsTArray.h" // for nsTArray @@ -137,15 +140,34 @@ ContentCompositorBridgeParent::AllocPAPZCTreeManagerParent( // retain a reference to itself, through the checkerboard observer. LayersId dummyId{0}; RefPtr temp = new APZCTreeManager(dummyId); - RefPtr tempUpdater = new APZUpdater(temp, false); - tempUpdater->ClearTree(dummyId); + RefPtr tempUpdater = new APZUpdater(temp +#ifdef MOZ_BUILD_WEBRENDER + , + false +#endif + ); + tempUpdater->ClearTree( +#ifdef MOZ_BUILD_WEBRENDER + dummyId +#endif + ); return new APZCTreeManagerParent( - WRRootId(aLayersId, gfxUtils::GetContentRenderRoot()), temp, - tempUpdater); +#ifdef MOZ_BUILD_WEBRENDER + WRRootId(aLayersId, gfxUtils::GetContentRenderRoot()), +#else + aLayersId, +#endif + temp, tempUpdater); } state.mParent->AllocateAPZCTreeManagerParent( - lock, WRRootId(aLayersId, gfxUtils::GetContentRenderRoot()), state); + lock, +#ifdef MOZ_BUILD_WEBRENDER + WRRootId(aLayersId, gfxUtils::GetContentRenderRoot()), +#else + aLayersId, +#endif + state); return state.mApzcTreeManagerParent; } bool ContentCompositorBridgeParent::DeallocPAPZCTreeManagerParent( @@ -195,6 +217,7 @@ bool ContentCompositorBridgeParent::DeallocPAPZParent(PAPZParent* aActor) { return true; } +#ifdef MOZ_BUILD_WEBRENDER PWebRenderBridgeParent* ContentCompositorBridgeParent::AllocPWebRenderBridgeParent( const wr::PipelineId& aPipelineId, const LayoutDeviceIntSize& aSize) { @@ -263,6 +286,7 @@ bool ContentCompositorBridgeParent::DeallocPWebRenderBridgeParent( parent->Release(); // IPDL reference return true; } +#endif // MOZ_BUILD_WEBRENDER mozilla::ipc::IPCResult ContentCompositorBridgeParent::RecvNotifyChildCreated( const LayersId& child, CompositorOptions* aOptions) { @@ -397,8 +421,10 @@ void ContentCompositorBridgeParent::DidCompositeLocked( Unused << SendDidComposite(aId, transactionId, aCompositeStart, aCompositeEnd); } +#ifdef MOZ_BUILD_WEBRENDER } else if (sIndirectLayerTrees[aId].mWrBridge) { MOZ_ASSERT(false); // this should never get called for a WR compositor +#endif } } @@ -471,11 +497,21 @@ void ContentCompositorBridgeParent::ApplyAsyncProperties( } void ContentCompositorBridgeParent::SetTestAsyncScrollOffset( - const WRRootId& aLayersId, const ScrollableLayerGuid::ViewID& aScrollId, - const CSSPoint& aPoint) { +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aLayersId, +#else + const LayersId& aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, const CSSPoint& aPoint) { MOZ_ASSERT(aLayersId.IsValid()); const CompositorBridgeParent::LayerTreeState* state = - CompositorBridgeParent::GetIndirectShadowTree(aLayersId.mLayersId); + CompositorBridgeParent::GetIndirectShadowTree( +#ifdef MOZ_BUILD_WEBRENDER + aLayersId.mLayersId +#else + aLayersId +#endif + ); if (!state) { return; } @@ -485,11 +521,22 @@ void ContentCompositorBridgeParent::SetTestAsyncScrollOffset( } void ContentCompositorBridgeParent::SetTestAsyncZoom( - const WRRootId& aLayersId, const ScrollableLayerGuid::ViewID& aScrollId, +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aLayersId, +#else + const LayersId& aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, const LayerToParentLayerScale& aZoom) { MOZ_ASSERT(aLayersId.IsValid()); const CompositorBridgeParent::LayerTreeState* state = - CompositorBridgeParent::GetIndirectShadowTree(aLayersId.mLayersId); + CompositorBridgeParent::GetIndirectShadowTree( +#ifdef MOZ_BUILD_WEBRENDER + aLayersId.mLayersId +#else + aLayersId +#endif + ); if (!state) { return; } @@ -499,10 +546,21 @@ void ContentCompositorBridgeParent::SetTestAsyncZoom( } void ContentCompositorBridgeParent::FlushApzRepaints( - const WRRootId& aLayersId) { +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aLayersId +#else + const LayersId& aLayersId +#endif +) { MOZ_ASSERT(aLayersId.IsValid()); const CompositorBridgeParent::LayerTreeState* state = - CompositorBridgeParent::GetIndirectShadowTree(aLayersId.mLayersId); + CompositorBridgeParent::GetIndirectShadowTree( +#ifdef MOZ_BUILD_WEBRENDER + aLayersId.mLayersId +#else + aLayersId +#endif + ); if (!state || !state->mParent) { return; } @@ -510,11 +568,22 @@ void ContentCompositorBridgeParent::FlushApzRepaints( state->mParent->FlushApzRepaints(aLayersId); } -void ContentCompositorBridgeParent::GetAPZTestData(const WRRootId& aLayersId, - APZTestData* aOutData) { +void ContentCompositorBridgeParent::GetAPZTestData( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aLayersId, +#else + const LayersId& aLayersId, +#endif + APZTestData* aOutData) { MOZ_ASSERT(aLayersId.IsValid()); const CompositorBridgeParent::LayerTreeState* state = - CompositorBridgeParent::GetIndirectShadowTree(aLayersId.mLayersId); + CompositorBridgeParent::GetIndirectShadowTree( +#ifdef MOZ_BUILD_WEBRENDER + aLayersId.mLayersId +#else + aLayersId +#endif + ); if (!state || !state->mParent) { return; } @@ -524,7 +593,12 @@ void ContentCompositorBridgeParent::GetAPZTestData(const WRRootId& aLayersId, void ContentCompositorBridgeParent::SetConfirmedTargetAPZC( const LayersId& aLayersId, const uint64_t& aInputBlockId, - const nsTArray& aTargets) { +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif +) { MOZ_ASSERT(aLayersId.IsValid()); const CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(aLayersId); @@ -557,8 +631,12 @@ ContentCompositorBridgeParent::~ContentCompositorBridgeParent() { PTextureParent* ContentCompositorBridgeParent::AllocPTextureParent( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, const LayersBackend& aLayersBackend, const TextureFlags& aFlags, - const LayersId& aId, const uint64_t& aSerial, - const wr::MaybeExternalImageId& aExternalImageId) { + const LayersId& aId, const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif +) { CompositorBridgeParent::LayerTreeState* state = nullptr; LayerTreeMap::iterator itr = sIndirectLayerTrees.find(aId); @@ -587,8 +665,12 @@ PTextureParent* ContentCompositorBridgeParent::AllocPTextureParent( } return TextureHost::CreateIPDLActor(this, aSharedData, aReadLock, - aLayersBackend, aFlags, aSerial, - aExternalImageId); + aLayersBackend, aFlags, aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + aExternalImageId +#endif + ); } bool ContentCompositorBridgeParent::DeallocPTextureParent( diff --git a/gfx/layers/ipc/ContentCompositorBridgeParent.h b/gfx/layers/ipc/ContentCompositorBridgeParent.h index 27de4f5933..b1a0f0effc 100644 --- a/gfx/layers/ipc/ContentCompositorBridgeParent.h +++ b/gfx/layers/ipc/ContentCompositorBridgeParent.h @@ -57,9 +57,11 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase { return IPC_OK(); } mozilla::ipc::IPCResult RecvFlushRendering() override { return IPC_OK(); } +#ifdef MOZ_BUILD_WEBRENDER mozilla::ipc::IPCResult RecvFlushRenderingAsync() override { return IPC_OK(); } +#endif mozilla::ipc::IPCResult RecvForcePresent() override { return IPC_OK(); } mozilla::ipc::IPCResult RecvWaitOnTransactionProcessed() override { return IPC_OK(); @@ -124,18 +126,44 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase { void LeaveTestMode(const LayersId& aId) override; void ApplyAsyncProperties(LayerTransactionParent* aLayerTree, TransformsToSkip aSkip) override; - void SetTestAsyncScrollOffset(const WRRootId& aLayersId, - const ScrollableLayerGuid::ViewID& aScrollId, - const CSSPoint& aPoint) override; - void SetTestAsyncZoom(const WRRootId& aLayersId, - const ScrollableLayerGuid::ViewID& aScrollId, - const LayerToParentLayerScale& aZoom) override; - void FlushApzRepaints(const WRRootId& aLayersId) override; - void GetAPZTestData(const WRRootId& aLayersId, - APZTestData* aOutData) override; - void SetConfirmedTargetAPZC( - const LayersId& aLayersId, const uint64_t& aInputBlockId, - const nsTArray& aTargets) override; + void SetTestAsyncScrollOffset( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, + const CSSPoint& aPoint) override; + void SetTestAsyncZoom( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aWrRootId, +#else + const LayersId& aLayersId, +#endif + const ScrollableLayerGuid::ViewID& aScrollId, + const LayerToParentLayerScale& aZoom) override; + void FlushApzRepaints( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aLayersId +#else + const LayersId& aLayersId +#endif + ) override; + void GetAPZTestData( +#ifdef MOZ_BUILD_WEBRENDER + const WRRootId& aLayersId, +#else + const LayersId& aLayersId, +#endif + APZTestData* aOutData) override; + void SetConfirmedTargetAPZC(const LayersId& aLayersId, + const uint64_t& aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) override; AsyncCompositionManager* GetCompositionManager( LayerTransactionParent* aParent) override; @@ -152,8 +180,12 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase { PTextureParent* AllocPTextureParent( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, const LayersBackend& aLayersBackend, const TextureFlags& aFlags, - const LayersId& aId, const uint64_t& aSerial, - const wr::MaybeExternalImageId& aExternalImageId) override; + const LayersId& aId, const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif + ) override; bool DeallocPTextureParent(PTextureParent* actor) override; @@ -182,10 +214,12 @@ class ContentCompositorBridgeParent final : public CompositorBridgeParentBase { void RegisterPayloads(LayerTransactionParent* aLayerTree, const nsTArray& aPayload) override; +#ifdef MOZ_BUILD_WEBRENDER PWebRenderBridgeParent* AllocPWebRenderBridgeParent( const wr::PipelineId& aPipelineId, const LayoutDeviceIntSize& aSize) override; bool DeallocPWebRenderBridgeParent(PWebRenderBridgeParent* aActor) override; +#endif void ObserveLayersUpdate(LayersId aLayersId, LayersObserverEpoch aEpoch, bool aActive) override; diff --git a/gfx/layers/ipc/ISurfaceAllocator.h b/gfx/layers/ipc/ISurfaceAllocator.h index 8456f1987e..74cd94a5f3 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.h +++ b/gfx/layers/ipc/ISurfaceAllocator.h @@ -101,7 +101,9 @@ class ISurfaceAllocator { virtual bool UsesImageBridge() const { return false; } +#ifdef MOZ_BUILD_WEBRENDER virtual bool UsesWebRenderBridge() const { return false; } +#endif protected: void Finalize() {} diff --git a/gfx/layers/ipc/ImageBridgeChild.cpp b/gfx/layers/ipc/ImageBridgeChild.cpp index a1e603a893..429db816da 100644 --- a/gfx/layers/ipc/ImageBridgeChild.cpp +++ b/gfx/layers/ipc/ImageBridgeChild.cpp @@ -14,12 +14,12 @@ #include "base/task.h" // for NewRunnableFunction, etc #include "base/thread.h" // for Thread #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc -#include "mozilla/Monitor2.h" // for Monitor, MonitorAutoLock +#include "mozilla/Monitor2.h" // for Monitor, MonitorAutoLock #include "mozilla/ReentrantMonitor.h" // for ReentrantMonitor, etc #include "mozilla/ipc/MessageChannel.h" // for MessageChannel, etc #include "mozilla/ipc/Transport.h" // for Transport #include "mozilla/gfx/gfxVars.h" -#include "mozilla/gfx/Point.h" // for IntSize +#include "mozilla/gfx/Point.h" // for IntSize #include "mozilla/layers/AsyncCanvasRenderer.h" #include "mozilla/media/MediaSystemResourceManager.h" // for MediaSystemResourceManager #include "mozilla/media/MediaSystemResourceManagerChild.h" // for MediaSystemResourceManagerChild @@ -96,10 +96,13 @@ struct AutoEndTransaction final { CompositableTransaction* mTxn; }; -void ImageBridgeChild::UseTextures( - CompositableClient* aCompositable, - const nsTArray& aTextures, - const Maybe& aRenderRoot) { +void ImageBridgeChild::UseTextures(CompositableClient* aCompositable, + const nsTArray& aTextures +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif +) { MOZ_ASSERT(aCompositable); MOZ_ASSERT(aCompositable->GetIPCHandle()); MOZ_ASSERT(aCompositable->IsConnected()); @@ -328,7 +331,12 @@ void ImageBridgeChild::UpdateImageClient(RefPtr aContainer) { } BeginTransaction(); - client->UpdateImage(aContainer, Layer::CONTENT_OPAQUE, Nothing()); + client->UpdateImage(aContainer, Layer::CONTENT_OPAQUE +#ifdef MOZ_BUILD_WEBRENDER + , + Nothing() +#endif + ); EndTransaction(); } @@ -368,7 +376,11 @@ void ImageBridgeChild::UpdateAsyncCanvasRendererNow( BeginTransaction(); // TODO wr::RenderRoot::Unknown - aWrapper->GetCanvasClient()->Updated(wr::RenderRoot::Default); + aWrapper->GetCanvasClient()->Updated( +#ifdef MOZ_BUILD_WEBRENDER + wr::RenderRoot::Default +#endif + ); EndTransaction(); } @@ -630,6 +642,7 @@ void ImageBridgeChild::UpdateTextureFactoryIdentifier( const TextureFactoryIdentifier& aIdentifier) { // ImageHost is incompatible between WebRender enabled and WebRender disabled. // Then drop all ImageContainers' ImageClients during disabling WebRender. +#ifdef MOZ_BUILD_WEBRENDER bool disablingWebRender = GetCompositorBackendType() == LayersBackend::LAYERS_WR && aIdentifier.mParentBackend != LayersBackend::LAYERS_WR; @@ -657,6 +670,9 @@ void ImageBridgeChild::UpdateTextureFactoryIdentifier( aIdentifier.mParentBackend == LayersBackend::LAYERS_WR; bool needsDrop = disablingWebRender || initializingWebRender; +#else + bool needsDrop = false; +#endif #if defined(XP_WIN) RefPtr device = gfx::DeviceManagerDx::Get()->GetImageDevice(); @@ -859,8 +875,12 @@ bool ImageBridgeChild::DeallocShmem(ipc::Shmem& aShmem) { PTextureChild* ImageBridgeChild::AllocPTextureChild( const SurfaceDescriptor&, const ReadLockDescriptor&, const LayersBackend&, - const TextureFlags&, const uint64_t& aSerial, - const wr::MaybeExternalImageId& aExternalImageId) { + const TextureFlags&, const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif +) { MOZ_ASSERT(CanSend()); return TextureClient::CreateIPDLActor(); } @@ -936,10 +956,18 @@ mozilla::ipc::IPCResult ImageBridgeChild::RecvReportFramesDropped( PTextureChild* ImageBridgeChild::CreateTexture( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, LayersBackend aLayersBackend, TextureFlags aFlags, uint64_t aSerial, - wr::MaybeExternalImageId& aExternalImageId, nsIEventTarget* aTarget) { +#ifdef MOZ_BUILD_WEBRENDER + wr::MaybeExternalImageId& aExternalImageId, +#endif + nsIEventTarget* aTarget) { MOZ_ASSERT(CanSend()); return SendPTextureConstructor(aSharedData, aReadLock, aLayersBackend, aFlags, - aSerial, aExternalImageId); + aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + aExternalImageId +#endif + ); } static bool IBCAddOpDestroy(CompositableTransaction* aTxn, @@ -961,8 +989,12 @@ bool ImageBridgeChild::DestroyInTransaction(const CompositableHandle& aHandle) { } void ImageBridgeChild::RemoveTextureFromCompositable( - CompositableClient* aCompositable, TextureClient* aTexture, - const Maybe& aRenderRoot) { + CompositableClient* aCompositable, TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif +) { MOZ_ASSERT(CanSend()); MOZ_ASSERT(aTexture); MOZ_ASSERT(aTexture->IsSharedWithCompositor()); @@ -1033,6 +1065,7 @@ void ImageBridgeChild::HandleFatalError(const char* aMsg) const { dom::ContentChild::FatalErrorIfNotUsingGPUProcess(aMsg, OtherPid()); } +#ifdef MOZ_BUILD_WEBRENDER wr::MaybeExternalImageId ImageBridgeChild::GetNextExternalImageId() { static uint32_t sNextID = 1; ++sNextID; @@ -1042,6 +1075,7 @@ wr::MaybeExternalImageId ImageBridgeChild::GetNextExternalImageId() { imageId = imageId << 32 | sNextID; return Some(wr::ToExternalImageId(imageId)); } +#endif } // namespace layers } // namespace mozilla diff --git a/gfx/layers/ipc/ImageBridgeChild.h b/gfx/layers/ipc/ImageBridgeChild.h index 757ee08d1b..7046b42ca2 100644 --- a/gfx/layers/ipc/ImageBridgeChild.h +++ b/gfx/layers/ipc/ImageBridgeChild.h @@ -19,7 +19,9 @@ #include "mozilla/layers/CompositorTypes.h" #include "mozilla/layers/PImageBridgeChild.h" #include "mozilla/Mutex.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "nsRegion.h" // for nsIntRegion #include "mozilla/gfx/Rect.h" #include "mozilla/ReentrantMonitor.h" // for ReentrantMonitor, etc @@ -180,8 +182,12 @@ class ImageBridgeChild final : public PImageBridgeChild, PTextureChild* AllocPTextureChild( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, const LayersBackend& aLayersBackend, const TextureFlags& aFlags, - const uint64_t& aSerial, - const wr::MaybeExternalImageId& aExternalImageId); + const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif + ); bool DeallocPTextureChild(PTextureChild* actor); @@ -264,8 +270,12 @@ class ImageBridgeChild final : public PImageBridgeChild, * See CompositableForwarder::UseTextures */ void UseTextures(CompositableClient* aCompositable, - const nsTArray& aTextures, - const Maybe& aRenderRoot) override; + const nsTArray& aTextures +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ) override; void UseComponentAlphaTextures(CompositableClient* aCompositable, TextureClient* aClientOnBlack, TextureClient* aClientOnWhite) override; @@ -292,9 +302,13 @@ class ImageBridgeChild final : public PImageBridgeChild, bool DestroyInTransaction(PTextureChild* aTexture) override; bool DestroyInTransaction(const CompositableHandle& aHandle); - void RemoveTextureFromCompositable( - CompositableClient* aCompositable, TextureClient* aTexture, - const Maybe& aRenderRoot) override; + void RemoveTextureFromCompositable(CompositableClient* aCompositable, + TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ) override; void UseTiledLayerBuffer( CompositableClient* aCompositable, @@ -335,7 +349,9 @@ class ImageBridgeChild final : public PImageBridgeChild, const ReadLockDescriptor& aReadLock, LayersBackend aLayersBackend, TextureFlags aFlags, uint64_t aSerial, +#ifdef MOZ_BUILD_WEBRENDER wr::MaybeExternalImageId& aExternalImageId, +#endif nsIEventTarget* aTarget = nullptr) override; bool IsSameProcess() const override; @@ -347,7 +363,9 @@ class ImageBridgeChild final : public PImageBridgeChild, void HandleFatalError(const char* aMsg) const override; +#ifdef MOZ_BUILD_WEBRENDER wr::MaybeExternalImageId GetNextExternalImageId() override; +#endif protected: explicit ImageBridgeChild(uint32_t aNamespace); diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index c36fd6dfe9..9515cecd4c 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -270,8 +270,15 @@ mozilla::ipc::IPCResult ImageBridgeParent::RecvWillClose() { mozilla::ipc::IPCResult ImageBridgeParent::RecvNewCompositable( const CompositableHandle& aHandle, const TextureInfo& aInfo, const LayersBackend& aLayersBackend) { +#ifdef MOZ_BUILD_WEBRENDER bool useWebRender = aLayersBackend == LayersBackend::LAYERS_WR; - RefPtr host = AddCompositable(aHandle, aInfo, useWebRender); +#endif + RefPtr host = AddCompositable(aHandle, aInfo +#ifdef MOZ_BUILD_WEBRENDER + , + useWebRender +#endif + ); if (!host) { return IPC_FAIL_NO_REASON(this); } @@ -289,10 +296,19 @@ mozilla::ipc::IPCResult ImageBridgeParent::RecvReleaseCompositable( PTextureParent* ImageBridgeParent::AllocPTextureParent( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, const LayersBackend& aLayersBackend, const TextureFlags& aFlags, - const uint64_t& aSerial, const wr::MaybeExternalImageId& aExternalImageId) { + const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif +) { return TextureHost::CreateIPDLActor(this, aSharedData, aReadLock, - aLayersBackend, aFlags, aSerial, - aExternalImageId); + aLayersBackend, aFlags, aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + aExternalImageId +#endif + ); } bool ImageBridgeParent::DeallocPTextureParent(PTextureParent* actor) { diff --git a/gfx/layers/ipc/ImageBridgeParent.h b/gfx/layers/ipc/ImageBridgeParent.h index 6cdd2451e3..1543da993a 100644 --- a/gfx/layers/ipc/ImageBridgeParent.h +++ b/gfx/layers/ipc/ImageBridgeParent.h @@ -79,8 +79,12 @@ class ImageBridgeParent final : public PImageBridgeParent, PTextureParent* AllocPTextureParent( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, const LayersBackend& aLayersBackend, const TextureFlags& aFlags, - const uint64_t& aSerial, - const wr::MaybeExternalImageId& aExternalImageId); + const uint64_t& aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + const wr::MaybeExternalImageId& aExternalImageId +#endif + ); bool DeallocPTextureParent(PTextureParent* actor); mozilla::ipc::IPCResult RecvNewCompositable( diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index 80393a46a0..b3147b2925 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -386,8 +386,13 @@ mozilla::ipc::IPCResult LayerTransactionParent::RecvUpdate( if (!imageBridge) { return IPC_FAIL_NO_REASON(this); } - RefPtr host = imageBridge->FindCompositable( - op.compositable(), /* aAllowDisablingWebRender */ true); + RefPtr host = + imageBridge->FindCompositable(op.compositable() +#ifdef MOZ_BUILD_WEBRENDER + , + /* aAllowDisablingWebRender */ true +#endif + ); if (!host) { // This normally should not happen, but can after a GPU process crash. // Media may not have had time to update the ImageContainer associated @@ -745,8 +750,13 @@ mozilla::ipc::IPCResult LayerTransactionParent::RecvSetAsyncScrollOffset( return IPC_FAIL_NO_REASON(this); } - mCompositorBridge->SetTestAsyncScrollOffset(WRRootId::NonWebRender(GetId()), - aScrollID, CSSPoint(aX, aY)); + mCompositorBridge->SetTestAsyncScrollOffset( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId::NonWebRender(GetId()), +#else + GetId(), +#endif + aScrollID, CSSPoint(aX, aY)); return IPC_OK(); } @@ -756,20 +766,36 @@ mozilla::ipc::IPCResult LayerTransactionParent::RecvSetAsyncZoom( return IPC_FAIL_NO_REASON(this); } - mCompositorBridge->SetTestAsyncZoom(WRRootId::NonWebRender(GetId()), - aScrollID, - LayerToParentLayerScale(aValue)); + mCompositorBridge->SetTestAsyncZoom( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId::NonWebRender(GetId()), +#else + GetId(), +#endif + aScrollID, LayerToParentLayerScale(aValue)); return IPC_OK(); } mozilla::ipc::IPCResult LayerTransactionParent::RecvFlushApzRepaints() { - mCompositorBridge->FlushApzRepaints(WRRootId::NonWebRender(GetId())); + mCompositorBridge->FlushApzRepaints( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId::NonWebRender(GetId()) +#else + GetId() +#endif + ); return IPC_OK(); } mozilla::ipc::IPCResult LayerTransactionParent::RecvGetAPZTestData( APZTestData* aOutData) { - mCompositorBridge->GetAPZTestData(WRRootId::NonWebRender(GetId()), aOutData); + mCompositorBridge->GetAPZTestData( +#ifdef MOZ_BUILD_WEBRENDER + WRRootId::NonWebRender(GetId()), +#else + GetId(), +#endif + aOutData); return IPC_OK(); } @@ -780,9 +806,16 @@ mozilla::ipc::IPCResult LayerTransactionParent::RecvRequestProperty( } mozilla::ipc::IPCResult LayerTransactionParent::RecvSetConfirmedTargetAPZC( - const uint64_t& aBlockId, nsTArray&& aTargets) { + const uint64_t& aBlockId, +#ifdef MOZ_BUILD_WEBRENDER + nsTArray&& aTargets +#else + nsTArray&& aTargets +#endif +) { for (size_t i = 0; i < aTargets.Length(); i++) { // Guard against bad data from hijacked child processes +#ifdef MOZ_BUILD_WEBRENDER if (aTargets[i].mRenderRoot != wr::RenderRoot::Default) { NS_ERROR( "Unexpected render root in RecvSetConfirmedTargetAPZC; dropping " @@ -790,6 +823,9 @@ mozilla::ipc::IPCResult LayerTransactionParent::RecvSetConfirmedTargetAPZC( return IPC_FAIL(this, "Bad render root"); } if (aTargets[i].mScrollableLayerGuid.mLayersId != GetId()) { +#else + if (aTargets[i].mLayersId != GetId()) { +#endif NS_ERROR( "Unexpected layers id in RecvSetConfirmedTargetAPZC; dropping " "message..."); @@ -816,10 +852,12 @@ bool LayerTransactionParent::Attach(Layer* aLayer, static_cast(aLayer->Manager()) ->GetTextureSourceProvider(); +#ifdef MOZ_BUILD_WEBRENDER MOZ_ASSERT(!aCompositable->AsWebRenderImageHost()); if (aCompositable->AsWebRenderImageHost()) { gfxCriticalNote << "Use WebRenderImageHost at LayerTransactionParent."; } +#endif if (!layer->SetCompositableHost(aCompositable)) { // not all layer types accept a compositable, see bug 967824 return false; @@ -968,7 +1006,12 @@ Layer* LayerTransactionParent::AsLayer(const LayerHandle& aHandle) { mozilla::ipc::IPCResult LayerTransactionParent::RecvNewCompositable( const CompositableHandle& aHandle, const TextureInfo& aInfo) { - if (!AddCompositable(aHandle, aInfo, /* aUseWebRender */ false)) { + if (!AddCompositable(aHandle, aInfo +#ifdef MOZ_BUILD_WEBRENDER + , + /* aUseWebRender */ false +#endif + )) { return IPC_FAIL_NO_REASON(this); } return IPC_OK(); diff --git a/gfx/layers/ipc/LayerTransactionParent.h b/gfx/layers/ipc/LayerTransactionParent.h index d52d01de13..70f3bb2350 100644 --- a/gfx/layers/ipc/LayerTransactionParent.h +++ b/gfx/layers/ipc/LayerTransactionParent.h @@ -128,7 +128,13 @@ class LayerTransactionParent final : public PLayerTransactionParent, mozilla::ipc::IPCResult RecvRequestProperty(const nsString& aProperty, float* aValue); mozilla::ipc::IPCResult RecvSetConfirmedTargetAPZC( - const uint64_t& aBlockId, nsTArray&& aTargets); + const uint64_t& aBlockId, +#ifdef MOZ_BUILD_WEBRENDER + nsTArray&& aTargets +#else + nsTArray&& aTargets +#endif + ); mozilla::ipc::IPCResult RecvRecordPaintTimes(const PaintTiming& aTiming); mozilla::ipc::IPCResult RecvGetTextureFactoryIdentifier( TextureFactoryIdentifier* aIdentifier); diff --git a/gfx/layers/ipc/LayersMessageUtils.h b/gfx/layers/ipc/LayersMessageUtils.h index 227366f0d6..c890bd43dc 100644 --- a/gfx/layers/ipc/LayersMessageUtils.h +++ b/gfx/layers/ipc/LayersMessageUtils.h @@ -19,7 +19,6 @@ #include "mozilla/ServoBindings.h" #include "mozilla/ipc/ByteBufUtils.h" #include "mozilla/layers/APZInputBridge.h" -#include "mozilla/layers/APZTypes.h" #include "mozilla/layers/AsyncDragMetrics.h" #include "mozilla/layers/CompositorOptions.h" #include "mozilla/layers/CompositorTypes.h" @@ -29,9 +28,12 @@ #include "mozilla/layers/LayerAttributes.h" #include "mozilla/layers/LayersTypes.h" #include "mozilla/layers/MatrixMessage.h" -#include "mozilla/layers/RefCountedShmem.h" #include "mozilla/layers/RepaintRequest.h" -#include "mozilla/layers/WebRenderMessageUtils.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/APZTypes.h" +# include "mozilla/layers/RefCountedShmem.h" +# include "mozilla/layers/WebRenderMessageUtils.h" +#endif #include "mozilla/Move.h" #include "nsSize.h" @@ -549,6 +551,7 @@ struct ParamTraits { } }; +#ifdef MOZ_BUILD_WEBRENDER template <> struct ParamTraits { typedef mozilla::layers::SLGuidAndRenderRoot paramType; @@ -564,6 +567,7 @@ struct ParamTraits { ReadParam(aMsg, aIter, &aResult->mRenderRoot)); } }; +#endif template <> struct ParamTraits { @@ -615,17 +619,22 @@ struct ParamTraits { static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, aParam.mHorizontal); - WriteParam(aMsg, aParam.mHorizontalRenderRoot); WriteParam(aMsg, aParam.mVertical); +#ifdef MOZ_BUILD_WEBRENDER + WriteParam(aMsg, aParam.mHorizontalRenderRoot); WriteParam(aMsg, aParam.mVerticalRenderRoot); +#endif } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mHorizontal) && - ReadParam(aMsg, aIter, &aResult->mHorizontalRenderRoot) && - ReadParam(aMsg, aIter, &aResult->mVertical) && - ReadParam(aMsg, aIter, &aResult->mVerticalRenderRoot); + ReadParam(aMsg, aIter, &aResult->mVertical) +#ifdef MOZ_BUILD_WEBRENDER + && ReadParam(aMsg, aIter, &aResult->mHorizontalRenderRoot) && + ReadParam(aMsg, aIter, &aResult->mVerticalRenderRoot) +#endif + ; } }; @@ -776,7 +785,9 @@ struct ParamTraits { static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, aParam.mUseAPZ); +#ifdef MOZ_BUILD_WEBRENDER WriteParam(aMsg, aParam.mUseWebRender); +#endif WriteParam(aMsg, aParam.mUseAdvancedLayers); WriteParam(aMsg, aParam.mInitiallyPaused); } @@ -784,7 +795,9 @@ struct ParamTraits { static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { return ReadParam(aMsg, aIter, &aResult->mUseAPZ) && +#ifdef MOZ_BUILD_WEBRENDER ReadParam(aMsg, aIter, &aResult->mUseWebRender) && +#endif ReadParam(aMsg, aIter, &aResult->mUseAdvancedLayers) && ReadParam(aMsg, aIter, &aResult->mInitiallyPaused); } diff --git a/gfx/layers/ipc/PAPZCTreeManager.ipdl b/gfx/layers/ipc/PAPZCTreeManager.ipdl index a5c5d87185..d2564471ad 100644 --- a/gfx/layers/ipc/PAPZCTreeManager.ipdl +++ b/gfx/layers/ipc/PAPZCTreeManager.ipdl @@ -15,12 +15,14 @@ using ScreenPoint from "Units.h"; using mozilla::layers::MaybeZoomConstraints from "mozilla/layers/ZoomConstraints.h"; using struct mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h"; using mozilla::layers::ScrollableLayerGuid::ViewID from "mozilla/layers/ScrollableLayerGuid.h"; -using struct mozilla::layers::SLGuidAndRenderRoot from "mozilla/layers/APZTypes.h"; using mozilla::layers::TouchBehaviorFlags from "mozilla/layers/LayersTypes.h"; using mozilla::layers::AsyncDragMetrics from "mozilla/layers/AsyncDragMetrics.h"; using mozilla::layers::GeckoContentController::TapType from "mozilla/layers/GeckoContentController.h"; using class mozilla::layers::KeyboardMap from "mozilla/layers/KeyboardMap.h"; +#ifdef MOZ_BUILD_WEBRENDER +using struct mozilla::layers::SLGuidAndRenderRoot from "mozilla/layers/APZTypes.h"; using mozilla::wr::RenderRoot from "mozilla/webrender/WebRenderTypes.h"; +#endif using mozilla::Modifiers from "mozilla/EventForwards.h"; using mozilla::PinchGestureInput::PinchGestureType from "InputData.h"; @@ -46,13 +48,31 @@ parent: // These messages correspond to the methods // on the IAPZCTreeManager interface - async ZoomToRect(SLGuidAndRenderRoot aGuid, CSSRect aRect, uint32_t Flags); + async ZoomToRect( +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot aGuid, +#else + ScrollableLayerGuid aGuid, +#endif + CSSRect aRect, uint32_t Flags); async ContentReceivedInputBlock(uint64_t aInputBlockId, bool PreventDefault); - async SetTargetAPZC(uint64_t aInputBlockId, SLGuidAndRenderRoot[] Targets); - - async UpdateZoomConstraints(SLGuidAndRenderRoot aGuid, MaybeZoomConstraints aConstraints); + async SetTargetAPZC(uint64_t aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot[] Targets +#else + ScrollableLayerGuid[] Targets +#endif + ); + + async UpdateZoomConstraints( +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot aGuid, +#else + ScrollableLayerGuid aGuid, +#endif + MaybeZoomConstraints aConstraints); async SetKeyboardMap(KeyboardMap aKeyboardMap); @@ -60,11 +80,29 @@ parent: async SetAllowedTouchBehavior(uint64_t aInputBlockId, TouchBehaviorFlags[] aValues); - async StartScrollbarDrag(SLGuidAndRenderRoot aGuid, AsyncDragMetrics aDragMetrics); - - async StartAutoscroll(SLGuidAndRenderRoot aGuid, ScreenPoint aAnchorLocation); - - async StopAutoscroll(SLGuidAndRenderRoot aGuid); + async StartScrollbarDrag( +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot aGuid, +#else + ScrollableLayerGuid aGuid, +#endif + AsyncDragMetrics aDragMetrics); + + async StartAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot aGuid, +#else + ScrollableLayerGuid aGuid, +#endif + ScreenPoint aAnchorLocation); + + async StopAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot aGuid +#else + ScrollableLayerGuid aGuid +#endif + ); async SetLongTapEnabled(bool aTapGestureEnabled); diff --git a/gfx/layers/ipc/PCompositorBridge.ipdl b/gfx/layers/ipc/PCompositorBridge.ipdl index 1978f3d85d..5f30c256f5 100644 --- a/gfx/layers/ipc/PCompositorBridge.ipdl +++ b/gfx/layers/ipc/PCompositorBridge.ipdl @@ -12,10 +12,12 @@ include protocol PCompositorManager; include protocol PCompositorWidget; include protocol PLayerTransaction; include protocol PTexture; -include protocol PWebRenderBridge; include "mozilla/GfxMessageUtils.h"; include "mozilla/layers/LayersMessageUtils.h"; +#ifdef MOZ_BUILD_WEBRENDER +include protocol PWebRenderBridge; include "mozilla/layers/WebRenderMessageUtils.h"; +#endif using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; using struct mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h"; @@ -34,10 +36,12 @@ using class mozilla::TimeStamp from "mozilla/TimeStamp.h"; using class mozilla::layers::FrameUniformityData from "mozilla/layers/FrameUniformityData.h"; using mozilla::layers::TextureFlags from "mozilla/layers/CompositorTypes.h"; using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h"; +using base::ProcessId from "base/process.h"; +#ifdef MOZ_BUILD_WEBRENDER using mozilla::wr::PipelineId from "mozilla/webrender/WebRenderTypes.h"; using mozilla::wr::IdNamespace from "mozilla/webrender/WebRenderTypes.h"; -using base::ProcessId from "base/process.h"; using mozilla::wr::MaybeExternalImageId from "mozilla/webrender/WebRenderTypes.h"; +#endif using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h"; using mozilla::layers::TransactionId from "mozilla/layers/LayersTypes.h"; @@ -96,7 +100,9 @@ sync refcounted protocol PCompositorBridge manages PLayerTransaction; manages PTexture; manages PCompositorWidget; +#ifdef MOZ_BUILD_WEBRENDER manages PWebRenderBridge; +#endif child: // The child should invalidate retained layers. This is used for local @@ -215,7 +221,9 @@ parent: // Same as FlushRendering, but asynchronous, since not all platforms require // synchronous repaints on resize. +#ifdef MOZ_BUILD_WEBRENDER async FlushRenderingAsync(); +#endif // Make sure any pending composites have been received. sync WaitOnTransactionProcessed(); @@ -251,12 +259,18 @@ parent: */ async AllPluginsCaptured(); - async PTexture(SurfaceDescriptor aSharedData, ReadLockDescriptor aReadLock, LayersBackend aBackend, TextureFlags aTextureFlags, LayersId id, uint64_t aSerial, MaybeExternalImageId aExternalImageId); + async PTexture(SurfaceDescriptor aSharedData, ReadLockDescriptor aReadLock, LayersBackend aBackend, TextureFlags aTextureFlags, LayersId id, uint64_t aSerial +#ifdef MOZ_BUILD_WEBRENDER + , MaybeExternalImageId aExternalImageId +#endif + ); sync SyncWithCompositor(); // The pipelineId is the same as the layersId +#ifdef MOZ_BUILD_WEBRENDER async PWebRenderBridge(PipelineId pipelineId, LayoutDeviceIntSize aSize); +#endif sync CheckContentOnlyTDR(uint32_t sequenceNum) returns (bool isContentOnlyTDR); diff --git a/gfx/layers/ipc/PCompositorManager.ipdl b/gfx/layers/ipc/PCompositorManager.ipdl index cdfc14adb6..c650d6ca78 100644 --- a/gfx/layers/ipc/PCompositorManager.ipdl +++ b/gfx/layers/ipc/PCompositorManager.ipdl @@ -5,7 +5,9 @@ include protocol PCompositorBridge; include LayersSurfaces; include "mozilla/GfxMessageUtils.h"; +#ifdef MOZ_BUILD_WEBRENDER include "mozilla/layers/WebRenderMessageUtils.h"; +#endif using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; using mozilla::TimeDuration from "mozilla/TimeStamp.h"; @@ -13,10 +15,12 @@ using mozilla::CSSToLayoutDeviceScale from "Units.h"; using mozilla::gfx::IntSize from "mozilla/gfx/2D.h"; using mozilla::ipc::SharedMemoryBasic::Handle from "mozilla/ipc/SharedMemoryBasic.h"; using mozilla::layers::CompositorOptions from "mozilla/layers/CompositorOptions.h"; +#ifdef MOZ_BUILD_WEBRENDER using mozilla::wr::ExternalImageId from "mozilla/webrender/WebRenderTypes.h"; using mozilla::wr::MemoryReport from "mozilla/webrender/WebRenderTypes.h"; using mozilla::wr::WebRenderError from "mozilla/webrender/WebRenderTypes.h"; using mozilla::layers::SharedSurfacesMemoryReport from "mozilla/layers/SharedSurfacesMemoryReport.h"; +#endif namespace mozilla { namespace layers { @@ -73,16 +77,18 @@ parent: */ async PCompositorBridge(CompositorBridgeOptions options); +#ifdef MOZ_BUILD_WEBRENDER async AddSharedSurface(ExternalImageId aId, SurfaceDescriptorShared aDesc); async RemoveSharedSurface(ExternalImageId aId); async ReportSharedSurfacesMemory() returns (SharedSurfacesMemoryReport aReport); - async NotifyMemoryPressure(); - async ReportMemory() returns (MemoryReport aReport); + async NotifyMemoryPressure(); + child: async NotifyWebRenderError(WebRenderError error); +#endif }; } // layers diff --git a/gfx/layers/ipc/PImageBridge.ipdl b/gfx/layers/ipc/PImageBridge.ipdl index 9bfd04d7b0..ee9dd3cfa5 100644 --- a/gfx/layers/ipc/PImageBridge.ipdl +++ b/gfx/layers/ipc/PImageBridge.ipdl @@ -10,12 +10,16 @@ include protocol PMediaSystemResourceManager; include "mozilla/GfxMessageUtils.h"; include "mozilla/layers/LayersMessageUtils.h"; +#ifdef MOZ_BUILD_WEBRENDER include "mozilla/layers/WebRenderMessageUtils.h"; +#endif using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; using mozilla::layers::TextureFlags from "mozilla/layers/CompositorTypes.h"; using mozilla::layers::CompositableHandle from "mozilla/layers/LayersTypes.h"; +#ifdef MOZ_BUILD_WEBRENDER using mozilla::wr::MaybeExternalImageId from "mozilla/webrender/WebRenderTypes.h"; +#endif namespace mozilla { namespace layers { @@ -50,7 +54,11 @@ parent: // before sending closing the channel. sync WillClose(); - async PTexture(SurfaceDescriptor aSharedData, ReadLockDescriptor aReadLock, LayersBackend aBackend, TextureFlags aTextureFlags, uint64_t aSerial, MaybeExternalImageId aExternalImageId); + async PTexture(SurfaceDescriptor aSharedData, ReadLockDescriptor aReadLock, LayersBackend aBackend, TextureFlags aTextureFlags, uint64_t aSerial +#ifdef MOZ_BUILD_WEBRENDER + , MaybeExternalImageId aExternalImageId +#endif + ); async PMediaSystemResourceManager(); sync NewCompositable(CompositableHandle aHandle, TextureInfo aInfo, LayersBackend aBackend); diff --git a/gfx/layers/ipc/PLayerTransaction.ipdl b/gfx/layers/ipc/PLayerTransaction.ipdl index 649886fab7..6bd470a271 100644 --- a/gfx/layers/ipc/PLayerTransaction.ipdl +++ b/gfx/layers/ipc/PLayerTransaction.ipdl @@ -15,7 +15,11 @@ using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; using class mozilla::layers::APZTestData from "mozilla/layers/APZTestData.h"; using mozilla::layers::ScrollableLayerGuid::ViewID from "mozilla/layers/ScrollableLayerGuid.h"; +#ifdef MOZ_BUILD_WEBRENDER using struct mozilla::layers::SLGuidAndRenderRoot from "mozilla/layers/APZTypes.h"; +#else +using struct mozilla::layers::ScrollableLayerGuid from "mozilla/layers/ScrollableLayerGuid.h"; +#endif using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h"; using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h"; using mozilla::layers::LayerHandle from "mozilla/layers/LayersTypes.h"; @@ -63,7 +67,13 @@ parent: // Tell the compositor to notify APZ that a layer has been confirmed for an // input event. - async SetConfirmedTargetAPZC(uint64_t aInputBlockId, SLGuidAndRenderRoot[] aTargets); + async SetConfirmedTargetAPZC(uint64_t aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot[] aTargets +#else + ScrollableLayerGuid[] aTargets +#endif + ); // Testing APIs diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index 3c1cfefd16..538572a782 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -402,8 +402,12 @@ void ShadowLayerForwarder::UpdateTextureRegion( void ShadowLayerForwarder::UseTextures( CompositableClient* aCompositable, - const nsTArray& aTextures, - const Maybe& aRenderRoot) { + const nsTArray& aTextures +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif +) { MOZ_ASSERT(aCompositable); if (!aCompositable->IsConnected()) { @@ -482,8 +486,12 @@ bool ShadowLayerForwarder::DestroyInTransaction( } void ShadowLayerForwarder::RemoveTextureFromCompositable( - CompositableClient* aCompositable, TextureClient* aTexture, - const Maybe& aRenderRoot) { + CompositableClient* aCompositable, TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif +) { MOZ_ASSERT(aCompositable); MOZ_ASSERT(aTexture); MOZ_ASSERT(aTexture->GetIPDLActor()); diff --git a/gfx/layers/ipc/ShadowLayers.h b/gfx/layers/ipc/ShadowLayers.h index 5b7aa69af8..e9455eddf4 100644 --- a/gfx/layers/ipc/ShadowLayers.h +++ b/gfx/layers/ipc/ShadowLayers.h @@ -215,9 +215,13 @@ class ShadowLayerForwarder final : public LayersIPCActor, bool DestroyInTransaction(PTextureChild* aTexture) override; bool DestroyInTransaction(const CompositableHandle& aHandle); - void RemoveTextureFromCompositable( - CompositableClient* aCompositable, TextureClient* aTexture, - const Maybe& aRenderRoot) override; + void RemoveTextureFromCompositable(CompositableClient* aCompositable, + TextureClient* aTexture +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ) override; /** * Communicate to the compositor that aRegion in the texture identified by @@ -231,8 +235,12 @@ class ShadowLayerForwarder final : public LayersIPCActor, * See CompositableForwarder::UseTextures */ void UseTextures(CompositableClient* aCompositable, - const nsTArray& aTextures, - const Maybe& aRenderRoot) override; + const nsTArray& aTextures +#ifdef MOZ_BUILD_WEBRENDER + , + const Maybe& aRenderRoot +#endif + ) override; void UseComponentAlphaTextures(CompositableClient* aCompositable, TextureClient* aClientOnBlack, TextureClient* aClientOnWhite) override; diff --git a/gfx/layers/ipc/TextureForwarder.h b/gfx/layers/ipc/TextureForwarder.h index bc5acd2225..4cc9dde566 100644 --- a/gfx/layers/ipc/TextureForwarder.h +++ b/gfx/layers/ipc/TextureForwarder.h @@ -52,9 +52,11 @@ class LayersIPCChannel : public LayersIPCActor, virtual void CancelWaitForNotifyNotUsed(uint64_t aTextureId) = 0; +#ifdef MOZ_BUILD_WEBRENDER virtual wr::MaybeExternalImageId GetNextExternalImageId() { return Nothing(); } +#endif protected: virtual ~LayersIPCChannel() = default; @@ -74,7 +76,9 @@ class TextureForwarder : public LayersIPCChannel { virtual PTextureChild* CreateTexture( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, LayersBackend aLayersBackend, TextureFlags aFlags, uint64_t aSerial, +#ifdef MOZ_BUILD_WEBRENDER wr::MaybeExternalImageId& aExternalImageId, +#endif nsIEventTarget* aTarget = nullptr) = 0; }; diff --git a/gfx/layers/ipc/VideoBridgeChild.cpp b/gfx/layers/ipc/VideoBridgeChild.cpp index 3e246a14c9..63f405376a 100644 --- a/gfx/layers/ipc/VideoBridgeChild.cpp +++ b/gfx/layers/ipc/VideoBridgeChild.cpp @@ -80,7 +80,10 @@ void VideoBridgeChild::ActorDealloc() { mIPDLSelfRef = nullptr; } PTextureChild* VideoBridgeChild::CreateTexture( const SurfaceDescriptor& aSharedData, const ReadLockDescriptor& aReadLock, LayersBackend aLayersBackend, TextureFlags aFlags, uint64_t aSerial, - wr::MaybeExternalImageId& aExternalImageId, nsIEventTarget* aTarget) { +#ifdef MOZ_BUILD_WEBRENDER + wr::MaybeExternalImageId& aExternalImageId, +#endif + nsIEventTarget* aTarget) { MOZ_ASSERT(CanSend()); return SendPTextureConstructor(aSharedData, aReadLock, aLayersBackend, aFlags, aSerial); diff --git a/gfx/layers/ipc/VideoBridgeChild.h b/gfx/layers/ipc/VideoBridgeChild.h index e5bb21295d..f58ef9a789 100644 --- a/gfx/layers/ipc/VideoBridgeChild.h +++ b/gfx/layers/ipc/VideoBridgeChild.h @@ -47,7 +47,9 @@ class VideoBridgeChild final : public PVideoBridgeChild, const ReadLockDescriptor& aReadLock, LayersBackend aLayersBackend, TextureFlags aFlags, uint64_t aSerial, +#ifdef MOZ_BUILD_WEBRENDER wr::MaybeExternalImageId& aExternalImageId, +#endif nsIEventTarget* aTarget = nullptr) override; // ClientIPCAllocator diff --git a/gfx/layers/ipc/VideoBridgeParent.cpp b/gfx/layers/ipc/VideoBridgeParent.cpp index 8ff656d988..08d8cede80 100644 --- a/gfx/layers/ipc/VideoBridgeParent.cpp +++ b/gfx/layers/ipc/VideoBridgeParent.cpp @@ -46,7 +46,12 @@ PTextureParent* VideoBridgeParent::AllocPTextureParent( const LayersBackend& aLayersBackend, const TextureFlags& aFlags, const uint64_t& aSerial) { PTextureParent* parent = TextureHost::CreateIPDLActor( - this, aSharedData, aReadLock, aLayersBackend, aFlags, aSerial, Nothing()); + this, aSharedData, aReadLock, aLayersBackend, aFlags, aSerial +#ifdef MOZ_BUILD_WEBRENDER + , + Nothing() +#endif + ); if (!parent) { return nullptr; diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 1fe6f01ada..6665d9c2e3 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -108,7 +108,6 @@ EXPORTS.mozilla.layers += [ 'AnimationInfo.h', 'apz/public/APZInputBridge.h', 'apz/public/APZSampler.h', - 'apz/public/APZTypes.h', 'apz/public/APZUpdater.h', 'apz/public/CompositorController.h', 'apz/public/GeckoContentController.h', @@ -208,14 +207,10 @@ EXPORTS.mozilla.layers += [ 'ipc/LayerTransactionChild.h', 'ipc/LayerTransactionParent.h', 'ipc/LayerTreeOwnerTracker.h', - 'ipc/RefCountedShmem.h', 'ipc/RemoteContentController.h', 'ipc/ShadowLayers.h', 'ipc/SharedPlanarYCbCrImage.h', 'ipc/SharedRGBImage.h', - 'ipc/SharedSurfacesChild.h', - 'ipc/SharedSurfacesMemoryReport.h', - 'ipc/SharedSurfacesParent.h', 'ipc/SynchronousTask.h', 'ipc/TextureForwarder.h', 'ipc/UiCompositorControllerChild.h', @@ -258,30 +253,39 @@ EXPORTS.mozilla.layers += [ 'TransactionIdAllocator.h', 'TreeTraversal.h', 'UpdateImageHelper.h', - 'wr/AsyncImagePipelineManager.h', - 'wr/ClipManager.h', - 'wr/IpcResourceUpdateQueue.h', - 'wr/RenderRootBoundary.h', - 'wr/RenderRootStateManager.h', - 'wr/RenderRootTypes.h', - 'wr/StackingContextHelper.h', - 'wr/WebRenderBridgeChild.h', - 'wr/WebRenderBridgeParent.h', - 'wr/WebRenderCanvasRenderer.h', - 'wr/WebRenderCommandBuilder.h', - 'wr/WebRenderCompositionRecorder.h', - 'wr/WebRenderDrawEventRecorder.h', - 'wr/WebRenderImageHost.h', - 'wr/WebRenderLayerManager.h', - 'wr/WebRenderLayersLogging.h', - 'wr/WebRenderMessageUtils.h', - 'wr/WebRenderScrollData.h', - 'wr/WebRenderScrollDataWrapper.h', - 'wr/WebRenderTextureHost.h', - 'wr/WebRenderUserData.h', 'ZoomConstraints.h', ] +if CONFIG['MOZ_BUILD_WEBRENDER']: + EXPORTS.mozilla.layers += [ + 'apz/public/APZTypes.h', + 'ipc/RefCountedShmem.h', + 'ipc/SharedSurfacesChild.h', + 'ipc/SharedSurfacesMemoryReport.h', + 'ipc/SharedSurfacesParent.h', + 'wr/AsyncImagePipelineManager.h', + 'wr/ClipManager.h', + 'wr/IpcResourceUpdateQueue.h', + 'wr/RenderRootBoundary.h', + 'wr/RenderRootStateManager.h', + 'wr/RenderRootTypes.h', + 'wr/StackingContextHelper.h', + 'wr/WebRenderBridgeChild.h', + 'wr/WebRenderBridgeParent.h', + 'wr/WebRenderCanvasRenderer.h', + 'wr/WebRenderCommandBuilder.h', + 'wr/WebRenderCompositionRecorder.h', + 'wr/WebRenderDrawEventRecorder.h', + 'wr/WebRenderImageHost.h', + 'wr/WebRenderLayerManager.h', + 'wr/WebRenderLayersLogging.h', + 'wr/WebRenderMessageUtils.h', + 'wr/WebRenderScrollData.h', + 'wr/WebRenderScrollDataWrapper.h', + 'wr/WebRenderTextureHost.h', + 'wr/WebRenderUserData.h', + ] + if CONFIG['MOZ_X11']: EXPORTS.mozilla.layers += [ 'basic/TextureClientX11.h', @@ -453,13 +457,10 @@ UNIFIED_SOURCES += [ 'ipc/LayerTransactionChild.cpp', 'ipc/LayerTransactionParent.cpp', 'ipc/LayerTreeOwnerTracker.cpp', - 'ipc/RefCountedShmem.cpp', 'ipc/RemoteContentController.cpp', 'ipc/ShadowLayers.cpp', 'ipc/SharedPlanarYCbCrImage.cpp', 'ipc/SharedRGBImage.cpp', - 'ipc/SharedSurfacesChild.cpp', - 'ipc/SharedSurfacesParent.cpp', 'ipc/UiCompositorControllerChild.cpp', 'ipc/UiCompositorControllerParent.cpp', 'ipc/VideoBridgeChild.cpp', @@ -507,35 +508,46 @@ UNIFIED_SOURCES += [ 'SyncObject.cpp', 'TextureSourceProvider.cpp', 'TextureWrapperImage.cpp', - 'wr/AsyncImagePipelineManager.cpp', - 'wr/ClipManager.cpp', - 'wr/IpcResourceUpdateQueue.cpp', - 'wr/RenderRootStateManager.cpp', - 'wr/RenderRootTypes.cpp', - 'wr/StackingContextHelper.cpp', - 'wr/WebRenderBridgeChild.cpp', - 'wr/WebRenderBridgeParent.cpp', - 'wr/WebRenderCanvasRenderer.cpp', - 'wr/WebRenderCommandBuilder.cpp', - 'wr/WebRenderCompositionRecorder.cpp', - 'wr/WebRenderDrawEventRecorder.cpp', - 'wr/WebRenderImageHost.cpp', - 'wr/WebRenderLayerManager.cpp', - 'wr/WebRenderLayersLogging.cpp', - 'wr/WebRenderScrollData.cpp', - 'wr/WebRenderUserData.cpp', - # XXX here are some unified build error. - #'wr/WebRenderTextureHost.cpp' ] +if CONFIG['MOZ_BUILD_WEBRENDER']: + UNIFIED_SOURCES += [ + 'ipc/RefCountedShmem.cpp', + 'ipc/SharedSurfacesChild.cpp', + 'ipc/SharedSurfacesParent.cpp', + 'wr/AsyncImagePipelineManager.cpp', + 'wr/ClipManager.cpp', + 'wr/IpcResourceUpdateQueue.cpp', + 'wr/RenderRootStateManager.cpp', + 'wr/RenderRootTypes.cpp', + 'wr/StackingContextHelper.cpp', + 'wr/WebRenderBridgeChild.cpp', + 'wr/WebRenderBridgeParent.cpp', + 'wr/WebRenderCanvasRenderer.cpp', + 'wr/WebRenderCommandBuilder.cpp', + 'wr/WebRenderCompositionRecorder.cpp', + 'wr/WebRenderDrawEventRecorder.cpp', + 'wr/WebRenderImageHost.cpp', + 'wr/WebRenderLayerManager.cpp', + 'wr/WebRenderLayersLogging.cpp', + 'wr/WebRenderScrollData.cpp', + 'wr/WebRenderUserData.cpp', + # XXX here are some unified build error. + #'wr/WebRenderTextureHost.cpp' + ] + SOURCES += [ 'basic/BasicImageLayer.cpp', 'ImageContainer.cpp', 'PersistentBufferProvider.cpp', 'protobuf/LayerScopePacket.pb.cc', - 'wr/WebRenderTextureHost.cpp', ] +if CONFIG['MOZ_BUILD_WEBRENDER']: + SOURCES += [ + 'wr/WebRenderTextureHost.cpp', + ] + DEFINES['GOOGLE_PROTOBUF_NO_RTTI'] = True DEFINES['GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER'] = True @@ -550,19 +562,26 @@ IPDL_SOURCES += [ 'ipc/LayersMessages.ipdlh', 'ipc/LayersSurfaces.ipdlh', 'ipc/PAPZ.ipdl', - 'ipc/PAPZCTreeManager.ipdl', 'ipc/PAPZInputBridge.ipdl', + 'ipc/PTexture.ipdl', + 'ipc/PUiCompositorController.ipdl', + 'ipc/PVideoBridge.ipdl', +] + +PREPROCESSED_IPDL_SOURCES += [ + 'ipc/PAPZCTreeManager.ipdl', 'ipc/PCompositorBridge.ipdl', 'ipc/PCompositorManager.ipdl', 'ipc/PImageBridge.ipdl', 'ipc/PLayerTransaction.ipdl', - 'ipc/PTexture.ipdl', - 'ipc/PUiCompositorController.ipdl', - 'ipc/PVideoBridge.ipdl', - 'ipc/PWebRenderBridge.ipdl', - 'ipc/WebRenderMessages.ipdlh', ] +if CONFIG['MOZ_BUILD_WEBRENDER']: + IPDL_SOURCES += [ + 'ipc/PWebRenderBridge.ipdl', + 'ipc/WebRenderMessages.ipdlh', + ] + include('/ipc/chromium/chromium-config.mozbuild') if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index 442ab17afa..61c822065e 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -226,7 +226,11 @@ already_AddRefed CompositorOGL::CreateContext() { if (gfxEnv::LayersPreferEGL()) { printf_stderr("Trying GL layers...\n"); context = gl::GLContextProviderEGL::CreateForCompositorWidget( - mWidget, /* aWebRender */ false, /* aForceAccelerated */ false); + mWidget, +# ifdef MOZ_BUILD_WEBRENDER + /* aWebRender */ false, +# endif + /* aForceAccelerated */ false); } #endif @@ -245,7 +249,9 @@ already_AddRefed CompositorOGL::CreateContext() { if (!context) { context = gl::GLContextProvider::CreateForCompositorWidget( mWidget, +#ifdef MOZ_BUILD_WEBRENDER /* aWebRender */ false, +#endif gfxVars::RequiresAcceleratedGLContextForCompositorOGL()); } diff --git a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp index 74122d441a..2f9eb36670 100644 --- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp +++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp @@ -128,6 +128,7 @@ gfx::ColorRange MacIOSurfaceTextureHostOGL::GetColorRange() const { : gfx::ColorRange::LIMITED; } +#ifdef MOZ_BUILD_WEBRENDER void MacIOSurfaceTextureHostOGL::CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) { RefPtr texture = @@ -255,6 +256,7 @@ void MacIOSurfaceTextureHostOGL::PushDisplayItems( } } } +#endif } // namespace layers } // namespace mozilla diff --git a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h index 0b04d3e747..5caeffeaac 100644 --- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h +++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h @@ -61,6 +61,7 @@ class MacIOSurfaceTextureHostOGL : public TextureHost { MacIOSurface* GetMacIOSurface() override { return mSurface; } +#ifdef MOZ_BUILD_WEBRENDER void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; @@ -75,6 +76,7 @@ class MacIOSurfaceTextureHostOGL : public TextureHost { const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip, wr::ImageRendering aFilter, const Range& aImageKeys) override; +#endif gfx::YUVColorSpace GetYUVColorSpace() const override; gfx::ColorRange GetColorRange() const override; diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index 808d4d3c5a..85605ed971 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -14,8 +14,10 @@ #include "mozilla/gfx/BaseSize.h" // for BaseSize #include "mozilla/gfx/Logging.h" // for gfxCriticalError #include "mozilla/layers/ISurfaceAllocator.h" -#include "mozilla/webrender/RenderEGLImageTextureHost.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/RenderEGLImageTextureHost.h" +# include "mozilla/webrender/WebRenderAPI.h" +#endif #include "nsRegion.h" // for nsIntRegion #include "AndroidSurfaceTexture.h" #include "GfxTexturesReporter.h" // for GfxTexturesReporter @@ -622,6 +624,7 @@ void SurfaceTextureHost::DeallocateDeviceData() { } } +# ifdef MOZ_BUILD_WEBRENDER void SurfaceTextureHost::CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) { RefPtr texture = @@ -679,6 +682,7 @@ void SurfaceTextureHost::PushDisplayItems( } } } +# endif // MOZ_BUILD_WEBRENDER #endif // MOZ_WIDGET_ANDROID @@ -821,6 +825,7 @@ gfx::SurfaceFormat EGLImageTextureHost::GetFormat() const { : gfx::SurfaceFormat::UNKNOWN; } +#ifdef MOZ_BUILD_WEBRENDER void EGLImageTextureHost::CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) { RefPtr texture = @@ -859,6 +864,7 @@ void EGLImageTextureHost::PushDisplayItems( aBuilder.PushImage(aBounds, aClip, true, aFilter, aImageKeys[0], !(mFlags & TextureFlags::NON_PREMULTIPLIED)); } +#endif // diff --git a/gfx/layers/opengl/TextureHostOGL.h b/gfx/layers/opengl/TextureHostOGL.h index ead86b0314..39cec3e1d1 100644 --- a/gfx/layers/opengl/TextureHostOGL.h +++ b/gfx/layers/opengl/TextureHostOGL.h @@ -24,7 +24,9 @@ #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor #include "mozilla/layers/TextureHost.h" // for TextureHost, etc #include "mozilla/mozalloc.h" // for operator delete, etc -#include "mozilla/webrender/RenderThread.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/RenderThread.h" +#endif #include "nsCOMPtr.h" // for already_AddRefed #include "nsDebug.h" // for NS_WARNING #include "nsISupportsImpl.h" // for TextureImage::Release, etc @@ -425,6 +427,7 @@ class SurfaceTextureHost : public TextureHost { SurfaceTextureHost* AsSurfaceTextureHost() override { return this; } +# ifdef MOZ_BUILD_WEBRENDER void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; @@ -437,6 +440,7 @@ class SurfaceTextureHost : public TextureHost { const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip, wr::ImageRendering aFilter, const Range& aImageKeys) override; +# endif protected: bool EnsureAttached(); @@ -530,6 +534,7 @@ class EGLImageTextureHost final : public TextureHost { const char* Name() override { return "EGLImageTextureHost"; } +#ifdef MOZ_BUILD_WEBRENDER void CreateRenderTexture( const wr::ExternalImageId& aExternalImageId) override; @@ -542,6 +547,7 @@ class EGLImageTextureHost final : public TextureHost { const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip, wr::ImageRendering aFilter, const Range& aImageKeys) override; +#endif protected: const EGLImage mImage; diff --git a/gfx/moz.build b/gfx/moz.build index ba7d3bbffd..2fddbd3217 100644 --- a/gfx/moz.build +++ b/gfx/moz.build @@ -25,9 +25,12 @@ DIRS += [ 'thebes', 'ipc', 'config', - 'webrender_bindings', + ] +if CONFIG['MOZ_BUILD_WEBRENDER']: + DIRS += ['webrender_bindings'] + if CONFIG['MOZ_ENABLE_SKIA']: DIRS += ['skia'] diff --git a/gfx/thebes/DeviceManagerDx.cpp b/gfx/thebes/DeviceManagerDx.cpp index 24f2fa0651..59c3c5a556 100644 --- a/gfx/thebes/DeviceManagerDx.cpp +++ b/gfx/thebes/DeviceManagerDx.cpp @@ -104,7 +104,9 @@ bool DeviceManagerDx::LoadD3D11() { bool DeviceManagerDx::LoadDcomp() { MOZ_ASSERT(gfxConfig::GetFeature(Feature::D3D11_COMPOSITING).IsEnabled()); +#ifdef MOZ_BUILD_WEBRENDER MOZ_ASSERT(gfxVars::UseWebRender()); +#endif MOZ_ASSERT(gfxVars::UseWebRenderANGLE()); MOZ_ASSERT(gfxVars::UseWebRenderDCompWin()); @@ -142,9 +144,9 @@ void DeviceManagerDx::ReleaseD3D11() { #ifdef DEBUG static inline bool ProcessOwnsCompositor() { return XRE_GetProcessType() == GeckoProcessType_GPU || -#ifdef MOZ_VR +# ifdef MOZ_VR XRE_GetProcessType() == GeckoProcessType_VR || -#endif +# endif (XRE_IsParentProcess() && !gfxConfig::IsEnabled(Feature::GPU_PROCESS)); } #endif @@ -195,9 +197,10 @@ bool DeviceManagerDx::CreateCompositorDevices() { // Fallback from WR to D3D11 Non-WR compositor without re-creating gpu process // could happen when WR causes error. In this case, the attachments are loaded // synchronously. - if (!gfx::gfxVars::UseWebRender()) { +#ifdef MOZ_BUILD_WEBRENDER + if (!gfx::gfxVars::UseWebRender()) +#endif PreloadAttachmentsOnCompositorThread(); - } return true; } @@ -242,6 +245,7 @@ bool DeviceManagerDx::CreateVRDevice() { } #endif +#ifdef MOZ_BUILD_WEBRENDER void DeviceManagerDx::CreateDirectCompositionDevice() { if (!gfxVars::UseWebRenderDCompWin()) { return; @@ -276,6 +280,7 @@ void DeviceManagerDx::CreateDirectCompositionDevice() { mDirectCompositionDevice = compositionDevice; } +#endif void DeviceManagerDx::ImportDeviceInfo(const D3D11DeviceStatus& aDeviceStatus) { MOZ_ASSERT(!ProcessOwnsCompositor()); diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index 7bb4c4f5d4..623d7219aa 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -21,7 +21,9 @@ #include "mozilla/gfx/PathHelpers.h" #include "mozilla/gfx/DrawTargetTiled.h" #include -#include "TextDrawTarget.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "TextDrawTarget.h" +#endif #if XP_WIN # include "gfxWindowsPlatform.h" @@ -101,12 +103,14 @@ gfxContext::~gfxContext() { } } +#ifdef MOZ_BUILD_WEBRENDER mozilla::layout::TextDrawTarget* gfxContext::GetTextDrawer() { if (mDT->GetBackendType() == BackendType::WEBRENDER_TEXT) { return static_cast(&*mDT); } return nullptr; } +#endif void gfxContext::Save() { CurrentState().transform = mTransform; diff --git a/gfx/thebes/gfxContext.h b/gfx/thebes/gfxContext.h index ba75ed8f13..50dc914334 100644 --- a/gfx/thebes/gfxContext.h +++ b/gfx/thebes/gfxContext.h @@ -23,9 +23,12 @@ namespace mozilla { namespace gfx { struct RectCornerRadii; } // namespace gfx + +#ifdef MOZ_BUILD_WEBRENDER namespace layout { class TextDrawTarget; } // namespace layout +#endif } // namespace mozilla class ClipExporter; @@ -85,7 +88,9 @@ class gfxContext final { /** * Returns the DrawTarget if it's actually a TextDrawTarget. */ +#ifdef MOZ_BUILD_WEBRENDER mozilla::layout::TextDrawTarget* GetTextDrawer(); +#endif /** ** State diff --git a/gfx/thebes/gfxEnv.h b/gfx/thebes/gfxEnv.h index b760f76dc8..d4bf8dff39 100644 --- a/gfx/thebes/gfxEnv.h +++ b/gfx/thebes/gfxEnv.h @@ -33,8 +33,10 @@ class gfxEnv final { // Debugging inside of ContainerLayerComposite DECL_GFX_ENV("DUMP_DEBUG", DumpDebug); +#ifdef MOZ_BUILD_WEBRENDER // Use WR recording DECL_GFX_ENV("ENABLE_WR_RECORDING", EnableWebRenderRecording); +#endif // OpenGL shader debugging in OGLShaderProgram, in DEBUG only DECL_GFX_ENV("MOZ_DEBUG_SHADERS", DebugShaders); diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 380c68c8d0..3a6d3525fa 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -42,7 +42,9 @@ #include "gfxMathTable.h" #include "gfxSVGGlyphs.h" #include "gfx2DGlue.h" -#include "TextDrawTarget.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "TextDrawTarget.h" +#endif #include "GreekCasing.h" @@ -1913,12 +1915,17 @@ void gfxFont::DrawOneGlyph(uint32_t aGlyphID, const gfx::Point& aPt, if (FC == FontComplexityT::ComplexFont) { const FontDrawParams& fontParams(aBuffer.mFontParams); +#ifdef MOZ_BUILD_WEBRENDER auto* textDrawer = runParams.context->GetTextDrawer(); +#endif gfxContextMatrixAutoSaveRestore matrixRestore; - if (fontParams.obliqueSkew != 0.0f && fontParams.isVerticalFont && - !textDrawer) { + if (fontParams.obliqueSkew != 0.0f && fontParams.isVerticalFont +#ifdef MOZ_BUILD_WEBRENDER + && !textDrawer +#endif + ) { // We have to flush each glyph individually when doing // synthetic-oblique for vertical-upright text, because // the skew transform needs to be applied to a separate @@ -1940,16 +1947,22 @@ void gfxFont::DrawOneGlyph(uint32_t aGlyphID, const gfx::Point& aPt, NS_WARNING_ASSERTION( runParams.drawMode != DrawMode::GLYPH_PATH, "Rendering SVG glyph despite request for glyph path"); - if (RenderSVGGlyph(runParams.context, textDrawer, devPt, aGlyphID, - fontParams.contextPaint, runParams.callbacks, - *aEmittedGlyphs)) { + if (RenderSVGGlyph(runParams.context, +#ifdef MOZ_BUILD_WEBRENDER + textDrawer, +#endif + devPt, aGlyphID, fontParams.contextPaint, + runParams.callbacks, *aEmittedGlyphs)) { return; } } if (fontParams.haveColorGlyphs && !gfxPlatform::GetPlatform()->HasNativeColrFontSupport() && - RenderColorGlyph(runParams.dt, runParams.context, textDrawer, + RenderColorGlyph(runParams.dt, runParams.context, +#ifdef MOZ_BUILD_WEBRENDER + textDrawer, +#endif fontParams.scaledFont, fontParams.drawOptions, devPt, aGlyphID)) { return; @@ -1967,8 +1980,11 @@ void gfxFont::DrawOneGlyph(uint32_t aGlyphID, const gfx::Point& aPt, aBuffer.OutputGlyph(aGlyphID, devPt); } - if (fontParams.obliqueSkew != 0.0f && fontParams.isVerticalFont && - !textDrawer) { + if (fontParams.obliqueSkew != 0.0f && fontParams.isVerticalFont +#ifdef MOZ_BUILD_WEBRENDER + && !textDrawer +#endif + ) { aBuffer.Flush(); } } else { @@ -1986,9 +2002,10 @@ bool gfxFont::DrawMissingGlyph(const TextRunDrawParams& aRunParams, // we don't have to draw the hexbox for them. float advance = aDetails->mAdvance; if (aRunParams.drawMode != DrawMode::GLYPH_PATH && advance > 0) { - auto* textDrawer = aRunParams.context->GetTextDrawer(); const Matrix* matPtr = nullptr; Matrix mat; +#ifdef MOZ_BUILD_WEBRENDER + auto* textDrawer = aRunParams.context->GetTextDrawer(); if (textDrawer) { // Generate an orientation matrix for the current writing mode wr::FontInstanceFlags flags = textDrawer->GetWRGlyphFlags(); @@ -2000,6 +2017,7 @@ bool gfxFont::DrawMissingGlyph(const TextRunDrawParams& aRunParams, flags & wr::FontInstanceFlags::FLIP_Y ? -1.0f : 1.0f); matPtr = &mat; } +#endif Point pt(Float(ToDeviceUnits(aPt.x, aRunParams.devPerApp)), Float(ToDeviceUnits(aPt.y, aRunParams.devPerApp))); @@ -2016,8 +2034,11 @@ bool gfxFont::DrawMissingGlyph(const TextRunDrawParams& aRunParams, // of the drawTarget's transform, we need to undo // this before drawing the hexbox. (Bug 983985) gfxContextMatrixAutoSaveRestore matrixRestore; - if (aFontParams.obliqueSkew != 0.0f && !aFontParams.isVerticalFont && - !textDrawer) { + if (aFontParams.obliqueSkew != 0.0f && !aFontParams.isVerticalFont +#ifdef MOZ_BUILD_WEBRENDER + && !textDrawer +#endif + ) { matrixRestore.SetContext(aRunParams.context); gfx::Matrix mat = aRunParams.context->CurrentMatrix() @@ -2096,22 +2117,27 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd, return; } +#ifdef MOZ_BUILD_WEBRENDER auto* textDrawer = aRunParams.context->GetTextDrawer(); +#endif fontParams.obliqueSkew = SkewForSyntheticOblique(); fontParams.haveSVGGlyphs = GetFontEntry()->TryGetSVGData(this); fontParams.haveColorGlyphs = GetFontEntry()->TryGetColorGlyphs(); fontParams.contextPaint = aRunParams.runContextPaint; +#ifdef MOZ_BUILD_WEBRENDER if (textDrawer) { fontParams.isVerticalFont = aRunParams.isVerticalRun; } else { +#endif fontParams.isVerticalFont = aOrientation == gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_UPRIGHT; +#ifdef MOZ_BUILD_WEBRENDER } +#endif gfxContextMatrixAutoSaveRestore matrixRestore; - layout::TextDrawTarget::AutoRestoreWRGlyphFlags glyphFlagsRestore; // Save the current baseline offset for restoring later, in case it is // modified. @@ -2142,6 +2168,8 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd, // If we're rendering a sideways run, we need to push a rotation transform to // the context. if (sidewaysDir != 0.0f) { +#ifdef MOZ_BUILD_WEBRENDER + layout::TextDrawTarget::AutoRestoreWRGlyphFlags glyphFlagsRestore; if (textDrawer) { // For WebRender, we can't use a DrawTarget transform and must instead use // flags that locally transform the glyph, without affecting the glyph @@ -2179,6 +2207,7 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd, ? &kSidewaysLeft : &kSidewaysRight; } else { +#endif // For non-WebRender targets, just push a rotation transform. matrixRestore.SetContext(aRunParams.context); gfxPoint p(aPt->x * aRunParams.devPerApp, aPt->y * aRunParams.devPerApp); @@ -2193,7 +2222,9 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd, PreTranslate(-p); // undo the translation aRunParams.context->SetMatrixDouble(mat); +#ifdef MOZ_BUILD_WEBRENDER } +#endif // If we're drawing rotated horizontal text for an element styled // text-orientation:mixed, the dominant baseline will be vertical- @@ -2211,8 +2242,11 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd, } } - if (fontParams.obliqueSkew != 0.0f && !fontParams.isVerticalFont && - !textDrawer) { + if (fontParams.obliqueSkew != 0.0f && !fontParams.isVerticalFont +#ifdef MOZ_BUILD_WEBRENDER + && !textDrawer +#endif + ) { // Adjust matrix for synthetic-oblique, except if we're doing vertical- // upright text, in which case this will be handled for each glyph // individually in DrawOneGlyph. @@ -2243,7 +2277,11 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd, // (these values are only needed if IsSyntheticBold() is true) // WebRender handles synthetic bold independently via FontInstanceFlags, // so just ignore requests in that case. - if (IsSyntheticBold() && !textDrawer) { + if (IsSyntheticBold() +#ifdef MOZ_BUILD_WEBRENDER + && !textDrawer +#endif + ) { gfx::Float xscale = CalcXScale(aRunParams.context->GetDrawTarget()); fontParams.synBoldOnePixelOffset = aRunParams.direction * xscale; if (xscale != 0.0) { @@ -2280,8 +2318,11 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd, GlyphBufferAzure buffer(aRunParams, fontParams); if (fontParams.haveSVGGlyphs || fontParams.haveColorGlyphs || fontParams.extraStrikes || - (fontParams.obliqueSkew != 0.0f && fontParams.isVerticalFont && - !textDrawer)) { + (fontParams.obliqueSkew != 0.0f && fontParams.isVerticalFont +#ifdef MOZ_BUILD_WEBRENDER + && !textDrawer +#endif + )) { if (aRunParams.spacing) { emittedGlyphs = DrawGlyphs( @@ -2313,7 +2354,11 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd, aRunParams.dt->SetTransform(oldMat); aRunParams.dt->SetPermitSubpixelAA(oldSubpixelAA); - if (sidewaysDir != 0.0f && !textDrawer) { + if (sidewaysDir != 0.0f +#ifdef MOZ_BUILD_WEBRENDER + && !textDrawer +#endif + ) { // Adjust updated aPt to account for the transform we were using. // The advance happened horizontally in local-space, but the transformed // sideways advance is actually vertical, with sign depending on the @@ -2324,19 +2369,23 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd, } bool gfxFont::RenderSVGGlyph(gfxContext* aContext, +#ifdef MOZ_BUILD_WEBRENDER layout::TextDrawTarget* aTextDrawer, +#endif gfx::Point aPoint, uint32_t aGlyphId, SVGContextPaint* aContextPaint) const { if (!GetFontEntry()->HasSVGGlyph(aGlyphId)) { return false; } +#ifdef MOZ_BUILD_WEBRENDER if (aTextDrawer) { // WebRender doesn't support SVG Glyphs. // (pretend to succeed, output doesn't matter, we will emit a blob) aTextDrawer->FoundUnsupportedFeature(); return true; } +#endif const gfxFloat devUnitsPerSVGUnit = GetAdjustedSize() / GetFontEntry()->UnitsPerEm(); @@ -2354,7 +2403,9 @@ bool gfxFont::RenderSVGGlyph(gfxContext* aContext, } bool gfxFont::RenderSVGGlyph(gfxContext* aContext, +#ifdef MOZ_BUILD_WEBRENDER layout::TextDrawTarget* aTextDrawer, +#endif gfx::Point aPoint, uint32_t aGlyphId, SVGContextPaint* aContextPaint, gfxTextRunDrawCallbacks* aCallbacks, @@ -2363,11 +2414,17 @@ bool gfxFont::RenderSVGGlyph(gfxContext* aContext, aCallbacks->NotifyGlyphPathEmitted(); aEmittedGlyphs = false; } - return RenderSVGGlyph(aContext, aTextDrawer, aPoint, aGlyphId, aContextPaint); + return RenderSVGGlyph(aContext, +#ifdef MOZ_BUILD_WEBRENDER + aTextDrawer, +#endif + aPoint, aGlyphId, aContextPaint); } bool gfxFont::RenderColorGlyph(DrawTarget* aDrawTarget, gfxContext* aContext, +#ifdef MOZ_BUILD_WEBRENDER layout::TextDrawTarget* aTextDrawer, +#endif mozilla::gfx::ScaledFont* scaledFont, mozilla::gfx::DrawOptions aDrawOptions, const mozilla::gfx::Point& aPoint, @@ -2386,6 +2443,7 @@ bool gfxFont::RenderColorGlyph(DrawTarget* aDrawTarget, gfxContext* aContext, // Default to opaque rendering (non-webrender applies alpha with a layer) float alpha = 1.0; +#ifdef MOZ_BUILD_WEBRENDER if (aTextDrawer) { // defaultColor is the one that comes from CSS, so it has transparency info. bool hasComplexTransparency = 0.f < defaultColor.a && defaultColor.a < 1.f; @@ -2405,6 +2463,7 @@ bool gfxFont::RenderColorGlyph(DrawTarget* aDrawTarget, gfxContext* aContext, // might be wrapped in a shadow that uses the text run's glyphs. alpha = defaultColor.a; } +#endif for (uint32_t layerIndex = 0; layerIndex < layerGlyphs.Length(); layerIndex++) { diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index 8655a13831..c65a233f65 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -34,7 +34,9 @@ #include "nsColor.h" #include "nsFontMetrics.h" #include "mozilla/ServoUtils.h" -#include "TextDrawTarget.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "TextDrawTarget.h" +#endif typedef struct _cairo cairo_t; typedef struct _cairo_scaled_font cairo_scaled_font_t; @@ -2148,18 +2150,24 @@ class gfxFont { void SanitizeMetrics(Metrics* aMetrics, bool aIsBadUnderlineFont); bool RenderSVGGlyph(gfxContext* aContext, +#ifdef MOZ_BUILD_WEBRENDER mozilla::layout::TextDrawTarget* aTextDrawer, +#endif mozilla::gfx::Point aPoint, uint32_t aGlyphId, SVGContextPaint* aContextPaint) const; bool RenderSVGGlyph(gfxContext* aContext, +#ifdef MOZ_BUILD_WEBRENDER mozilla::layout::TextDrawTarget* aTextDrawer, +#endif mozilla::gfx::Point aPoint, uint32_t aGlyphId, SVGContextPaint* aContextPaint, gfxTextRunDrawCallbacks* aCallbacks, bool& aEmittedGlyphs) const; bool RenderColorGlyph(DrawTarget* aDrawTarget, gfxContext* aContext, +#ifdef MOZ_BUILD_WEBRENDER mozilla::layout::TextDrawTarget* aTextDrawer, +#endif mozilla::gfx::ScaledFont* scaledFont, mozilla::gfx::DrawOptions drawOptions, const mozilla::gfx::Point& aPoint, diff --git a/gfx/thebes/gfxFontMissingGlyphs.cpp b/gfx/thebes/gfxFontMissingGlyphs.cpp index e3be66fe8b..2fd20d10c5 100644 --- a/gfx/thebes/gfxFontMissingGlyphs.cpp +++ b/gfx/thebes/gfxFontMissingGlyphs.cpp @@ -12,7 +12,9 @@ #include "mozilla/RefPtr.h" #include "nsDeviceContext.h" #include "nsLayoutUtils.h" -#include "TextDrawTarget.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "TextDrawTarget.h" +#endif using namespace mozilla; using namespace mozilla::gfx; @@ -141,6 +143,7 @@ static void PurgeGlyphAtlas() { gGlyphMask = nullptr; } +# ifdef MOZ_BUILD_WEBRENDER // WebRender layer manager user data that will get signaled when the layer // manager is destroyed. class WRUserData : public layers::LayerUserData, @@ -317,11 +320,13 @@ static already_AddRefed GetWRGlyphAtlas(DrawTarget& aDrawTarget, } return atlas.forget(); } +# endif // MOZ_BUILD_WEBRENDER static void DrawHexChar(uint32_t aDigit, Float aLeft, Float aTop, DrawTarget& aDrawTarget, SourceSurface* aAtlas, const Color& aColor, const Matrix* aMat = nullptr) { Rect dest(aLeft, aTop, MINIFONT_WIDTH, MINIFONT_HEIGHT); +# ifdef MOZ_BUILD_WEBRENDER if (aDrawTarget.GetBackendType() == BackendType::WEBRENDER_TEXT) { // For WR, we need to get the image key assigned to the given WR layer // manager for referencing the image. @@ -353,6 +358,7 @@ static void DrawHexChar(uint32_t aDigit, Float aLeft, Float aTop, tdt->PushImage(key, bounds, dest, wr::ImageRendering::Pixelated, wr::ToColorF(aColor)); } else { +# endif // For the normal case, just draw the given digit from the atlas. Point // filtering is used to ensure the mini-font rectangles stay sharp with any // scaling. Handle any transparency here as well. @@ -361,12 +367,16 @@ static void DrawHexChar(uint32_t aDigit, Float aLeft, Float aTop, Rect(aDigit * MINIFONT_WIDTH, 0, MINIFONT_WIDTH, MINIFONT_HEIGHT), DrawSurfaceOptions(SamplingFilter::POINT), DrawOptions(aColor.a, CompositionOp::OP_OVER, AntialiasMode::NONE)); +# ifdef MOZ_BUILD_WEBRENDER } +# endif } void gfxFontMissingGlyphs::Purge() { PurgeGlyphAtlas(); +# ifdef MOZ_BUILD_WEBRENDER PurgeWRGlyphAtlas(); +# endif } #else // MOZ_GFX_OPTIMIZE_MOBILE @@ -418,9 +428,12 @@ void gfxFontMissingGlyphs::DrawMissingGlyph(uint32_t aChar, const Rect& aRect, #ifndef MOZ_GFX_OPTIMIZE_MOBILE RefPtr atlas = +# ifdef MOZ_BUILD_WEBRENDER aDrawTarget.GetBackendType() == BackendType::WEBRENDER_TEXT ? GetWRGlyphAtlas(aDrawTarget, aMat) - : GetGlyphAtlas(color); + : +# endif + GetGlyphAtlas(color); if (!atlas) { return; } diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 4393695c71..2cc96c4fe4 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -4,16 +4,18 @@ #include "mozilla/FontPropertyTypes.h" #include "mozilla/RDDProcessManager.h" -#include "mozilla/image/ImageMemoryReporter.h" #include "mozilla/layers/CompositorManagerChild.h" #include "mozilla/layers/CompositorThread.h" #include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/ISurfaceAllocator.h" // for GfxMemoryImageReporter #include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/TiledContentClient.h" -#include "mozilla/webrender/RenderThread.h" -#include "mozilla/webrender/WebRenderAPI.h" -#include "mozilla/webrender/webrender_ffi.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/image/ImageMemoryReporter.h" +# include "mozilla/webrender/RenderThread.h" +# include "mozilla/webrender/WebRenderAPI.h" +# include "mozilla/webrender/webrender_ffi.h" +#endif #include "mozilla/layers/PaintThread.h" #include "mozilla/gfx/gfxVars.h" #include "mozilla/gfx/GPUProcessManager.h" @@ -452,6 +454,7 @@ void gfxPlatform::OnMemoryPressure(layers::MemoryPressureReason aWhy) { gfxGradientCache::PurgeAllCaches(); gfxFontMissingGlyphs::Purge(); PurgeSkiaFontCache(); +#ifdef MOZ_BUILD_WEBRENDER if (XRE_IsParentProcess()) { layers::CompositorManagerChild* manager = CompositorManagerChild::GetInstance(); @@ -459,6 +462,7 @@ void gfxPlatform::OnMemoryPressure(layers::MemoryPressureReason aWhy) { manager->SendNotifyMemoryPressure(); } } +#endif } gfxPlatform::gfxPlatform() @@ -553,15 +557,15 @@ void RecordingPrefChanged(const char* aPrefName, void* aClosure) { Factory::SetGlobalEventRecorder(nullptr); } } - -#define WR_DEBUG_PREF "gfx.webrender.debug" +#ifdef MOZ_BUILD_WEBRENDER +# define WR_DEBUG_PREF "gfx.webrender.debug" static void WebRenderDebugPrefChangeCallback(const char* aPrefName, void*) { wr::DebugFlags flags{0}; -#define GFX_WEBRENDER_DEBUG(suffix, bit) \ - if (Preferences::GetBool(WR_DEBUG_PREF suffix, false)) { \ - flags |= (bit); \ - } +# define GFX_WEBRENDER_DEBUG(suffix, bit) \ + if (Preferences::GetBool(WR_DEBUG_PREF suffix, false)) { \ + flags |= (bit); \ + } GFX_WEBRENDER_DEBUG(".profiler", wr::DebugFlags::PROFILER_DBG) GFX_WEBRENDER_DEBUG(".render-targets", wr::DebugFlags::RENDER_TARGET_DBG) @@ -598,10 +602,11 @@ static void WebRenderDebugPrefChangeCallback(const char* aPrefName, void*) { wr::DebugFlags::DISABLE_GRADIENT_PRIMS) GFX_WEBRENDER_DEBUG(".obscure-images", wr::DebugFlags::OBSCURE_IMAGES) GFX_WEBRENDER_DEBUG(".glyph-flashing", wr::DebugFlags::GLYPH_FLASHING) -#undef GFX_WEBRENDER_DEBUG +# undef GFX_WEBRENDER_DEBUG gfx::gfxVars::SetWebRenderDebugFlags(flags.bits); } +#endif // MOZ_BUILD_WEBRENDER #if defined(USE_SKIA) static uint32_t GetSkiaGlyphCacheSize() { @@ -625,6 +630,7 @@ static uint32_t GetSkiaGlyphCacheSize() { } #endif +#ifdef MOZ_BUILD_WEBRENDER class WebRenderMemoryReporter final : public nsIMemoryReporter { public: NS_DECL_ISUPPORTS @@ -698,6 +704,7 @@ static void FinishAsyncMemoryReport() { imgr->EndReport(); } } +#endif // MOZ_BUILD_WEBRENDER // clang-format off // (For some reason, clang-format gets the second macro right, but totally mangles the first). @@ -710,6 +717,7 @@ static void FinishAsyncMemoryReport() { helper.Report(aReport.interning.data_stores.id, \ "interning/" #id "/data-stores"); +#ifdef MOZ_BUILD_WEBRENDER NS_IMPL_ISUPPORTS(WebRenderMemoryReporter, nsIMemoryReporter) NS_IMETHODIMP @@ -759,8 +767,8 @@ WebRenderMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport, return NS_OK; } -#undef REPORT_INTERNER -#undef REPORT_DATA_STORE +# undef REPORT_INTERNER +# undef REPORT_DATA_STORE static const char* const WR_ROLLOUT_PREF = "gfx.webrender.all.qualified"; static const bool WR_ROLLOUT_PREF_DEFAULTVALUE = true; @@ -837,6 +845,7 @@ class WrRolloutPrefShutdownSaver : public nsIObserver { Preferences::SetBool(WR_ROLLOUT_DEFAULT_PREF, defaultValue); } }; +#endif // MOZ_BUILD_WEBRENDER static void FrameRatePrefChanged(const char* aPref, void*) { int32_t newRate = gfxPlatform::ForceSoftwareVsync() @@ -848,7 +857,9 @@ static void FrameRatePrefChanged(const char* aPref, void*) { } } +#ifdef MOZ_BUILD_WEBRENDER NS_IMPL_ISUPPORTS(WrRolloutPrefShutdownSaver, nsIObserver) +#endif void gfxPlatform::Init() { MOZ_RELEASE_ASSERT(!XRE_IsGPUProcess(), "GFX: Not allowed in GPU process."); @@ -892,7 +903,9 @@ void gfxPlatform::Init() { } if (XRE_IsParentProcess()) { +#ifdef MOZ_BUILD_WEBRENDER WrRolloutPrefShutdownSaver::AddShutdownObserver(); +#endif nsCOMPtr profDir; nsresult rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DIR_STARTUP, @@ -980,15 +993,19 @@ void gfxPlatform::Init() { #endif gPlatform->PopulateScreenInfo(); gPlatform->InitAcceleration(); +#ifdef MOZ_BUILD_WEBRENDER gPlatform->InitWebRenderConfig(); +#endif +#ifdef MOZ_BUILD_WEBRENDER // When using WebRender, we defer initialization of the D3D11 devices until // the (rare) cases where they're used. Note that the GPU process where // WebRender runs doesn't initialize gfxPlatform and performs explicit // initialization of the bits it needs. - if (!UseWebRender()) { + if (!UseWebRender()) +#endif gPlatform->EnsureDevicesInitialized(); - } + gPlatform->InitOMTPConfig(); if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) { @@ -1075,9 +1092,11 @@ void gfxPlatform::Init() { } RegisterStrongMemoryReporter(new GfxMemoryImageReporter()); +#ifdef MOZ_BUILD_WEBRENDER if (XRE_IsParentProcess() && UseWebRender()) { RegisterStrongAsyncMemoryReporter(new WebRenderMemoryReporter()); } +#endif #ifdef USE_SKIA RegisterStrongMemoryReporter(new SkMemoryReporter()); @@ -1183,8 +1202,10 @@ bool gfxPlatform::IsHeadless() { return headless; } +#ifdef MOZ_BUILD_WEBRENDER /* static */ bool gfxPlatform::UseWebRender() { return gfx::gfxVars::UseWebRender(); } +#endif static bool sLayersIPCIsUp = false; @@ -1288,10 +1309,12 @@ void gfxPlatform::InitLayersIPC() { } if (XRE_IsParentProcess()) { +#ifdef MOZ_BUILD_WEBRENDER if (!gfxConfig::IsEnabled(Feature::GPU_PROCESS) && UseWebRender()) { wr::RenderThread::Start(); image::ImageMemoryReporter::InitForWebRender(); } +#endif layers::CompositorThreadHolder::Start(); } @@ -1328,6 +1351,7 @@ void gfxPlatform::ShutdownLayersIPC() { layers::ImageBridgeChild::ShutDown(); // This has to happen after shutting down the child protocols. layers::CompositorThreadHolder::Shutdown(); +#ifdef MOZ_BUILD_WEBRENDER image::ImageMemoryReporter::ShutdownForWebRender(); // There is a case that RenderThread exists when UseWebRender() is // false. This could happen when WebRender was fallbacked to compositor. @@ -1337,6 +1361,7 @@ void gfxPlatform::ShutdownLayersIPC() { Preferences::UnregisterCallback(WebRenderDebugPrefChangeCallback, WR_DEBUG_PREF); } +#endif } else { // TODO: There are other kind of processes and we should make sure gfx @@ -2516,6 +2541,7 @@ void gfxPlatform::InitCompositorAccelerationPrefs() { } } +#ifdef MOZ_BUILD_WEBRENDER /*static*/ bool gfxPlatform::WebRenderPrefEnabled() { return StaticPrefs::gfx_webrender_all_AtStartup() || @@ -2630,19 +2656,19 @@ static void UpdateWRQualificationForAMD(FeatureState& aFeature, // we have a desktop CAYMAN, SI, CIK, VI, or GFX9 device. -#if defined(XP_WIN) +# if defined(XP_WIN) // These devices got WR in release Firefox 68. *aOutGuardedByQualifiedPref = false; -#elif defined(NIGHTLY_BUILD) +# elif defined(NIGHTLY_BUILD) // Qualify on Linux Nightly, but leave *aOutGuardedByQualifiedPref as true // to indicate users on release don't have it yet, and it's still guarded // by the qualified pref. -#else +# else // Disqualify everywhere else aFeature.Disable(FeatureStatus::BlockedReleaseChannelAMD, "Release channel and AMD", NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_AMD")); -#endif +# endif } static void UpdateWRQualificationForIntel(FeatureState& aFeature, @@ -2747,20 +2773,20 @@ static void UpdateWRQualificationForIntel(FeatureState& aFeature, // Performance is not great on 4k screens with WebRender. // Disable it for now on all release platforms, and also on Linux // nightly. We only allow it on Windows nightly. -#if defined(XP_WIN) && defined(NIGHTLY_BUILD) +# if defined(XP_WIN) && defined(NIGHTLY_BUILD) // Windows nightly, so don't do screen size checks -#else +# else // Windows release, Linux nightly, Linux release. Do screen size // checks. (macOS is still completely blocked by the blocklist). // On Windows release, we only allow really small screens (sub-WUXGA). On // Linux we allow medium size screens as well (anything sub-4k). -# if defined(XP_WIN) +# if defined(XP_WIN) // Allow up to WUXGA on Windows release const int64_t kMaxPixels = 1920 * 1200; // WUXGA -# else +# else // Allow up to 4k on Linux const int64_t kMaxPixels = 3440 * 1440; // UWQHD -# endif +# endif if (aScreenPixels > kMaxPixels) { aFeature.Disable( FeatureStatus::BlockedScreenTooLarge, "Screen size too large", @@ -2772,19 +2798,19 @@ static void UpdateWRQualificationForIntel(FeatureState& aFeature, NS_LITERAL_CSTRING("FEATURE_FAILURE_SCREEN_SIZE_UNKNOWN")); return; } -#endif +# endif -#if (defined(XP_WIN) || (defined(MOZ_WIDGET_GTK) && defined(NIGHTLY_BUILD))) +# if (defined(XP_WIN) || (defined(MOZ_WIDGET_GTK) && defined(NIGHTLY_BUILD))) // Qualify Intel graphics cards on Windows to release and on Linux nightly // (subject to device whitelist and screen size checks above). // Leave *aOutGuardedByQualifiedPref as true to indicate no existing // release users have this yet, and it's still guarded by the qualified pref. -#else +# else // Disqualify everywhere else aFeature.Disable(FeatureStatus::BlockedReleaseChannelIntel, "Release channel and Intel", NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_INTEL")); -#endif +# endif } static FeatureState& WebRenderHardwareQualificationStatus( @@ -2859,11 +2885,11 @@ static FeatureState& WebRenderHardwareQualificationStatus( // We leave checking the battery for last because we would like to know // which users were denied WebRender only because they have a battery. if (aHasBattery) { -#ifndef XP_WIN +# ifndef XP_WIN // aHasBattery is only ever true on Windows, we don't check it on other // platforms. MOZ_ASSERT(false); -#endif +# endif // We never released WR to the battery populations, so let's keep the pref // guard for these populations. That way we can do a gradual rollout to // the battery population using the pref. @@ -2872,12 +2898,12 @@ static FeatureState& WebRenderHardwareQualificationStatus( // if we have a battery, ignore it if the screen is small enough. const int64_t kMaxPixelsBattery = 1920 * 1200; // WUXGA if (aScreenPixels > 0 && aScreenPixels <= kMaxPixelsBattery) { -#ifndef NIGHTLY_BUILD +# ifndef NIGHTLY_BUILD featureWebRenderQualified.Disable( FeatureStatus::BlockedReleaseChannelBattery, "Release channel and battery", NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_BATTERY")); -#endif // !NIGHTLY_BUILD +# endif // !NIGHTLY_BUILD } else { featureWebRenderQualified.Disable( FeatureStatus::BlockedHasBattery, "Has battery", @@ -2960,13 +2986,13 @@ void gfxPlatform::InitWebRenderConfig() { } // WebRender relies on the GPU process when on Windows -#ifdef XP_WIN +# ifdef XP_WIN if (!gfxConfig::IsEnabled(Feature::GPU_PROCESS)) { featureWebRender.ForceDisable( FeatureStatus::UnavailableNoGpuProcess, "GPU Process is disabled", NS_LITERAL_CSTRING("FEATURE_FAILURE_GPU_PROCESS_DISABLED")); } -#endif +# endif if (InSafeMode()) { featureWebRender.ForceDisable( @@ -2974,7 +3000,7 @@ void gfxPlatform::InitWebRenderConfig() { NS_LITERAL_CSTRING("FEATURE_FAILURE_SAFE_MODE")); } -#ifdef XP_WIN +# ifdef XP_WIN if (Preferences::GetBool("gfx.webrender.force-angle", false)) { if (!gfxConfig::IsEnabled(Feature::D3D11_HW_ANGLE)) { featureWebRender.ForceDisable( @@ -2984,21 +3010,21 @@ void gfxPlatform::InitWebRenderConfig() { gfxVars::SetUseWebRenderANGLE(gfxConfig::IsEnabled(Feature::WEBRENDER)); } } -#endif +# endif if (Preferences::GetBool("gfx.webrender.program-binary-disk", false)) { gfxVars::SetUseWebRenderProgramBinaryDisk( gfxConfig::IsEnabled(Feature::WEBRENDER)); } -#ifdef MOZ_WIDGET_ANDROID +# ifdef MOZ_WIDGET_ANDROID if (jni::IsFennec()) { featureWebRender.ForceDisable( FeatureStatus::Unavailable, "WebRender not ready for use on non-e10s Android", NS_LITERAL_CSTRING("FEATURE_FAILURE_ANDROID")); } -#endif +# endif // gfxFeature is not usable in the GPU process, so we use gfxVars to transmit // this feature @@ -3011,7 +3037,7 @@ void gfxPlatform::InitWebRenderConfig() { WebRenderDebugPrefChangeCallback, WR_DEBUG_PREF); } } -#if defined(MOZ_WIDGET_GTK) +# if defined(MOZ_WIDGET_GTK) else if (gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) { // Hardware compositing should be disabled by default if we aren't using // WebRender. We had to check if it is enabled at all, because it may @@ -3020,9 +3046,9 @@ void gfxPlatform::InitWebRenderConfig() { gfxConfig::Disable(Feature::HW_COMPOSITING, FeatureStatus::Blocked, "Acceleration blocked by platform"); } -#endif +# endif -#ifdef XP_WIN +# ifdef XP_WIN if (Preferences::GetBool("gfx.webrender.flip-sequential", false)) { // XXX relax win version to windows 8. if (IsWin10OrLater() && UseWebRender() && gfxVars::UseWebRenderANGLE()) { @@ -3041,15 +3067,17 @@ void gfxPlatform::InitWebRenderConfig() { gfxVars::SetUseWebRenderTripleBufferingWin(true); } } -#endif +# endif // Set features that affect WR's RendererOptions - gfxVars::SetUseGLSwizzle(IsFeatureSupported(nsIGfxInfo::FEATURE_GL_SWIZZLE, true)); + gfxVars::SetUseGLSwizzle( + IsFeatureSupported(nsIGfxInfo::FEATURE_GL_SWIZZLE, true)); // The RemoveShaderCacheFromDiskIfNecessary() needs to be called after // WebRenderConfig initialization. gfxUtils::RemoveShaderCacheFromDiskIfNecessary(); } +#endif // MOZ_BUILD_WEBRENDER void gfxPlatform::InitOMTPConfig() { ScopedGfxFeatureReporter reporter("OMTP"); @@ -3445,6 +3473,7 @@ void gfxPlatform::NotifyCompositorCreated(LayersBackend aBackend) { })); } +#ifdef MOZ_BUILD_WEBRENDER /* static */ void gfxPlatform::NotifyGPUProcessDisabled() { if (gfxConfig::IsEnabled(Feature::WEBRENDER)) { @@ -3455,6 +3484,7 @@ void gfxPlatform::NotifyGPUProcessDisabled() { gfxVars::SetUseWebRender(false); } } +#endif void gfxPlatform::FetchAndImportContentDeviceData() { MOZ_ASSERT(XRE_IsContentProcess()); diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index f53a366a4b..236cfe1293 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -202,7 +202,9 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener { static bool IsHeadless(); +#ifdef MOZ_BUILD_WEBRENDER static bool UseWebRender(); +#endif /** * Create an offscreen surface of the given dimensions @@ -673,7 +675,9 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener { */ static bool PerfWarnings(); +#ifdef MOZ_BUILD_WEBRENDER static void NotifyGPUProcessDisabled(); +#endif void NotifyCompositorCreated(mozilla::layers::LayersBackend aBackend); mozilla::layers::LayersBackend GetCompositorBackend() const { @@ -718,10 +722,12 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener { bool HasNativeColrFontSupport() const { return mHasNativeColrFontSupport; } +#ifdef MOZ_BUILD_WEBRENDER // you probably want to use gfxVars::UseWebRender() instead of this static bool WebRenderPrefEnabled(); // you probably want to use gfxVars::UseWebRender() instead of this static bool WebRenderEnvvarEnabled(); +#endif void NotifyFrameStats(nsTArray&& aFrameStats); @@ -740,7 +746,9 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener { virtual bool HasBattery() { return false; } virtual void InitAcceleration(); +#ifdef MOZ_BUILD_WEBRENDER virtual void InitWebRenderConfig(); +#endif /** * Called immediately before deleting the gfxPlatform object. diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp index 7ebfefd613..b14726354f 100644 --- a/gfx/thebes/gfxTextRun.cpp +++ b/gfx/thebes/gfxTextRun.cpp @@ -23,7 +23,9 @@ #include "mozilla/gfx/Logging.h" // for gfxCriticalError #include "mozilla/UniquePtr.h" #include "mozilla/Unused.h" -#include "TextDrawTarget.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "TextDrawTarget.h" +#endif #ifdef XP_WIN # include "gfxWindowsPlatform.h" @@ -551,8 +553,11 @@ void gfxTextRun::Draw(Range aRange, gfx::Point aPt, bool skipDrawing = mSkipDrawing; if (aParams.drawMode & DrawMode::GLYPH_FILL) { Color currentColor; - if (aParams.context->GetDeviceColor(currentColor) && currentColor.a == 0 && - !aParams.context->GetTextDrawer()) { + if (aParams.context->GetDeviceColor(currentColor) && currentColor.a == 0 +#ifdef MOZ_BUILD_WEBRENDER + && !aParams.context->GetTextDrawer() +#endif + ) { skipDrawing = true; } } @@ -581,8 +586,11 @@ void gfxTextRun::Draw(Range aRange, gfx::Point aPt, if (aParams.drawMode & DrawMode::GLYPH_FILL && aParams.context->HasNonOpaqueNonTransparentColor(currentColor) && - HasSyntheticBoldOrColor(this, aRange) && - !aParams.context->GetTextDrawer()) { + HasSyntheticBoldOrColor(this, aRange) +#ifdef MOZ_BUILD_WEBRENDER + && !aParams.context->GetTextDrawer() +#endif + ) { needToRestore = true; // Measure text; use the bounding box to determine the area we need // to buffer. @@ -1330,9 +1338,8 @@ void gfxTextRun::SortGlyphRuns() { // A GlyphRun with the same font and orientation as the previous can // just be skipped; the last GlyphRun will cover its character range. MOZ_ASSERT(run.mFont != nullptr); - if (!prevRun || - !prevRun->Matches(run.mFont, run.mOrientation, run.mIsCJK, - run.mMatchType)) { + if (!prevRun || !prevRun->Matches(run.mFont, run.mOrientation, run.mIsCJK, + run.mMatchType)) { // If two font runs have the same character offset, Sort() will have // randomized their order! MOZ_ASSERT(prevRun == nullptr || diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index 9881e32042..126e26dbb8 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -33,7 +33,9 @@ #include "mozilla/UniquePtrExtensions.h" #include "mozilla/Unused.h" #include "mozilla/Vector.h" -#include "mozilla/webrender/webrender_ffi.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/webrender_ffi.h" +#endif #include "nsAppRunner.h" #include "nsComponentManagerUtils.h" #include "nsIClipboardHelper.h" @@ -1417,6 +1419,7 @@ nsresult gfxUtils::ThreadSafeGetFeatureStatus( #define GFX_SHADER_CHECK_DEVICE_ID_PREF "gfx-shader-check.device-id" #define GFX_SHADER_CHECK_DRIVER_VERSION_PREF "gfx-shader-check.driver-version" +#ifdef MOZ_BUILD_WEBRENDER /* static */ void gfxUtils::RemoveShaderCacheFromDiskIfNecessary() { if (!gfxVars::UseWebRenderProgramBinaryDisk()) { @@ -1458,6 +1461,7 @@ void gfxUtils::RemoveShaderCacheFromDiskIfNecessary() { Preferences::SetString(GFX_SHADER_CHECK_DRIVER_VERSION_PREF, driverVersion); return; } +#endif /* static */ bool gfxUtils::DumpDisplayList() { @@ -1468,6 +1472,7 @@ bool gfxUtils::DumpDisplayList() { XRE_IsContentProcess()); } +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot gfxUtils::GetContentRenderRoot() { if (gfx::gfxVars::UseWebRender() && StaticPrefs::gfx_webrender_split_render_roots_AtStartup()) { @@ -1541,6 +1546,7 @@ wr::RenderRoot gfxUtils::RecursivelyGetRenderRootForElement( return wr::RenderRoot::Default; } +#endif // MOZ_BUILD_WEBRENDER FILE* gfxUtils::sDumpPaintFile = stderr; diff --git a/gfx/thebes/gfxUtils.h b/gfx/thebes/gfxUtils.h index 197072b398..80dd72cc2a 100644 --- a/gfx/thebes/gfxUtils.h +++ b/gfx/thebes/gfxUtils.h @@ -16,7 +16,9 @@ #include "nsRegionFwd.h" #include "mozilla/gfx/Rect.h" #include "mozilla/CheckedInt.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif class gfxASurface; class gfxDrawable; @@ -29,17 +31,21 @@ namespace dom { class Element; } namespace layers { -class WebRenderBridgeChild; class GlyphArray; struct PlanarYCbCrData; +#ifdef MOZ_BUILD_WEBRENDER +class WebRenderBridgeChild; class WebRenderCommand; +#endif } // namespace layers namespace image { class ImageRegion; } // namespace image +#ifdef MOZ_BUILD_WEBRENDER namespace wr { class DisplayListBuilder; } // namespace wr +#endif } // namespace mozilla enum class ImageType { @@ -299,7 +305,9 @@ class gfxUtils { const nsCOMPtr& gfxInfo, int32_t feature, nsACString& failureId, int32_t* status); +#ifdef MOZ_BUILD_WEBRENDER static void RemoveShaderCacheFromDiskIfNecessary(); +#endif /** * Copy to the clipboard as a PNG encoded Data URL. @@ -311,6 +319,7 @@ class gfxUtils { static FILE* sDumpPaintFile; +#ifdef MOZ_BUILD_WEBRENDER static mozilla::wr::RenderRoot GetContentRenderRoot(); static mozilla::Maybe GetRenderRootForFrame( @@ -321,6 +330,7 @@ class gfxUtils { const nsIFrame* aFrame); static mozilla::wr::RenderRoot RecursivelyGetRenderRootForElement( const mozilla::dom::Element* aElement); +#endif }; namespace mozilla { diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 71f4f5cff5..606875ffdc 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -457,6 +457,7 @@ void gfxWindowsPlatform::InitAcceleration() { UpdateCanUseHardwareVideoDecoding(); } +#ifdef MOZ_BUILD_WEBRENDER void gfxWindowsPlatform::InitWebRenderConfig() { gfxPlatform::InitWebRenderConfig(); @@ -464,6 +465,7 @@ void gfxWindowsPlatform::InitWebRenderConfig() { UpdateBackendPrefs(); } } +#endif bool gfxWindowsPlatform::CanUseHardwareVideoDecoding() { DeviceManagerDx* dm = DeviceManagerDx::Get(); @@ -544,11 +546,15 @@ BackendPrefsData gfxWindowsPlatform::GetBackendPrefs() const { if (gfxConfig::IsEnabled(Feature::DIRECT2D)) { data.mCanvasBitmask |= BackendTypeBit(BackendType::DIRECT2D1_1); data.mCanvasDefault = BackendType::DIRECT2D1_1; +#ifdef MOZ_BUILD_WEBRENDER // We do not use d2d for content when WebRender is used. if (!gfxVars::UseWebRender()) { +#endif data.mContentBitmask |= BackendTypeBit(BackendType::DIRECT2D1_1); data.mContentDefault = BackendType::DIRECT2D1_1; +#ifdef MOZ_BUILD_WEBRENDER } +#endif } return data; } @@ -611,10 +617,12 @@ mozilla::gfx::BackendType gfxWindowsPlatform::GetContentBackendFor( return defaultBackend; } +#ifdef MOZ_BUILD_WEBRENDER if (aLayers == LayersBackend::LAYERS_WR && gfx::gfxVars::UseWebRenderANGLE()) { return defaultBackend; } +#endif if (defaultBackend == BackendType::DIRECT2D1_1) { // We can't have D2D without D3D11 layers, so fallback to Skia. @@ -628,12 +636,14 @@ mozilla::gfx::BackendType gfxWindowsPlatform::GetContentBackendFor( mozilla::gfx::BackendType gfxWindowsPlatform::GetPreferredCanvasBackend() { mozilla::gfx::BackendType backend = gfxPlatform::GetPreferredCanvasBackend(); +#ifdef MOZ_BUILD_WEBRENDER if (backend == BackendType::DIRECT2D1_1 && gfx::gfxVars::UseWebRender() && !gfx::gfxVars::UseWebRenderANGLE()) { // We can't have D2D without ANGLE when WebRender is enabled, so fallback to // Skia. return BackendType::SKIA; } +#endif return backend; } diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 298054924d..ef647a2948 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -50,7 +50,7 @@ class DeviceManagerDx; namespace layers { class DeviceManagerD3D9; class ReadbackManagerD3D11; -} +} // namespace layers } // namespace mozilla struct IDirect3DDevice9; struct ID3D11Device; @@ -242,7 +242,9 @@ class gfxWindowsPlatform : public gfxPlatform { void Init(); void InitAcceleration() override; +#ifdef MOZ_BUILD_WEBRENDER void InitWebRenderConfig() override; +#endif void InitializeDevices(); void InitializeD3D11(); diff --git a/image/Image.cpp b/image/Image.cpp index 6bd4519ff7..9ff4e48555 100644 --- a/image/Image.cpp +++ b/image/Image.cpp @@ -10,7 +10,9 @@ #include "mozilla/SizeOfState.h" #include "mozilla/TimeStamp.h" #include "mozilla/Tuple.h" // for Tie -#include "mozilla/layers/SharedSurfacesChild.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/SharedSurfacesChild.h" +#endif namespace mozilla { namespace image { @@ -96,6 +98,7 @@ void ImageResource::SetCurrentImage(ImageContainer* aContainer, aContainer->SetCurrentImages(imageList); } +#ifdef MOZ_BUILD_WEBRENDER // If we are animated, then we should request that the image container be // treated as such, to avoid display list rebuilding to update frames for // WebRender. @@ -109,6 +112,7 @@ void ImageResource::SetCurrentImage(ImageContainer* aContainer, dirtyRect); } } +#endif } ImgDrawResult ImageResource::GetImageContainerImpl( diff --git a/image/Image.h b/image/Image.h index f7d7ef856e..89372fd2e8 100644 --- a/image/Image.h +++ b/image/Image.h @@ -35,8 +35,13 @@ struct MemoryCounter { mDecodedHeap(0), mDecodedNonHeap(0), mExternalHandles(0), - mFrameIndex(0), - mExternalId(0) {} + mFrameIndex(0) +#ifdef MOZ_BUILD_WEBRENDER + , + mExternalId(0) +#endif + { + } void SetSource(size_t aCount) { mSource = aCount; } size_t Source() const { return mSource; } @@ -48,8 +53,10 @@ struct MemoryCounter { size_t ExternalHandles() const { return mExternalHandles; } void SetFrameIndex(size_t aIndex) { mFrameIndex = aIndex; } size_t FrameIndex() const { return mFrameIndex; } +#ifdef MOZ_BUILD_WEBRENDER void SetExternalId(uint64_t aId) { mExternalId = aId; } uint64_t ExternalId() const { return mExternalId; } +#endif MemoryCounter& operator+=(const MemoryCounter& aOther) { mSource += aOther.mSource; @@ -65,7 +72,9 @@ struct MemoryCounter { size_t mDecodedNonHeap; size_t mExternalHandles; size_t mFrameIndex; +#ifdef MOZ_BUILD_WEBRENDER uint64_t mExternalId; +#endif }; enum class SurfaceMemoryCounterType { NORMAL, COMPOSITING, COMPOSITING_PREV }; diff --git a/image/RecyclingSourceSurface.h b/image/RecyclingSourceSurface.h index f27f8114a8..476a904af0 100644 --- a/image/RecyclingSourceSurface.h +++ b/image/RecyclingSourceSurface.h @@ -34,8 +34,13 @@ class RecyclingSourceSurface final : public gfx::DataSourceSurface { } void AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t& aHeapSizeOut, - size_t& aNonHeapSizeOut, size_t& aExtHandlesOut, - uint64_t& aExtIdOut) const override {} + size_t& aNonHeapSizeOut, size_t& aExtHandlesOut +#ifdef MOZ_BUILD_WEBRENDER + , + uint64_t& aExtIdOut +#endif + ) const override { + } bool OnHeap() const override { return mSurface->OnHeap(); } bool Map(MapType aType, MappedSurface* aMappedSurface) override { diff --git a/image/SurfaceCache.cpp b/image/SurfaceCache.cpp index be8b628596..9a84d520c1 100644 --- a/image/SurfaceCache.cpp +++ b/image/SurfaceCache.cpp @@ -193,7 +193,9 @@ class CachedSurface { counter.Values().SetDecodedNonHeap(aMetadata.nonHeap); counter.Values().SetExternalHandles(aMetadata.handles); counter.Values().SetFrameIndex(aMetadata.index); +#ifdef MOZ_BUILD_WEBRENDER counter.Values().SetExternalId(aMetadata.externalId); +#endif mCounters.AppendElement(counter); }); diff --git a/image/imgFrame.cpp b/image/imgFrame.cpp index 704fc6c80c..a36dea2119 100644 --- a/image/imgFrame.cpp +++ b/image/imgFrame.cpp @@ -97,12 +97,15 @@ static already_AddRefed AllocateBufferForImage( const IntSize& size, SurfaceFormat format, bool aIsAnimated = false) { int32_t stride = VolatileSurfaceStride(size, format); +#ifdef MOZ_BUILD_WEBRENDER if (gfxVars::GetUseWebRenderOrDefault() && StaticPrefs::image_mem_shared()) { RefPtr newSurf = new SourceSurfaceSharedData(); if (newSurf->Init(size, stride, format)) { return newSurf.forget(); } - } else if (ShouldUseHeap(size, stride, aIsAnimated)) { + } else +#endif + if (ShouldUseHeap(size, stride, aIsAnimated)) { RefPtr newSurf = new SourceSurfaceAlignedRawData(); if (newSurf->Init(size, format, false, 0, stride)) { @@ -353,10 +356,12 @@ nsresult imgFrame::InitForDecoderRecycle(const AnimationParams& aAnimParams) { return NS_OK; } -nsresult imgFrame::InitWithDrawable( - gfxDrawable* aDrawable, const nsIntSize& aSize, const SurfaceFormat aFormat, - SamplingFilter aSamplingFilter, uint32_t aImageFlags, - gfx::BackendType aBackend) { +nsresult imgFrame::InitWithDrawable(gfxDrawable* aDrawable, + const nsIntSize& aSize, + const SurfaceFormat aFormat, + SamplingFilter aSamplingFilter, + uint32_t aImageFlags, + gfx::BackendType aBackend) { // Assert for properties that should be verified by decoders, // warn for properties related to bad content. if (!SurfaceCache::IsLegalSize(aSize)) { @@ -930,8 +935,12 @@ void imgFrame::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf, if (mRawSurface) { metadata.heap += aMallocSizeOf(mRawSurface); mRawSurface->AddSizeOfExcludingThis(aMallocSizeOf, metadata.heap, - metadata.nonHeap, metadata.handles, - metadata.externalId); + metadata.nonHeap, metadata.handles +#ifdef MOZ_BUILD_WEBRENDER + , + metadata.externalId +#endif + ); } aCallback(metadata); diff --git a/image/imgFrame.h b/image/imgFrame.h index 3f2f8c2fb3..33f56b75a9 100644 --- a/image/imgFrame.h +++ b/image/imgFrame.h @@ -181,13 +181,24 @@ class imgFrame { struct AddSizeOfCbData { AddSizeOfCbData() - : heap(0), nonHeap(0), handles(0), index(0), externalId(0) {} + : heap(0), + nonHeap(0), + handles(0), + index(0) +#ifdef MOZ_BUILD_WEBRENDER + , + externalId(0) +#endif + { + } size_t heap; size_t nonHeap; size_t handles; size_t index; +#ifdef MOZ_BUILD_WEBRENDER uint64_t externalId; +#endif }; typedef std::function AddSizeOfCb; diff --git a/image/imgLoader.cpp b/image/imgLoader.cpp index 74102f2a32..dc72e34244 100644 --- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -48,8 +48,10 @@ #include "mozilla/BasePrincipal.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/nsMixedContentBlocker.h" -#include "mozilla/image/ImageMemoryReporter.h" -#include "mozilla/layers/CompositorManagerChild.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/image/ImageMemoryReporter.h" +# include "mozilla/layers/CompositorManagerChild.h" +#endif #include "nsIApplicationCache.h" #include "nsIApplicationCacheContainer.h" @@ -82,6 +84,7 @@ class imgMemoryReporter final : public nsIMemoryReporter { NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { +#ifdef MOZ_BUILD_WEBRENDER MOZ_ASSERT(NS_IsMainThread()); layers::CompositorManagerChild* manager = @@ -110,6 +113,7 @@ class imgMemoryReporter final : public nsIMemoryReporter { void FinishCollectReports( nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize, layers::SharedSurfacesMemoryReport& aSharedSurfaces) { +#endif nsTArray chrome; nsTArray content; nsTArray uncached; @@ -138,16 +142,31 @@ class imgMemoryReporter final : public nsIMemoryReporter { // Note that we only need to anonymize content image URIs. - ReportCounterArray(aHandleReport, aData, chrome, "images/chrome", - /* aAnonymize */ false, aSharedSurfaces); + ReportCounterArray(aHandleReport, aData, chrome, "images/chrome" +#ifdef MOZ_BUILD_WEBRENDER + , + /* aAnonymize */ false, aSharedSurfaces +#endif + ); ReportCounterArray(aHandleReport, aData, content, "images/content", - aAnonymize, aSharedSurfaces); + aAnonymize +#ifdef MOZ_BUILD_WEBRENDER + , + aSharedSurfaces +#endif + ); // Uncached images may be content or chrome, so anonymize them. ReportCounterArray(aHandleReport, aData, uncached, "images/uncached", - aAnonymize, aSharedSurfaces); + aAnonymize +#ifdef MOZ_BUILD_WEBRENDER + , + aSharedSurfaces +#endif + ); +#ifdef MOZ_BUILD_WEBRENDER // Report any shared surfaces that were not merged with the surface cache. ImageMemoryReporter::ReportSharedSurfaces(aHandleReport, aData, aSharedSurfaces); @@ -157,6 +176,9 @@ class imgMemoryReporter final : public nsIMemoryReporter { if (imgr) { imgr->EndReport(); } +#else + return NS_OK; +#endif } static int64_t ImagesContentUsedUncompressedDistinguishedAmount() { @@ -239,8 +261,14 @@ class imgMemoryReporter final : public nsIMemoryReporter { void ReportCounterArray(nsIHandleReportCallback* aHandleReport, nsISupports* aData, nsTArray& aCounterArray, - const char* aPathPrefix, bool aAnonymize, - layers::SharedSurfacesMemoryReport& aSharedSurfaces) { + const char* aPathPrefix, +#ifdef MOZ_BUILD_WEBRENDER + bool aAnonymize, + layers::SharedSurfacesMemoryReport& aSharedSurfaces +#else + bool aAnonymize = false +#endif + ) { MemoryTotal summaryTotal; MemoryTotal nonNotableTotal; @@ -263,11 +291,21 @@ class imgMemoryReporter final : public nsIMemoryReporter { summaryTotal += counter; - if (counter.IsNotable() || StaticPrefs::image_mem_debug_reporting()) { - ReportImage(aHandleReport, aData, aPathPrefix, counter, - aSharedSurfaces); + if (counter.IsNotable() +#ifdef MOZ_BUILD_WEBRENDER + || StaticPrefs::image_mem_debug_reporting() +#endif + ) { + ReportImage(aHandleReport, aData, aPathPrefix, counter +#ifdef MOZ_BUILD_WEBRENDER + , + aSharedSurfaces +#endif + ); } else { +#ifdef MOZ_BUILD_WEBRENDER ImageMemoryReporter::TrimSharedSurfaces(counter, aSharedSurfaces); +#endif nonNotableTotal += counter; } } @@ -283,8 +321,12 @@ class imgMemoryReporter final : public nsIMemoryReporter { static void ReportImage(nsIHandleReportCallback* aHandleReport, nsISupports* aData, const char* aPathPrefix, - const ImageMemoryCounter& aCounter, - layers::SharedSurfacesMemoryReport& aSharedSurfaces) { + const ImageMemoryCounter& aCounter +#ifdef MOZ_BUILD_WEBRENDER + , + layers::SharedSurfacesMemoryReport& aSharedSurfaces +#endif + ) { nsAutoCString pathPrefix(NS_LITERAL_CSTRING("explicit/")); pathPrefix.Append(aPathPrefix); pathPrefix.Append(aCounter.Type() == imgIContainer::TYPE_RASTER @@ -305,15 +347,24 @@ class imgMemoryReporter final : public nsIMemoryReporter { pathPrefix.AppendLiteral(")/"); - ReportSurfaces(aHandleReport, aData, pathPrefix, aCounter, aSharedSurfaces); + ReportSurfaces(aHandleReport, aData, pathPrefix, aCounter +#ifdef MOZ_BUILD_WEBRENDER + , + aSharedSurfaces +#endif + ); ReportSourceValue(aHandleReport, aData, pathPrefix, aCounter.Values()); } - static void ReportSurfaces( - nsIHandleReportCallback* aHandleReport, nsISupports* aData, - const nsACString& aPathPrefix, const ImageMemoryCounter& aCounter, - layers::SharedSurfacesMemoryReport& aSharedSurfaces) { + static void ReportSurfaces(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, const nsACString& aPathPrefix, + const ImageMemoryCounter& aCounter +#ifdef MOZ_BUILD_WEBRENDER + , + layers::SharedSurfacesMemoryReport& aSharedSurfaces +#endif + ) { for (const SurfaceMemoryCounter& counter : aCounter.Surfaces()) { nsAutoCString surfacePathPrefix(aPathPrefix); if (counter.IsLocked()) { @@ -333,16 +384,25 @@ class imgMemoryReporter final : public nsIMemoryReporter { surfacePathPrefix.AppendInt(counter.Key().Size().height); if (counter.Values().ExternalHandles() > 0) { - surfacePathPrefix.AppendLiteral(", handles:"); + surfacePathPrefix.AppendLiteral( +#ifdef MOZ_BUILD_WEBRENDER + ", handles:" +#else + ", external:" +#endif + ); surfacePathPrefix.AppendInt( uint32_t(counter.Values().ExternalHandles())); } +#ifdef MOZ_BUILD_WEBRENDER ImageMemoryReporter::AppendSharedSurfacePrefix(surfacePathPrefix, counter, aSharedSurfaces); +#endif if (counter.Type() == SurfaceMemoryCounterType::NORMAL) { PlaybackType playback = counter.Key().Playback(); +#ifdef MOZ_BUILD_WEBRENDER if (playback == PlaybackType::eAnimated) { if (StaticPrefs::image_mem_debug_reporting()) { surfacePathPrefix.AppendPrintf( @@ -351,6 +411,10 @@ class imgMemoryReporter final : public nsIMemoryReporter { surfacePathPrefix.AppendLiteral(" (animation)"); } } +#else + surfacePathPrefix.Append( + playback == PlaybackType::eAnimated ? " (animation)" : ""); +#endif if (counter.Key().Flags() != DefaultSurfaceFlags()) { surfacePathPrefix.AppendLiteral(", flags:"); @@ -1267,7 +1331,11 @@ void imgLoader::GlobalInit() { sCacheMaxSize = cachesize > 0 ? cachesize : 0; sMemReporter = new imgMemoryReporter(); +#ifdef MOZ_BUILD_WEBRENDER RegisterStrongAsyncMemoryReporter(sMemReporter); +#else + RegisterStrongMemoryReporter(sMemReporter); +#endif RegisterImagesContentUsedUncompressedDistinguishedAmount( imgMemoryReporter::ImagesContentUsedUncompressedDistinguishedAmount); } @@ -1661,10 +1729,10 @@ bool imgLoader::ValidateRequestWithNewChannel( imgRequest* request, nsIURI* aURI, nsIURI* aInitialDocumentURI, nsIReferrerInfo* aReferrerInfo, nsILoadGroup* aLoadGroup, imgINotificationObserver* aObserver, nsISupports* aCX, - Document* aLoadingDocument, uint64_t aInnerWindowId, - nsLoadFlags aLoadFlags, nsContentPolicyType aLoadPolicyType, - imgRequestProxy** aProxyRequest, nsIPrincipal* aTriggeringPrincipal, - int32_t aCORSMode, bool* aNewChannelCreated) { + Document* aLoadingDocument, uint64_t aInnerWindowId, nsLoadFlags aLoadFlags, + nsContentPolicyType aLoadPolicyType, imgRequestProxy** aProxyRequest, + nsIPrincipal* aTriggeringPrincipal, int32_t aCORSMode, + bool* aNewChannelCreated) { // now we need to insert a new channel request object inbetween the real // request and the proxy that basically delays loading the image until it // gets a 304 or figures out that this needs to be a new request diff --git a/image/imgRequest.cpp b/image/imgRequest.cpp index 9a9a7f8d92..22f83d4d67 100644 --- a/image/imgRequest.cpp +++ b/image/imgRequest.cpp @@ -38,7 +38,9 @@ #include "nsProperties.h" #include "mozilla/IntegerPrintfMacros.h" -#include "mozilla/SizeOfState.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/SizeOfState.h" +#endif using namespace mozilla; using namespace mozilla::image; diff --git a/image/moz.build b/image/moz.build index f6cbe6b0bb..7dd1af4cf8 100644 --- a/image/moz.build +++ b/image/moz.build @@ -57,10 +57,14 @@ EXPORTS.mozilla.image += [ 'encoders/jpeg/nsJPEGEncoder.h', 'encoders/png/nsPNGEncoder.h', 'ICOFileHeaders.h', - 'ImageMemoryReporter.h', 'RecyclingSourceSurface.h', ] +if CONFIG['MOZ_BUILD_WEBRENDER']: + EXPORTS.mozilla.image += [ + 'ImageMemoryReporter.h', + ] + UNIFIED_SOURCES += [ 'AnimationFrameBuffer.cpp', 'AnimationSurfaceProvider.cpp', @@ -75,7 +79,6 @@ UNIFIED_SOURCES += [ 'Image.cpp', 'ImageCacheKey.cpp', 'ImageFactory.cpp', - 'ImageMemoryReporter.cpp', 'ImageOps.cpp', 'ImageWrapper.cpp', 'imgFrame.cpp', @@ -96,6 +99,8 @@ UNIFIED_SOURCES += [ 'SVGDocumentWrapper.cpp', 'VectorImage.cpp', ] +if CONFIG['MOZ_BUILD_WEBRENDER']: + UNIFIED_SOURCES += [ 'ImageMemoryReporter.cpp'] if CONFIG['MOZ_ENABLE_SKIA']: UNIFIED_SOURCES += [ 'Downscaler.cpp'] diff --git a/ipc/glue/ByteBufUtils.h b/ipc/glue/ByteBufUtils.h index 4ec1cd25a5..b1c76a10e2 100644 --- a/ipc/glue/ByteBufUtils.h +++ b/ipc/glue/ByteBufUtils.h @@ -12,6 +12,58 @@ #include "mozilla/ipc/ByteBuf.h" #include "ipc/IPCMessageUtils.h" +namespace mozilla { +namespace ipc { + +struct ByteBuffer { + ByteBuffer(size_t aLength, uint8_t* aData) + : mLength(aLength), mData(aData), mOwned(false) {} + + ByteBuffer(ByteBuffer&& aFrom) + : mLength(aFrom.mLength), mData(aFrom.mData), mOwned(aFrom.mOwned) { + aFrom.mLength = 0; + aFrom.mData = nullptr; + aFrom.mOwned = false; + } + + ByteBuffer(ByteBuffer& aFrom) + : mLength(aFrom.mLength), mData(aFrom.mData), mOwned(aFrom.mOwned) { + aFrom.mLength = 0; + aFrom.mData = nullptr; + aFrom.mOwned = false; + } + + ByteBuffer() : mLength(0), mData(nullptr), mOwned(false) {} + + bool Allocate(size_t aLength) { + MOZ_ASSERT(mData == nullptr); + mData = (uint8_t*)malloc(aLength); + if (!mData) { + return false; + } + mLength = aLength; + mOwned = true; + return true; + } + + ~ByteBuffer() { + if (mData && mOwned) { + free(mData); + } + } + + bool operator==(const ByteBuffer& other) const { + return mLength == other.mLength && !(memcmp(mData, other.mData, mLength)); + } + + size_t mLength; + uint8_t* mData; + bool mOwned; +}; + +} // namespace ipc +} // namespace mozilla + namespace IPC { template <> @@ -45,6 +97,23 @@ struct ParamTraits { } }; +template <> +struct ParamTraits { + typedef mozilla::ipc::ByteBuffer paramType; + + static void Write(Message* aMsg, const paramType& aParam) { + WriteParam(aMsg, aParam.mLength); + aMsg->WriteBytes(aParam.mData, aParam.mLength); + } + + static bool Read(const Message* aMsg, PickleIterator* aIter, + paramType* aResult) { + size_t length; + return ReadParam(aMsg, aIter, &length) && aResult->Allocate(length) && + aMsg->ReadBytesInto(aIter, aResult->mData, length); + } +}; + } // namespace IPC #endif // ifndef mozilla_ipc_ByteBufUtils_h diff --git a/ipc/glue/IPCStreamChild.cpp b/ipc/glue/IPCStreamChild.cpp index ec0d3aa558..a938e9075b 100644 --- a/ipc/glue/IPCStreamChild.cpp +++ b/ipc/glue/IPCStreamChild.cpp @@ -53,7 +53,7 @@ class IPCStreamSourceChild final : public PChildToParentStreamChild, Unused << SendClose(aRv); } - void SendData(const wr::ByteBuffer& aBuffer) override { + void SendData(const ByteBuffer& aBuffer) override { Unused << SendBuffer(aBuffer); } @@ -128,7 +128,7 @@ class IPCStreamDestinationChild final : public PParentToChildStreamChild, void ActorDestroy(ActorDestroyReason aReason) override { ActorDestroyed(); } - IPCResult RecvBuffer(const wr::ByteBuffer& aBuffer) override { + IPCResult RecvBuffer(const ByteBuffer& aBuffer) override { BufferReceived(aBuffer); return IPC_OK(); } diff --git a/ipc/glue/IPCStreamDestination.cpp b/ipc/glue/IPCStreamDestination.cpp index 74c8819819..1170be7e0c 100644 --- a/ipc/glue/IPCStreamDestination.cpp +++ b/ipc/glue/IPCStreamDestination.cpp @@ -331,7 +331,7 @@ void IPCStreamDestination::ActorDestroyed() { } } -void IPCStreamDestination::BufferReceived(const wr::ByteBuffer& aBuffer) { +void IPCStreamDestination::BufferReceived(const ByteBuffer& aBuffer) { MOZ_ASSERT(mWriter); uint32_t numWritten = 0; diff --git a/ipc/glue/IPCStreamDestination.h b/ipc/glue/IPCStreamDestination.h index 71c40fee38..aee0b51d4e 100644 --- a/ipc/glue/IPCStreamDestination.h +++ b/ipc/glue/IPCStreamDestination.h @@ -13,12 +13,9 @@ class nsIAsyncOutputStream; namespace mozilla { -namespace wr { -struct ByteBuffer; -} // namespace wr - namespace ipc { +struct ByteBuffer; class PChildToParentStreamParent; class PParentToChildStreamChild; @@ -51,7 +48,7 @@ class IPCStreamDestination { void ActorDestroyed(); - void BufferReceived(const wr::ByteBuffer& aBuffer); + void BufferReceived(const ByteBuffer& aBuffer); void CloseReceived(nsresult aRv); diff --git a/ipc/glue/IPCStreamParent.cpp b/ipc/glue/IPCStreamParent.cpp index 3c800f36a3..a975395da4 100644 --- a/ipc/glue/IPCStreamParent.cpp +++ b/ipc/glue/IPCStreamParent.cpp @@ -51,7 +51,7 @@ class IPCStreamSourceParent final : public PParentToChildStreamParent, Unused << SendClose(aRv); } - void SendData(const wr::ByteBuffer& aBuffer) override { + void SendData(const ByteBuffer& aBuffer) override { Unused << SendBuffer(aBuffer); } @@ -128,7 +128,7 @@ class IPCStreamDestinationParent final : public PChildToParentStreamParent, void ActorDestroy(ActorDestroyReason aReason) override { ActorDestroyed(); } - IPCResult RecvBuffer(const wr::ByteBuffer& aBuffer) override { + IPCResult RecvBuffer(const ByteBuffer& aBuffer) override { BufferReceived(aBuffer); return IPC_OK(); } diff --git a/ipc/glue/IPCStreamSource.cpp b/ipc/glue/IPCStreamSource.cpp index 7facceed7c..238ec394f1 100644 --- a/ipc/glue/IPCStreamSource.cpp +++ b/ipc/glue/IPCStreamSource.cpp @@ -4,7 +4,7 @@ #include "IPCStreamSource.h" #include "BackgroundParent.h" // for AssertIsOnBackgroundThread -#include "mozilla/webrender/WebRenderTypes.h" +#include "mozilla/ipc/ByteBufUtils.h" #include "nsIAsyncInputStream.h" #include "nsICancelableRunnable.h" #include "nsIRunnable.h" @@ -12,8 +12,6 @@ #include "nsStreamUtils.h" #include "nsThreadUtils.h" -using mozilla::wr::ByteBuffer; - namespace mozilla { namespace ipc { diff --git a/ipc/glue/IPCStreamSource.h b/ipc/glue/IPCStreamSource.h index 27e77db14c..49c7196578 100644 --- a/ipc/glue/IPCStreamSource.h +++ b/ipc/glue/IPCStreamSource.h @@ -17,12 +17,9 @@ class ContentChild; class ContentParent; } // namespace dom -namespace wr { -struct ByteBuffer; -} // namespace wr - namespace ipc { +struct ByteBuffer; class PBackgroundChild; class PBackgroundParent; class PChildToParentStreamChild; @@ -105,7 +102,7 @@ class IPCStreamSource { virtual void Close(nsresult aRv) = 0; - virtual void SendData(const wr::ByteBuffer& aBuffer) = 0; + virtual void SendData(const ByteBuffer& aBuffer) = 0; void ActorConstructed(); diff --git a/ipc/glue/PChildToParentStream.ipdl b/ipc/glue/PChildToParentStream.ipdl index 1ca5e350b8..1ef35f9a2d 100644 --- a/ipc/glue/PChildToParentStream.ipdl +++ b/ipc/glue/PChildToParentStream.ipdl @@ -5,9 +5,9 @@ include protocol PBackground; include protocol PContent; -include "mozilla/layers/WebRenderMessageUtils.h"; +include "mozilla/ipc/ByteBufUtils.h"; -using mozilla::wr::ByteBuffer from "mozilla/webrender/WebRenderTypes.h"; +using mozilla::ipc::ByteBuffer from "mozilla/ipc/ByteBufUtils.h"; namespace mozilla { namespace ipc { diff --git a/ipc/glue/PParentToChildStream.ipdl b/ipc/glue/PParentToChildStream.ipdl index 181afa0535..5dd623715d 100644 --- a/ipc/glue/PParentToChildStream.ipdl +++ b/ipc/glue/PParentToChildStream.ipdl @@ -5,9 +5,9 @@ include protocol PBackground; include protocol PContent; -include "mozilla/layers/WebRenderMessageUtils.h"; +include "mozilla/ipc/ByteBufUtils.h"; -using mozilla::wr::ByteBuffer from "mozilla/webrender/WebRenderTypes.h"; +using mozilla::ipc::ByteBuffer from "mozilla/ipc/ByteBufUtils.h"; namespace mozilla { namespace ipc { diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 256ec06847..5327157dc4 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -180,8 +180,10 @@ #include "mozilla/GlobalStyleSheetCache.h" #include "mozilla/layers/InputAPZContext.h" #include "mozilla/layers/FocusTarget.h" -#include "mozilla/layers/WebRenderLayerManager.h" -#include "mozilla/layers/WebRenderUserData.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderLayerManager.h" +# include "mozilla/layers/WebRenderUserData.h" +#endif #include "mozilla/layout/ScrollAnchorContainer.h" #include "mozilla/ServoBindings.h" #include "mozilla/ServoStyleSet.h" @@ -1752,10 +1754,10 @@ nsresult PresShell::Initialize() { // content object down mFrameConstructor->ContentInserted( root, nsCSSFrameConstructor::InsertionKind::Sync); - // Run the XBL binding constructors for any new frames we've constructed. - // (Do this in a script runner, since our caller might have a script - // blocker on the stack.) - nsContentUtils::AddScriptRunner(new XBLConstructorRunner(mDocument)); + // Run the XBL binding constructors for any new frames we've constructed. + // (Do this in a script runner, since our caller might have a script + // blocker on the stack.) + nsContentUtils::AddScriptRunner(new XBLConstructorRunner(mDocument)); } // Something in mFrameConstructor->ContentInserted may have caused // Destroy() to get called, bug 337586. Or, nsAutoCauseReflowNotifier @@ -6045,9 +6047,11 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion, flags |= PaintFrameFlags::Compressed; mNextPaintCompressed = false; } +#ifdef MOZ_BUILD_WEBRENDER if (layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) { flags |= PaintFrameFlags::ForWebRender; } +#endif if (frame) { // We can paint directly into the widget using its layer manager. @@ -6056,6 +6060,7 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion, return; } +#ifdef MOZ_BUILD_WEBRENDER if (layerManager->GetBackendType() == layers::LayersBackend::LAYERS_WR) { nsPresContext* pc = GetPresContext(); LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits( @@ -6070,6 +6075,7 @@ void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion, nullptr, nullptr, std::move(wrFilters), &data); return; } +#endif RefPtr root = layerManager->CreateColorLayer(); if (root) { diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 0c1df0f111..2701d88cc3 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -127,12 +127,14 @@ #include "RegionBuilder.h" #include "SVGViewportElement.h" #include "DisplayItemClip.h" -#include "mozilla/layers/StackingContextHelper.h" -#include "mozilla/layers/WebRenderLayerManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/StackingContextHelper.h" +# include "mozilla/layers/WebRenderLayerManager.h" +# include "TextDrawTarget.h" +#endif #include "prenv.h" #include "RetainedDisplayListBuilder.h" #include "DisplayListChecker.h" -#include "TextDrawTarget.h" #include "nsDeckFrame.h" #include "mozilla/dom/InspectorFontFace.h" @@ -3708,9 +3710,11 @@ nsresult nsLayoutUtils::PaintFrame(gfxContext* aRenderingContext, if (aFlags & (PaintFrameFlags::WidgetLayers | PaintFrameFlags::ToWindow)) { builder->SetPaintingToWindow(true); } +#ifdef MOZ_BUILD_WEBRENDER if (aFlags & PaintFrameFlags::ForWebRender) { builder->SetPaintingForWebRender(true); } +#endif if (aFlags & PaintFrameFlags::IgnoreSuppression) { builder->IgnorePaintSuppression(); } @@ -6127,6 +6131,7 @@ void nsLayoutUtils::PaintTextShadow( nscolor shadowColor = shadow.color.CalcColor(aForegroundColor); +#ifdef MOZ_BUILD_WEBRENDER // Webrender just needs the shadow details if (auto* textDrawer = aContext->GetTextDrawer()) { wr::Shadow wrShadow; @@ -6144,6 +6149,7 @@ void nsLayoutUtils::PaintTextShadow( textDrawer->AppendShadow(wrShadow, inflate); continue; } +#endif gfxContext* shadowContext = contextBoxBlur.Init( shadowRect, 0, blurRadius, presCtx->AppUnitsPerDevPixel(), aDestCtx, @@ -6920,6 +6926,7 @@ CSSIntSize nsLayoutUtils::ComputeSizeForDrawingWithFallback( return imageSize; } +#ifdef MOZ_BUILD_WEBRENDER /* static */ IntSize nsLayoutUtils::ComputeImageContainerDrawingParameters( imgIContainer* aImage, nsIFrame* aForFrame, @@ -6994,6 +7001,7 @@ IntSize nsLayoutUtils::ComputeImageContainerDrawingParameters( return aImage->OptimalImageSizeForDest( gfxLayerSize, imgIContainer::FRAME_CURRENT, samplingFilter, aFlags); } +#endif // MOZ_BUILD_WEBRENDER /* static */ nsPoint nsLayoutUtils::GetBackgroundFirstTilePos(const nsPoint& aDest, @@ -8599,9 +8607,11 @@ void nsLayoutUtils::DoLogTestDataForPaint(LayerManager* aManager, MOZ_ASSERT(nsLayoutUtils::IsAPZTestLoggingEnabled(), "don't call me"); if (ClientLayerManager* mgr = aManager->AsClientLayerManager()) { mgr->LogTestDataForCurrentPaint(aScrollId, aKey, aValue); +#ifdef MOZ_BUILD_WEBRENDER } else if (WebRenderLayerManager* wrlm = aManager->AsWebRenderLayerManager()) { wrlm->LogTestDataForCurrentPaint(aScrollId, aKey, aValue); +#endif } } @@ -8614,8 +8624,10 @@ void nsLayoutUtils::LogAdditionalTestData(nsDisplayListBuilder* aBuilder, } if (ClientLayerManager* clm = manager->AsClientLayerManager()) { clm->LogAdditionalTestData(aKey, aValue); +#ifdef MOZ_BUILD_WEBRENDER } else if (WebRenderLayerManager* wrlm = manager->AsWebRenderLayerManager()) { wrlm->LogAdditionalTestData(aKey, aValue); +#endif } } @@ -9974,4 +9986,3 @@ ComputedStyle* nsLayoutUtils::StyleForScrollbar(nsIFrame* aScrollbarPart) { // held strongly by the element. return style.get(); } - diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 9f4cd23828..bf1ffc8d6b 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -93,7 +93,9 @@ namespace layers { struct FrameMetrics; struct ScrollMetadata; class Image; +#ifdef MOZ_BUILD_WEBRENDER class StackingContextHelper; +#endif class Layer; } // namespace layers } // namespace mozilla @@ -139,7 +141,9 @@ class nsLayoutUtils { typedef mozilla::LengthPercentageOrAuto LengthPercentageOrAuto; typedef mozilla::dom::DOMRectList DOMRectList; typedef mozilla::layers::Layer Layer; +#ifdef MOZ_BUILD_WEBRENDER typedef mozilla::layers::StackingContextHelper StackingContextHelper; +#endif typedef mozilla::ContainerLayerParameters ContainerLayerParameters; typedef mozilla::IntrinsicSize IntrinsicSize; typedef mozilla::gfx::SourceSurface SourceSurface; @@ -1104,7 +1108,9 @@ class nsLayoutUtils { ExistingTransaction = 0x80, NoComposite = 0x100, Compressed = 0x200, +#ifdef MOZ_BUILD_WEBRENDER ForWebRender = 0x400, +#endif }; /** @@ -1936,10 +1942,12 @@ class nsLayoutUtils { * Given the image container, frame, and dest rect, determine the best fitting * size to decode the image at, and calculate any necessary SVG parameters. */ +#ifdef MOZ_BUILD_WEBRENDER static mozilla::gfx::IntSize ComputeImageContainerDrawingParameters( imgIContainer* aImage, nsIFrame* aForFrame, const LayoutDeviceRect& aDestRect, const StackingContextHelper& aSc, uint32_t aFlags, mozilla::Maybe& aSVGContext); +#endif /** * Given a source area of an image (in appunits) and a destination area diff --git a/layout/forms/nsButtonFrameRenderer.cpp b/layout/forms/nsButtonFrameRenderer.cpp index da3f918bac..6062cdd87c 100644 --- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -18,7 +18,9 @@ #include "Layers.h" #include "gfxUtils.h" -#include "mozilla/layers/RenderRootStateManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/RenderRootStateManager.h" +#endif #define ACTIVE "active" #define HOVER "hover" @@ -71,6 +73,7 @@ class nsDisplayButtonBoxShadowOuter : public nsPaintedDisplayItem { } #endif +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -79,6 +82,7 @@ class nsDisplayButtonBoxShadowOuter : public nsPaintedDisplayItem { nsDisplayListBuilder* aDisplayListBuilder) override; bool CanBuildWebRenderDisplayItems(); +#endif virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, @@ -100,6 +104,7 @@ void nsDisplayButtonBoxShadowOuter::Paint(nsDisplayListBuilder* aBuilder, frameRect, GetPaintRect()); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayButtonBoxShadowOuter::CanBuildWebRenderDisplayItems() { // FIXME(emilio): Is this right? That doesn't make much sense. if (mFrame->StyleEffects()->mBoxShadow.IsEmpty()) { @@ -185,6 +190,7 @@ bool nsDisplayButtonBoxShadowOuter::CreateWebRenderCommands( } return true; } +#endif // MOZ_BUILD_WEBRENDER class nsDisplayButtonBorder final : public nsPaintedDisplayItem { public: @@ -211,12 +217,14 @@ class nsDisplayButtonBorder final : public nsPaintedDisplayItem { virtual void ComputeInvalidationRegion( nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry, nsRegion* aInvalidRegion) const override; +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif NS_DISPLAY_DECL_NAME("ButtonBorderBackground", TYPE_BUTTON_BORDER_BACKGROUND) private: nsButtonFrameRenderer* mBFR; @@ -227,6 +235,7 @@ nsDisplayItemGeometry* nsDisplayButtonBorder::AllocateGeometry( return new nsDisplayItemGenericImageGeometry(this, aBuilder); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayButtonBorder::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -254,6 +263,7 @@ bool nsDisplayButtonBorder::CreateWebRenderCommands( return true; } +#endif void nsDisplayButtonBorder::ComputeInvalidationRegion( nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry, @@ -311,12 +321,14 @@ class nsDisplayButtonForeground final : public nsPaintedDisplayItem { const nsDisplayItemGeometry* aGeometry, nsRegion* aInvalidRegion) const override; virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif NS_DISPLAY_DECL_NAME("ButtonForeground", TYPE_BUTTON_FOREGROUND) private: nsButtonFrameRenderer* mBFR; @@ -358,6 +370,7 @@ void nsDisplayButtonForeground::Paint(nsDisplayListBuilder* aBuilder, } } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayButtonForeground::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -383,6 +396,7 @@ bool nsDisplayButtonForeground::CreateWebRenderCommands( br->CreateWebRenderCommands(this, aBuilder, aResources, aSc); return true; } +#endif nsresult nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder, nsDisplayList* aBackground, diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp index 6b0412819b..deed7beb7c 100644 --- a/layout/forms/nsFieldSetFrame.cpp +++ b/layout/forms/nsFieldSetFrame.cpp @@ -106,12 +106,14 @@ class nsDisplayFieldSetBorder final : public nsPaintedDisplayItem { virtual void ComputeInvalidationRegion( nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry, nsRegion* aInvalidRegion) const override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const override; NS_DISPLAY_DECL_NAME("FieldSetBorder", TYPE_FIELDSET_BORDER_BACKGROUND) @@ -157,6 +159,7 @@ nsRect nsDisplayFieldSetBorder::GetBounds(nsDisplayListBuilder* aBuilder, return Frame()->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame(); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayFieldSetBorder::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -212,6 +215,7 @@ bool nsDisplayFieldSetBorder::CreateWebRenderCommands( nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, drawResult); return true; }; +#endif void nsFieldSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) { diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index 38913084aa..0854f87a3b 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -23,9 +23,11 @@ #include "mozilla/Likely.h" #include "mozilla/PresShell.h" #include "mozilla/dom/Selection.h" -#include "TextDrawTarget.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "TextDrawTarget.h" using mozilla::layout::TextDrawTarget; +#endif namespace mozilla { namespace css { @@ -191,12 +193,14 @@ class nsDisplayTextOverflowMarker final : public nsPaintedDisplayItem { void PaintTextToContext(gfxContext* aCtx, nsPoint aOffsetFromRect); +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif NS_DISPLAY_DECL_NAME("TextOverflow", TYPE_TEXT_OVERFLOW) private: @@ -264,6 +268,7 @@ void nsDisplayTextOverflowMarker::PaintTextToContext(gfxContext* aCtx, } } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayTextOverflowMarker::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -284,6 +289,7 @@ bool nsDisplayTextOverflowMarker::CreateWebRenderCommands( return textDrawer->Finish(); } +#endif TextOverflow::TextOverflow(nsDisplayListBuilder* aBuilder, nsIFrame* aBlockFrame) diff --git a/layout/generic/moz.build b/layout/generic/moz.build index 326ad645e0..fb47edf3fe 100644 --- a/layout/generic/moz.build +++ b/layout/generic/moz.build @@ -129,9 +129,10 @@ EXPORTS += [ 'ScrollAnimationPhysics.h', 'ScrollbarActivity.h', 'ScrollSnap.h', - 'TextDrawTarget.h', 'Visibility.h', ] +if CONFIG['MOZ_BUILD_WEBRENDER']: + EXPORTS += ['TextDrawTarget.h'] EXPORTS.mozilla += [ '!FrameIdList.h', diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index 843a2d7698..7a9ebdede4 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -13,9 +13,6 @@ #include "mozilla/gfx/2D.h" #include "mozilla/gfx/PathHelpers.h" #include "mozilla/layers/LayersMessages.h" -#include "mozilla/layers/StackingContextHelper.h" -#include "mozilla/layers/RenderRootStateManager.h" -#include "mozilla/layers/WebRenderMessages.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/Move.h" #include "mozilla/PresShell.h" @@ -38,8 +35,13 @@ #include "imgRequestProxy.h" #include "nsIURI.h" #include "SVGImageContext.h" -#include "TextDrawTarget.h" -#include "mozilla/layers/WebRenderBridgeChild.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/StackingContextHelper.h" +# include "mozilla/layers/RenderRootStateManager.h" +# include "mozilla/layers/WebRenderMessages.h" +# include "mozilla/layers/WebRenderBridgeChild.h" +# include "TextDrawTarget.h" +#endif #include @@ -224,12 +226,14 @@ class BulletRenderer final { MOZ_ASSERT(IsTextType()); } +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult CreateWebRenderCommands( nsDisplayItem* aItem, wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, const layers::StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder); +#endif ImgDrawResult Paint(gfxContext& aRenderingContext, nsPoint aPt, const nsRect& aDirtyRect, uint32_t aFlags, @@ -263,6 +267,7 @@ class BulletRenderer final { bool IsImageContainerAvailable(layers::LayerManager* aManager, uint32_t aFlags); +#ifdef MOZ_BUILD_WEBRENDER private: ImgDrawResult CreateWebRenderCommandsForImage( nsDisplayItem* aItem, wr::DisplayListBuilder& aBuilder, @@ -284,6 +289,7 @@ class BulletRenderer final { const layers::StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder); +#endif private: // mImage and mDest are the properties for list-style-image. @@ -321,6 +327,7 @@ class BulletRenderer final { int32_t mListStyleType; }; +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult BulletRenderer::CreateWebRenderCommands( nsDisplayItem* aItem, wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, @@ -344,6 +351,7 @@ ImgDrawResult BulletRenderer::CreateWebRenderCommands( return success ? ImgDrawResult::SUCCESS : ImgDrawResult::NOT_SUPPORTED; } +#endif ImgDrawResult BulletRenderer::Paint(gfxContext& aRenderingContext, nsPoint aPt, const nsRect& aDirtyRect, uint32_t aFlags, @@ -423,6 +431,7 @@ bool BulletRenderer::IsImageContainerAvailable(layers::LayerManager* aManager, return mImage->IsImageContainerAvailable(aManager, aFlags); } +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult BulletRenderer::CreateWebRenderCommandsForImage( nsDisplayItem* aItem, wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, @@ -539,6 +548,7 @@ bool BulletRenderer::CreateWebRenderCommandsForText( return textDrawer->Finish(); } +#endif // MOZ_BUILD_WEBRENDER class nsDisplayBullet final : public nsPaintedDisplayItem { public: @@ -556,11 +566,13 @@ class nsDisplayBullet final : public nsPaintedDisplayItem { return mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame(); } +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue&, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect, HitTestState* aState, @@ -609,6 +621,7 @@ class nsDisplayBullet final : public nsPaintedDisplayItem { Maybe mBulletRenderer; }; +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayBullet::CreateWebRenderCommands( wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, @@ -635,6 +648,7 @@ bool nsDisplayBullet::CreateWebRenderCommands( nsDisplayBulletGeometry::UpdateDrawResult(this, drawResult); return true; } +#endif void nsDisplayBullet::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { uint32_t flags = imgIContainer::FLAG_NONE; diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp index 351fb4db0b..4fcc8edfdb 100644 --- a/layout/generic/nsCanvasFrame.cpp +++ b/layout/generic/nsCanvasFrame.cpp @@ -23,8 +23,10 @@ #include "mozilla/AccessibleCaretEventHub.h" #include "mozilla/ComputedStyle.h" #include "mozilla/dom/AnonymousContent.h" -#include "mozilla/layers/StackingContextHelper.h" -#include "mozilla/layers/RenderRootStateManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/StackingContextHelper.h" +# include "mozilla/layers/RenderRootStateManager.h" +#endif #include "mozilla/PresShell.h" // for focus #include "nsIScrollableFrame.h" @@ -352,6 +354,7 @@ already_AddRefed nsDisplayCanvasBackgroundColor::BuildLayer( return layer.forget(); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayCanvasBackgroundColor::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -372,6 +375,7 @@ bool nsDisplayCanvasBackgroundColor::CreateWebRenderCommands( wr::ToColorF(ToDeviceColor(mColor))); return true; } +#endif #ifdef MOZ_DUMP_PAINTING void nsDisplayCanvasBackgroundColor::WriteDebugInfo( diff --git a/layout/generic/nsCanvasFrame.h b/layout/generic/nsCanvasFrame.h index b3e7fb8be2..aa995f4325 100644 --- a/layout/generic/nsCanvasFrame.h +++ b/layout/generic/nsCanvasFrame.h @@ -159,12 +159,14 @@ class nsDisplayCanvasBackgroundColor final : public nsDisplaySolidColorBase { virtual already_AddRefed BuildLayer( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) override; +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif virtual LayerState GetLayerState( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aParameters) override { diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index 67afe99063..bf9e17f46d 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -43,12 +43,14 @@ class nsDisplayColumnRule : public nsPaintedDisplayItem { ToReferenceFrame()); } +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; NS_DISPLAY_DECL_NAME("ColumnRule", TYPE_COLUMN_RULE); @@ -68,6 +70,7 @@ void nsDisplayColumnRule::Paint(nsDisplayListBuilder* aBuilder, } } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayColumnRule::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -84,12 +87,15 @@ bool nsDisplayColumnRule::CreateWebRenderCommands( return true; } +# ifdef MOZ_BUILD_WEBRENDER for (auto& renderer : mBorderRenderers) { renderer.CreateWebRenderCommands(this, aBuilder, aResources, aSc); } +# endif return true; } +#endif /** * Tracking issues: diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 15c325438f..881698c8db 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -113,7 +113,9 @@ #include "mozilla/dom/SVGPathData.h" #include "mozilla/dom/TouchEvent.h" #include "mozilla/gfx/Tools.h" -#include "mozilla/layers/WebRenderUserData.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderUserData.h" +#endif #include "mozilla/layout/ScrollAnchorContainer.h" #include "nsPrintfCString.h" #include "ActiveLayerTracker.h" @@ -1028,6 +1030,7 @@ void nsIFrame::DiscardOldItems() { } void nsIFrame::RemoveDisplayItemDataForDeletion() { +#ifdef MOZ_BUILD_WEBRENDER // Destroying a WebRenderUserDataTable can cause destruction of other objects // which can remove frame properties in their destructor. If we delete a frame // property it runs the destructor of the stored object in the middle of @@ -1043,6 +1046,7 @@ void nsIFrame::RemoveDisplayItemDataForDeletion() { } delete userDataTable; } +#endif FrameLayerBuilder::RemoveFrameFromLayerManager(this, DisplayItemData()); DisplayItemData().Clear(); @@ -2295,12 +2299,14 @@ class nsDisplaySelectionOverlay : public nsPaintedDisplayItem { #endif virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif NS_DISPLAY_DECL_NAME("SelectionOverlay", TYPE_SELECTION_OVERLAY) private: Color ComputeColor() const; @@ -2361,6 +2367,7 @@ void nsDisplaySelectionOverlay::Paint(nsDisplayListBuilder* aBuilder, aDrawTarget.FillRect(rect, color); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplaySelectionOverlay::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -2374,6 +2381,7 @@ bool nsDisplaySelectionOverlay::CreateWebRenderCommands( wr::ToColorF(ComputeColor())); return true; } +#endif static Element* FindElementAncestorForMozSelection(nsIContent* aContent) { NS_ENSURE_TRUE(aContent, nullptr); @@ -2568,6 +2576,7 @@ inline static bool IsSVGContentWithCSSClip(const nsIFrame* aFrame) { nsGkAtoms::foreignObject); } +#ifdef MOZ_BUILD_WEBRENDER bool nsIFrame::FormsBackdropRoot(const nsStyleDisplay* aStyleDisplay, const nsStyleEffects* aStyleEffects, const nsStyleSVGReset* aStyleSVGReset) { @@ -2596,6 +2605,7 @@ bool nsIFrame::FormsBackdropRoot(const nsStyleDisplay* aStyleDisplay, return false; } +#endif Maybe nsIFrame::GetClipPropClipRect(const nsStyleDisplay* aDisp, const nsStyleEffects* aEffects, @@ -2754,6 +2764,7 @@ class AutoSaveRestoreContainsBlendMode { } }; +#ifdef MOZ_BUILD_WEBRENDER class AutoSaveRestoreContainsBackdropFilter { nsDisplayListBuilder& mBuilder; bool mSavedContainsBackdropFilter; @@ -2777,6 +2788,7 @@ class AutoSaveRestoreContainsBackdropFilter { mBuilder.SetContainsBackdropFilter(mSavedContainsBackdropFilter); } }; +#endif static void CheckForApzAwareEventHandlers(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) { @@ -3113,6 +3125,7 @@ void nsIFrame::BuildDisplayListForStackingContext( AutoSaveRestoreContainsBlendMode autoRestoreBlendMode(*aBuilder); aBuilder->SetContainsBlendMode(false); +#ifdef MOZ_BUILD_WEBRENDER bool backdropFilterEnabled = StaticPrefs::layout_css_backdrop_filter_enabled(); bool usingBackdropFilter = @@ -3125,6 +3138,7 @@ void nsIFrame::BuildDisplayListForStackingContext( AutoSaveRestoreContainsBackdropFilter autoRestoreBackdropFilter(*aBuilder); aBuilder->SetContainsBackdropFilter(false); +#endif nsRect visibleRectOutsideTransform = visibleRect; bool allowAsyncAnimation = false; @@ -3317,7 +3331,9 @@ void nsIFrame::BuildDisplayListForStackingContext( nsDisplayListCollection set(aBuilder); Maybe clipForMask; +#ifdef MOZ_BUILD_WEBRENDER bool insertBackdropRoot; +#endif { DisplayListClipState::AutoSaveRestore nestedClipState(aBuilder); nsDisplayListBuilder::AutoInTransformSetter inTransformSetter(aBuilder, @@ -3350,10 +3366,12 @@ void nsIFrame::BuildDisplayListForStackingContext( aBuilder->AdjustWindowDraggingRegion(this); +#ifdef MOZ_BUILD_WEBRENDER if (gfxVars::UseWebRender()) { aBuilder->BuildCompositorHitTestInfoIfNeeded(this, set.BorderBackground(), true); } else { +#endif CompositorHitTestInfo info = aBuilder->BuildCompositorHitTestInfo() ? GetCompositorHitTestInfo(aBuilder) : CompositorHitTestInvisibleToHit; @@ -3365,7 +3383,9 @@ void nsIFrame::BuildDisplayListForStackingContext( // Let child frames know the current hit test area and hit test flags. aBuilder->SetCompositorHitTestInfo(hitTestInfo->mArea, hitTestInfo->mFlags); +#ifdef MOZ_BUILD_WEBRENDER } +#endif } MarkAbsoluteFramesForDisplayList(aBuilder); @@ -3374,9 +3394,11 @@ void nsIFrame::BuildDisplayListForStackingContext( aBuilder->Check(); aBuilder->DisplayCaret(this, set.Outlines()); +#ifdef MOZ_BUILD_WEBRENDER insertBackdropRoot = backdropFilterEnabled && aBuilder->ContainsBackdropFilter() && FormsBackdropRoot(disp, effects, StyleSVGReset()); +#endif // Blend modes are a real pain for retained display lists. We build a blend // container item if the built list contains any blend mode items within @@ -3396,7 +3418,11 @@ void nsIFrame::BuildDisplayListForStackingContext( // to remove any existing content that isn't wrapped in the blend container, // and then we need to build content infront/behind the blend container // to get correct positioning during merging. - if ((insertBackdropRoot || aBuilder->ContainsBlendMode()) && + if (( +#ifdef MOZ_BUILD_WEBRENDER + insertBackdropRoot || +#endif + aBuilder->ContainsBlendMode()) && aBuilder->IsRetainingDisplayList()) { if (!aBuilder->GetDirtyRect().Contains(aBuilder->GetVisibleRect())) { aBuilder->SetPartialBuildFailed(true); @@ -3406,12 +3432,14 @@ void nsIFrame::BuildDisplayListForStackingContext( } } +#ifdef MOZ_BUILD_WEBRENDER // If a child contains a backdrop filter, but this stacking context does not // form a backdrop root, we need to propogate up the tree until we find an // ancestor that does form a backdrop root. if (!insertBackdropRoot && aBuilder->ContainsBackdropFilter()) { autoRestoreBackdropFilter.DelegateUp(true); } +#endif if (aBuilder->IsBackgroundOnly()) { set.BlockBorderBackgrounds()->DeleteAll(aBuilder); @@ -3464,6 +3492,7 @@ void nsIFrame::BuildDisplayListForStackingContext( ct.TrackContainer(resultList.GetTop()); } +#ifdef MOZ_BUILD_WEBRENDER if (insertBackdropRoot) { DisplayListClipState::AutoSaveRestore backdropRootContainerClipState( aBuilder); @@ -3480,6 +3509,7 @@ void nsIFrame::BuildDisplayListForStackingContext( aBuilder, this, &resultList, backdropRect); ct.TrackContainer(resultList.GetTop()); } +#endif /* If there are any SVG effects, wrap the list up in an SVG effects item * (which also handles CSS group opacity). Note that we create an SVG effects @@ -3719,8 +3749,10 @@ void nsIFrame::BuildDisplayListForStackingContext( } if (hitTestInfo) { +#ifdef MOZ_BUILD_WEBRENDER // WebRender support is not yet implemented. MOZ_ASSERT(!gfxVars::UseWebRender()); +#endif AddHitTestInfo(aBuilder, &resultList, ct.mContainer, this, std::move(hitTestInfo)); } @@ -7385,12 +7417,14 @@ Layer* nsIFrame::InvalidateLayer(DisplayItemType aDisplayItemKey, nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(this); InvalidateRenderingObservers(displayRoot, this, false); +#ifdef MOZ_BUILD_WEBRENDER // Check if frame supports WebRender's async update if ((aFlags & UPDATE_IS_ASYNC) && WebRenderUserData::SupportsAsyncUpdate(this)) { // WebRender does not use layer, then return nullptr. return nullptr; } +#endif // If the layer is being updated asynchronously, and it's being forwarded // to a compositor, then we don't need to invalidate. @@ -10848,6 +10882,7 @@ void nsIFrame::SetParent(nsContainerFrame* aParent) { void nsIFrame::CreateOwnLayerIfNeeded(nsDisplayListBuilder* aBuilder, nsDisplayList* aList, bool* aCreatedContainerItem) { +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot renderRoot = gfxUtils::GetRenderRootForFrame(this).valueOr(wr::RenderRoot::Default); @@ -10858,9 +10893,11 @@ void nsIFrame::CreateOwnLayerIfNeeded(nsDisplayListBuilder* aBuilder, if (aCreatedContainerItem) { *aCreatedContainerItem = true; } - } else if (GetContent() && GetContent()->IsXULElement() && - GetContent()->AsElement()->HasAttr(kNameSpaceID_None, - nsGkAtoms::layer)) { + } else +#endif + if (GetContent() && GetContent()->IsXULElement() && + GetContent()->AsElement()->HasAttr(kNameSpaceID_None, + nsGkAtoms::layer)) { aList->AppendNewToTop( aBuilder, this, aList, aBuilder->CurrentActiveScrolledRoot()); if (aCreatedContainerItem) { @@ -10887,8 +10924,11 @@ bool nsIFrame::IsStackingContext(const nsStyleDisplay* aStyleDisplay, aStylePosition->mZIndex.IsInteger())) || (aStyleDisplay->mWillChange.bits & StyleWillChangeBits::STACKING_CONTEXT) || - aStyleDisplay->mIsolation != StyleIsolation::Auto || - aStyleEffects->HasBackdropFilters(); + aStyleDisplay->mIsolation != StyleIsolation::Auto +#ifdef MOZ_BUILD_WEBRENDER + || aStyleEffects->HasBackdropFilters() +#endif + ; } bool nsIFrame::IsStackingContext() { @@ -11166,13 +11206,14 @@ CompositorHitTestInfo nsIFrame::GetCompositorHitTestInfo( // Anything that didn't match the above conditions is visible to hit-testing. result = CompositorHitTestFlags::eVisibleToHitTest; if (nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(this)) { +#ifdef MOZ_BUILD_WEBRENDER // If WebRender is enabled, simple clip-paths can be converted into WR // clips that WR knows how to hit-test against, so we don't need to mark // it as an irregular area. if (!gfxVars::UseWebRender() || - !nsSVGIntegrationUtils::UsingSimpleClipPathForFrame(this)) { + !nsSVGIntegrationUtils::UsingSimpleClipPathForFrame(this)) +#endif result += CompositorHitTestFlags::eIrregularArea; - } } if (aBuilder->IsBuildingNonLayerizedScrollbar()) { diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 74ae64faa0..31c7e24bbc 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -2914,18 +2914,27 @@ void ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange, // update, instead of a full transaction. This empty transaction // might still get squashed into a full transaction if something // happens to trigger one. +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot renderRoot = wr::RenderRoot::Default; if (XRE_IsContentProcess()) { renderRoot = gfxUtils::GetContentRenderRoot(); } else { renderRoot = gfxUtils::RecursivelyGetRenderRootForFrame(mOuter); } +#endif success = manager->SetPendingScrollUpdateForNextTransaction( id, - {mScrollGeneration, CSSPoint::FromAppUnits(GetScrollPosition()), - CSSPoint::FromAppUnits(GetApzScrollPosition()), - mLastScrollOrigin == nsGkAtoms::relative}, - renderRoot); + { + mScrollGeneration, + CSSPoint::FromAppUnits(GetScrollPosition()), + CSSPoint::FromAppUnits(GetApzScrollPosition()), + mLastScrollOrigin == nsGkAtoms::relative + } +#ifdef MOZ_BUILD_WEBRENDER + , + renderRoot +#endif + ); if (success) { schedulePaint = false; mOuter->SchedulePaint(nsIFrame::PAINT_COMPOSITE_ONLY); diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 5a4c97dd5f..df6ee35c37 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -10,9 +10,11 @@ #include "mozilla/Assertions.h" #include "mozilla/PresShell.h" #include "mozilla/dom/HTMLCanvasElement.h" -#include "mozilla/layers/WebRenderBridgeChild.h" -#include "mozilla/layers/WebRenderCanvasRenderer.h" -#include "mozilla/layers/RenderRootStateManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderBridgeChild.h" +# include "mozilla/layers/WebRenderCanvasRenderer.h" +# include "mozilla/layers/RenderRootStateManager.h" +#endif #include "nsDisplayList.h" #include "nsLayoutUtils.h" #include "nsStyleUtil.h" @@ -107,6 +109,7 @@ class nsDisplayCanvas final : public nsPaintedDisplayItem { aBuilder, aManager, this, aContainerParameters); } +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, @@ -192,6 +195,7 @@ class nsDisplayCanvas final : public nsPaintedDisplayItem { } return true; } +#endif virtual LayerState GetLayerState( nsDisplayListBuilder* aBuilder, LayerManager* aManager, @@ -444,11 +448,13 @@ already_AddRefed nsHTMLCanvasFrame::BuildLayer( return layer.forget(); } +#ifdef MOZ_BUILD_WEBRENDER bool nsHTMLCanvasFrame::UpdateWebRenderCanvasData( nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) { HTMLCanvasElement* element = static_cast(GetContent()); return element->UpdateWebRenderCanvasData(aBuilder, aCanvasData); } +#endif void nsHTMLCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) { diff --git a/layout/generic/nsHTMLCanvasFrame.h b/layout/generic/nsHTMLCanvasFrame.h index 9ff81b4501..3c7ab49871 100644 --- a/layout/generic/nsHTMLCanvasFrame.h +++ b/layout/generic/nsHTMLCanvasFrame.h @@ -17,7 +17,9 @@ class PresShell; namespace layers { class Layer; class LayerManager; +#ifdef MOZ_BUILD_WEBRENDER class WebRenderCanvasData; +#endif } // namespace layers } // namespace mozilla @@ -32,7 +34,9 @@ class nsHTMLCanvasFrame final : public nsContainerFrame { typedef mozilla::layers::CanvasRenderer CanvasRenderer; typedef mozilla::layers::Layer Layer; typedef mozilla::layers::LayerManager LayerManager; +#ifdef MOZ_BUILD_WEBRENDER typedef mozilla::layers::WebRenderCanvasData WebRenderCanvasData; +#endif typedef mozilla::ContainerLayerParameters ContainerLayerParameters; NS_DECL_QUERYFRAME @@ -53,8 +57,10 @@ class nsHTMLCanvasFrame final : public nsContainerFrame { nsDisplayItem* aItem, const ContainerLayerParameters& aContainerParameters); +#ifdef MOZ_BUILD_WEBRENDER bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData); +#endif /* get the size of the canvas's image */ nsIntSize GetCanvasSize(); diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 31e3dd780f..65d1c1f9c0 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -1815,9 +1815,11 @@ class nsIFrame : public nsQueryFrame { * Return true if this frame should form a backdrop root container. * See: https://drafts.fxtf.org/filter-effects-2/#BackdropRootTriggers */ +#ifdef MOZ_BUILD_WEBRENDER bool FormsBackdropRoot(const nsStyleDisplay* aStyleDisplay, const nsStyleEffects* aStyleEffects, const nsStyleSVGReset* aStyleSvgReset); +#endif /** * Returns whether this frame will attempt to extend the 3d transforms of its diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index cccbc7a8de..f84bd03319 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -6,7 +6,6 @@ #include "nsImageFrame.h" -#include "TextDrawTarget.h" #include "gfx2DGlue.h" #include "gfxContext.h" #include "gfxUtils.h" @@ -23,8 +22,11 @@ #include "mozilla/dom/HTMLAreaElement.h" #include "mozilla/dom/HTMLImageElement.h" #include "mozilla/dom/ResponsiveImageSelector.h" -#include "mozilla/layers/RenderRootStateManager.h" -#include "mozilla/layers/WebRenderLayerManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "TextDrawTarget.h" +# include "mozilla/layers/RenderRootStateManager.h" +# include "mozilla/layers/WebRenderLayerManager.h" +#endif #include "mozilla/MouseEvents.h" #include "mozilla/PresShell.h" #include "mozilla/PresShellInlines.h" @@ -92,7 +94,9 @@ using namespace mozilla::gfx; using namespace mozilla::image; using namespace mozilla::layers; +#ifdef MOZ_BUILD_WEBRENDER using mozilla::layout::TextDrawTarget; +#endif // sizes (pixels) for image icon, padding and border frame #define ICON_SIZE (16) @@ -772,11 +776,13 @@ void nsImageFrame::InvalidateSelf(const nsIntRect* aLayerInvalidRect, // Check if WebRender has interacted with this frame. If it has // we need to let it know that things have changed. const auto type = DisplayItemType::TYPE_IMAGE; +#ifdef MOZ_BUILD_WEBRENDER const auto producerId = mImage ? mImage->GetProducerId() : kContainerProducerID_Invalid; if (WebRenderUserData::ProcessInvalidateForImage(this, type, producerId)) { return; } +#endif InvalidateLayer(type, aLayerInvalidRect, aFrameInvalidRect); @@ -1299,6 +1305,7 @@ class nsDisplayAltFeedback final : public nsPaintedDisplayItem { nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result); } +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -1313,6 +1320,7 @@ class nsDisplayAltFeedback final : public nsPaintedDisplayItem { return result == ImgDrawResult::SUCCESS; } +#endif NS_DISPLAY_DECL_NAME("AltFeedback", TYPE_ALT_FEEDBACK) }; @@ -1470,6 +1478,7 @@ ImgDrawResult nsImageFrame::DisplayAltFeedback(gfxContext& aRenderingContext, return result; } +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult nsImageFrame::DisplayAltFeedbackWithoutLayer( nsDisplayItem* aItem, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -1680,6 +1689,7 @@ ImgDrawResult nsImageFrame::DisplayAltFeedbackWithoutLayer( // already. return textDrawResult ? ImgDrawResult::SUCCESS : ImgDrawResult::NOT_READY; } +#endif // MOZ_BUILD_WEBRENDER #ifdef DEBUG static void PaintDebugImageMap(nsIFrame* aFrame, DrawTarget* aDrawTarget, @@ -1847,6 +1857,7 @@ already_AddRefed nsDisplayImage::BuildLayer( return layer.forget(); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayImage::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -1932,6 +1943,7 @@ bool nsDisplayImage::CreateWebRenderCommands( nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, drawResult); return true; } +#endif ImgDrawResult nsImageFrame::PaintImage(gfxContext& aRenderingContext, nsPoint aPt, const nsRect& aDirtyRect, diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index 27123d44fe..62d30153ed 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -144,12 +144,14 @@ class nsImageFrame : public nsAtomicContainerFrame, public nsIReflowCallback { const nsRect& aDirtyRect, nsPoint aPt, uint32_t aFlags); +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult DisplayAltFeedbackWithoutLayer( nsDisplayItem*, mozilla::wr::DisplayListBuilder&, mozilla::wr::IpcResourceUpdateQueue&, const mozilla::layers::StackingContextHelper&, mozilla::layers::RenderRootStateManager*, nsDisplayListBuilder*, nsPoint aPt, uint32_t aFlags); +#endif nsRect GetInnerArea() const; @@ -478,11 +480,13 @@ class nsDisplayImage final : public nsDisplayImageContainer { already_AddRefed BuildLayer(nsDisplayListBuilder*, LayerManager*, const ContainerLayerParameters&) final; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder&, mozilla::wr::IpcResourceUpdateQueue&, const StackingContextHelper&, mozilla::layers::RenderRootStateManager*, nsDisplayListBuilder*) final; +#endif NS_DISPLAY_DECL_NAME("Image", TYPE_IMAGE) private: diff --git a/layout/generic/nsPluginFrame.cpp b/layout/generic/nsPluginFrame.cpp index 79b63b92c7..a28ecd8e58 100644 --- a/layout/generic/nsPluginFrame.cpp +++ b/layout/generic/nsPluginFrame.cpp @@ -53,7 +53,9 @@ #include "Layers.h" #include "ReadbackLayer.h" #include "ImageContainer.h" -#include "mozilla/layers/RenderRootStateManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/RenderRootStateManager.h" +#endif // accessibility support #ifdef ACCESSIBILITY @@ -972,6 +974,7 @@ nsRegion nsDisplayPlugin::GetOpaqueRegion(nsDisplayListBuilder* aBuilder, return result; } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayPlugin::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -981,6 +984,7 @@ bool nsDisplayPlugin::CreateWebRenderCommands( return static_cast(mFrame)->CreateWebRenderCommands( this, aBuilder, aResources, aSc, aManager, aDisplayListBuilder); } +#endif nsresult nsPluginFrame::PluginEventNotifier::Run() { nsCOMPtr obsSvc = mozilla::services::GetObserverService(); @@ -1295,6 +1299,7 @@ bool nsPluginFrame::GetBounds(nsDisplayItem* aItem, IntSize& aSize, return true; } +#ifdef MOZ_BUILD_WEBRENDER bool nsPluginFrame::CreateWebRenderCommands( nsDisplayItem* aItem, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -1317,11 +1322,11 @@ bool nsPluginFrame::CreateWebRenderCommands( return true; } -#ifdef XP_MACOSX +# ifdef XP_MACOSX if (!mInstanceOwner->UseAsyncRendering()) { mInstanceOwner->DoCocoaEventDrawRect(r, nullptr); } -#endif +# endif RefPtr lm = aDisplayListBuilder->GetWidgetLayerManager(); if (!mDidCompositeObserver || !mDidCompositeObserver->IsValid(lm)) { @@ -1338,6 +1343,7 @@ bool nsPluginFrame::CreateWebRenderCommands( aSc, dest, dest); return true; } +#endif already_AddRefed nsPluginFrame::BuildLayer( nsDisplayListBuilder* aBuilder, LayerManager* aManager, diff --git a/layout/generic/nsPluginFrame.h b/layout/generic/nsPluginFrame.h index dc43498f37..ac6bd7e53e 100644 --- a/layout/generic/nsPluginFrame.h +++ b/layout/generic/nsPluginFrame.h @@ -16,8 +16,10 @@ #include "nsDisplayList.h" #include "nsIReflowCallback.h" #include "Units.h" -#include "mozilla/layers/StackingContextHelper.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/StackingContextHelper.h" +# include "mozilla/webrender/WebRenderAPI.h" +#endif #ifdef XP_WIN # include // For HWND :( @@ -60,9 +62,11 @@ class nsPluginFrame final : public nsFrame, typedef mozilla::layers::Layer Layer; typedef mozilla::layers::LayerManager LayerManager; typedef mozilla::layers::ImageContainer ImageContainer; +#ifdef MOZ_BUILD_WEBRENDER typedef mozilla::layers::StackingContextHelper StackingContextHelper; typedef mozilla::layers::RenderRootStateManager RenderRootStateManager; typedef mozilla::layers::WebRenderParentCommand WebRenderParentCommand; +#endif typedef mozilla::ContainerLayerParameters ContainerLayerParameters; NS_DECL_FRAMEARENA_HELPERS(nsPluginFrame) @@ -221,12 +225,14 @@ class nsPluginFrame final : public nsFrame, */ bool WantsToHandleWheelEventAsDefaultAction() const; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( nsDisplayItem* aItem, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder); +#endif protected: explicit nsPluginFrame(ComputedStyle* aStyle, nsPresContext* aPresContext); @@ -391,12 +397,14 @@ class nsDisplayPlugin final : public nsPaintedDisplayItem { return new nsDisplayPluginGeometry(this, aBuilder); } +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif }; #endif /* nsPluginFrame_h___ */ diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 78335def9c..9e2496cd28 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -56,8 +56,9 @@ #include "nsUnicodeProperties.h" #include "nsStyleUtil.h" #include "nsRubyFrame.h" -#include "TextDrawTarget.h" - +#ifdef MOZ_BUILD_WEBRENDER +# include "TextDrawTarget.h" +#endif #include "nsTextFragment.h" #include "nsGkAtoms.h" #include "nsFrameSelection.h" @@ -101,7 +102,9 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::gfx; +#ifdef MOZ_BUILD_WEBRENDER typedef mozilla::layout::TextDrawTarget TextDrawTarget; +#endif static bool NeedsToMaskPassword(nsTextFrame* aFrame) { MOZ_ASSERT(aFrame); @@ -6045,6 +6048,7 @@ void nsTextFrame::PaintOneShadow(const PaintShadowParams& aParams, nscolor shadowColor = aShadowDetails.color.CalcColor(aParams.foregroundColor); +#ifdef MOZ_BUILD_WEBRENDER if (auto* textDrawer = aParams.context->GetTextDrawer()) { wr::Shadow wrShadow; @@ -6058,6 +6062,7 @@ void nsTextFrame::PaintOneShadow(const PaintShadowParams& aParams, textDrawer->AppendShadow(wrShadow, inflate); return; } +#endif // This rect is the box which is equivalent to where the shadow will be // painted. The origin of aBoundingBox is the text baseline left, so we must @@ -6191,7 +6196,9 @@ bool nsTextFrame::PaintTextWithSelectionColors( TextRangeStyle rangeStyle; // Draw background colors +#ifdef MOZ_BUILD_WEBRENDER auto* textDrawer = aParams.context->GetTextDrawer(); +#endif if (anyBackgrounds && !aParams.IsGenerateTextMask()) { int32_t appUnitsPerDevPixel = @@ -6221,14 +6228,15 @@ bool nsTextFrame::PaintTextWithSelectionColors( LayoutDeviceRect selectionRect = LayoutDeviceRect::FromAppUnits(bgRect, appUnitsPerDevPixel); +#ifdef MOZ_BUILD_WEBRENDER if (textDrawer) { textDrawer->AppendSelectionRect(selectionRect, ToDeviceColor(background)); - } else { + } else +#endif PaintSelectionBackground(*aParams.context->GetDrawTarget(), background, aParams.dirtyRect, selectionRect, aParams.callbacks); - } } iterator.UpdateWithAdvance(advance); } @@ -6537,7 +6545,8 @@ nscolor nsTextFrame::GetCaretColorAt(int32_t aOffset) { return result; } -static gfxTextRun::Range ComputeTransformedRange(nsTextFrame::PropertyProvider& aProvider) { +static gfxTextRun::Range ComputeTransformedRange( + nsTextFrame::PropertyProvider& aProvider) { gfxSkipCharsIterator iter(aProvider.GetStart()); uint32_t start = iter.GetSkippedOffset(); iter.AdvanceOriginal(aProvider.GetOriginalLength()); @@ -6833,20 +6842,31 @@ static void DrawTextRun(const gfxTextRun* aTextRun, aTextRun->Draw(aRange, aTextBaselinePt, params); aParams.callbacks->NotifyAfterText(); } else { +#ifdef MOZ_BUILD_WEBRENDER auto* textDrawer = aParams.context->GetTextDrawer(); - if (NS_GET_A(aParams.textColor) != 0 || textDrawer || +#endif + if (NS_GET_A(aParams.textColor) != 0 || +#ifdef MOZ_BUILD_WEBRENDER + textDrawer || +#endif aParams.textStrokeWidth == 0.0f) { aParams.context->SetColor(Color::FromABGR(aParams.textColor)); } else { params.drawMode = DrawMode::GLYPH_STROKE; } - if ((NS_GET_A(aParams.textStrokeColor) != 0 || textDrawer) && + if ((NS_GET_A(aParams.textStrokeColor) != 0 +#ifdef MOZ_BUILD_WEBRENDER + || textDrawer +#endif + ) && aParams.textStrokeWidth != 0.0f) { +#ifdef MOZ_BUILD_WEBRENDER if (textDrawer) { textDrawer->FoundUnsupportedFeature(); return; } +#endif params.drawMode |= DrawMode::GLYPH_STROKE; // Check the paint-order property; if we find stroke before fill, @@ -7139,11 +7159,14 @@ void nsTextFrame::DrawText(Range aRange, const gfx::Point& aTextBaselinePt, DrawTextRun(aRange, aTextBaselinePt, aParams); } +#ifdef MOZ_BUILD_WEBRENDER if (auto* textDrawer = aParams.context->GetTextDrawer()) { textDrawer->TerminateShadows(); } +#endif } +#ifdef MOZ_BUILD_WEBRENDER NS_DECLARE_FRAME_PROPERTY_DELETABLE(WebRenderTextBounds, nsRect) nsRect nsTextFrame::WebRenderBounds() { @@ -7157,6 +7180,7 @@ nsRect nsTextFrame::WebRenderBounds() { } return *cachedBounds; } +#endif int16_t nsTextFrame::GetSelectionStatus(int16_t* aSelectionFlags) { // get the selection controller @@ -8225,9 +8249,9 @@ static bool FindFirstLetterRange(const nsTextFragment* aFrag, } static uint32_t FindStartAfterSkippingWhitespace( - nsTextFrame::PropertyProvider* aProvider, nsIFrame::InlineIntrinsicISizeData* aData, - const nsStyleText* aTextStyle, gfxSkipCharsIterator* aIterator, - uint32_t aFlowEndInTextRun) { + nsTextFrame::PropertyProvider* aProvider, + nsIFrame::InlineIntrinsicISizeData* aData, const nsStyleText* aTextStyle, + gfxSkipCharsIterator* aIterator, uint32_t aFlowEndInTextRun) { if (aData->mSkipWhitespace) { while (aIterator->GetSkippedOffset() < aFlowEndInTextRun && IsTrimmableSpace(aProvider->GetFragment(), @@ -8980,7 +9004,9 @@ void nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth, // reflow request from CharacterDataChanged (since we're reflowing now). RemoveStateBits(TEXT_REFLOW_FLAGS | TEXT_WHITESPACE_FLAGS); mReflowRequestedForCharDataChange = false; +#ifdef MOZ_BUILD_WEBRENDER DeleteProperty(WebRenderTextBounds()); +#endif // Temporarily map all possible content while we construct our new textrun. // so that when doing reflow our styles prevail over any part of the // textrun we look at. Note that next-in-flows may be mapping the same @@ -9646,7 +9672,9 @@ nsTextFrame::TrimOutput nsTextFrame::TrimTrailingWhiteSpace( nsOverflowAreas nsTextFrame::RecomputeOverflow(nsIFrame* aBlockFrame, bool aIncludeShadows) { +#ifdef MOZ_BUILD_WEBRENDER DeleteProperty(WebRenderTextBounds()); +#endif nsRect bounds(nsPoint(0, 0), GetSize()); nsOverflowAreas result(bounds, bounds); @@ -9953,7 +9981,7 @@ bool nsTextFrame::IsEmpty() { bool isEmpty = IsAllWhitespace(TextFragment(), textStyle->mWhiteSpace != - mozilla::StyleWhiteSpace::PreLine); + mozilla::StyleWhiteSpace::PreLine); AddStateBits(isEmpty ? TEXT_IS_ONLY_WHITESPACE : TEXT_ISNOT_ONLY_WHITESPACE); return isEmpty; } diff --git a/layout/generic/nsTextFrame.h b/layout/generic/nsTextFrame.h index 85bdf4de93..d957f2d50e 100644 --- a/layout/generic/nsTextFrame.h +++ b/layout/generic/nsTextFrame.h @@ -782,7 +782,9 @@ class nsTextFrame : public nsFrame { } nsFontMetrics* InflatedFontMetrics() const { return mFontMetrics; } +#ifdef MOZ_BUILD_WEBRENDER nsRect WebRenderBounds(); +#endif protected: virtual ~nsTextFrame(); diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index c102f2b0c7..72df5eae39 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -12,7 +12,9 @@ #include "mozilla/PresShell.h" #include "mozilla/dom/HTMLVideoElement.h" #include "mozilla/dom/ShadowRoot.h" -#include "mozilla/layers/RenderRootStateManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/RenderRootStateManager.h" +#endif #include "nsDisplayList.h" #include "nsGenericHTMLElement.h" #include "nsPresContext.h" @@ -409,6 +411,7 @@ class nsDisplayVideo : public nsPaintedDisplayItem { NS_DISPLAY_DECL_NAME("Video", TYPE_VIDEO) +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -478,6 +481,7 @@ class nsDisplayVideo : public nsPaintedDisplayItem { aSc, rect, rect); return true; } +#endif // For opaque videos, we will want to override GetOpaqueRegion here. // This is tracked by bug 1545498. diff --git a/layout/ipc/RenderFrame.cpp b/layout/ipc/RenderFrame.cpp index 76c123cdc4..d1c73594a2 100644 --- a/layout/ipc/RenderFrame.cpp +++ b/layout/ipc/RenderFrame.cpp @@ -16,9 +16,13 @@ #include "RenderFrame.h" #include "mozilla/gfx/GPUProcessManager.h" #include "mozilla/layers/CompositorBridgeChild.h" -#include "mozilla/layers/WebRenderLayerManager.h" -#include "mozilla/layers/WebRenderScrollData.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderLayerManager.h" +# include "mozilla/layers/WebRenderScrollData.h" +# include "mozilla/webrender/WebRenderAPI.h" +#else +# include "BasicLayers.h" +#endif using namespace mozilla; using namespace mozilla::layers; @@ -256,6 +260,7 @@ void nsDisplayRemote::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { target->DrawDependentSurface(mTabId, destRect); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayRemote::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -295,6 +300,7 @@ bool nsDisplayRemote::UpdateScrollData( } return true; } +#endif nsFrameLoader* nsDisplayRemote::GetFrameLoader() const { return mFrame ? static_cast(mFrame)->FrameLoader() diff --git a/layout/ipc/RenderFrame.h b/layout/ipc/RenderFrame.h index 22335563b0..d42e506671 100644 --- a/layout/ipc/RenderFrame.h +++ b/layout/ipc/RenderFrame.h @@ -111,6 +111,7 @@ class nsDisplayRemote final : public nsPaintedDisplayItem { void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -120,6 +121,7 @@ class nsDisplayRemote final : public nsPaintedDisplayItem { bool UpdateScrollData( mozilla::layers::WebRenderScrollData* aData, mozilla::layers::WebRenderLayerScrollData* aLayerData) override; +#endif NS_DISPLAY_DECL_NAME("Remote", TYPE_REMOTE) diff --git a/layout/mathml/nsMathMLmtableFrame.cpp b/layout/mathml/nsMathMLmtableFrame.cpp index 414699e4b8..6b427fd45a 100644 --- a/layout/mathml/nsMathMLmtableFrame.cpp +++ b/layout/mathml/nsMathMLmtableFrame.cpp @@ -308,6 +308,7 @@ class nsDisplaymtdBorder final : public nsDisplayBorder { nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result); } +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -316,6 +317,7 @@ class nsDisplaymtdBorder final : public nsDisplayBorder { nsDisplayListBuilder* aDisplayListBuilder) override { return false; } +#endif }; #ifdef DEBUG diff --git a/layout/painting/DisplayItemClip.cpp b/layout/painting/DisplayItemClip.cpp index ba12cd6527..e8112e5589 100644 --- a/layout/painting/DisplayItemClip.cpp +++ b/layout/painting/DisplayItemClip.cpp @@ -8,8 +8,10 @@ #include "gfxUtils.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/PathHelpers.h" -#include "mozilla/layers/StackingContextHelper.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/StackingContextHelper.h" +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "nsPresContext.h" #include "nsCSSRendering.h" #include "nsLayoutUtils.h" @@ -476,6 +478,7 @@ nsCString DisplayItemClip::ToString() const { return std::move(str); } +#ifdef MOZ_BUILD_WEBRENDER void DisplayItemClip::ToComplexClipRegions( int32_t aAppUnitsPerDevPixel, nsTArray& aOutArray) const { @@ -484,5 +487,6 @@ void DisplayItemClip::ToComplexClipRegions( clipRect.mRect, clipRect.mRadii, aAppUnitsPerDevPixel)); } } +#endif } // namespace mozilla diff --git a/layout/painting/DisplayItemClip.h b/layout/painting/DisplayItemClip.h index d6d0cf263e..a3b88a1324 100644 --- a/layout/painting/DisplayItemClip.h +++ b/layout/painting/DisplayItemClip.h @@ -18,12 +18,14 @@ namespace gfx { class DrawTarget; class Path; } // namespace gfx +#ifdef MOZ_BUILD_WEBRENDER namespace layers { class StackingContextHelper; } // namespace layers namespace wr { struct ComplexClipRegion; } // namespace wr +#endif } // namespace mozilla namespace mozilla { @@ -171,8 +173,10 @@ class DisplayItemClip { uint32_t GetRoundedRectCount() const { return mRoundedClipRects.Length(); } void AppendRoundedRects(nsTArray* aArray) const; +#ifdef MOZ_BUILD_WEBRENDER void ToComplexClipRegions(int32_t aAppUnitsPerDevPixel, nsTArray& aOutArray) const; +#endif static const DisplayItemClip& NoClip(); diff --git a/layout/painting/FrameLayerBuilder.cpp b/layout/painting/FrameLayerBuilder.cpp index f466217db6..9bc803ef61 100644 --- a/layout/painting/FrameLayerBuilder.cpp +++ b/layout/painting/FrameLayerBuilder.cpp @@ -47,7 +47,9 @@ #include "mozilla/layers/ShadowLayers.h" #include "mozilla/layers/TextureClient.h" #include "mozilla/layers/TextureWrapperImage.h" -#include "mozilla/layers/WebRenderUserData.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderUserData.h" +#endif #include "mozilla/Unused.h" #include "GeckoProfiler.h" #include "LayersLogging.h" @@ -64,7 +66,6 @@ using namespace mozilla::gfx; using mozilla::UniquePtr; using mozilla::WrapUnique; - // PaintedLayerData::mAssignedDisplayItems is a std::vector, which is // non-memmovable DECLARE_USE_COPY_CONSTRUCTORS(mozilla::PaintedLayerData); @@ -517,6 +518,7 @@ void FrameLayerBuilder::DestroyDisplayItemDataFor(nsIFrame* aFrame) { RemoveFrameFromLayerManager(aFrame, aFrame->DisplayItemData()); aFrame->DisplayItemData().Clear(); +#ifdef MOZ_BUILD_WEBRENDER // Destroying a WebRenderUserDataTable can cause destruction of other objects // which can remove frame properties in their destructor. If we delete a frame // property it runs the destructor of the stored object in the middle of @@ -532,6 +534,7 @@ void FrameLayerBuilder::DestroyDisplayItemDataFor(nsIFrame* aFrame) { } delete userDataTable; } +#endif } /** @@ -2339,11 +2342,13 @@ bool FrameLayerBuilder::HasRetainedDataFor(nsIFrame* aFrame, return true; } } +#ifdef MOZ_BUILD_WEBRENDER if (RefPtr data = GetWebRenderUserData(aFrame, aDisplayItemKey)) { return true; } +#endif return false; } @@ -5916,7 +5921,7 @@ void ContainerState::Finish(uint32_t* aTextContentFlags, mPaintedLayerDataTree.Finish(); NS_ASSERTION(mContainerBounds.IsEqualInterior(mAccumulatedChildBounds), - "Bounds computation mismatch"); + "Bounds computation mismatch"); if (mLayerBuilder->IsBuildingRetainedLayers()) { nsIntRegion containerOpaqueRegion; @@ -7306,11 +7311,13 @@ nsDisplayItemGeometry* FrameLayerBuilder::GetMostRecentGeometry( if (firstMatching) { return firstMatching->GetGeometry(); } +#ifdef MOZ_BUILD_WEBRENDER if (RefPtr data = GetWebRenderUserData(aItem->Frame(), itemPerFrameKey)) { return data->GetGeometry(); } +#endif return nullptr; } diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp index 5aef2a7668..5ee90c9ff9 100644 --- a/layout/painting/nsCSSRendering.cpp +++ b/layout/painting/nsCSSRendering.cpp @@ -65,7 +65,9 @@ #include "nsRubyTextContainerFrame.h" #include #include "SVGImageContext.h" -#include "TextDrawTarget.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "TextDrawTarget.h" +#endif using namespace mozilla; using namespace mozilla::css; @@ -665,6 +667,7 @@ Maybe nsCSSRendering::CreateBorderRenderer( aSkipSides); } +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult nsCSSRendering::CreateWebRenderCommandsForBorder( nsDisplayItem* aItem, nsIFrame* aForFrame, const nsRect& aBorderArea, mozilla::wr::DisplayListBuilder& aBuilder, @@ -750,12 +753,12 @@ ImgDrawResult nsCSSRendering::CreateWebRenderCommandsForBorderWithStyleBorder( return bir->CreateWebRenderCommands(aItem, aForFrame, aBuilder, aResources, aSc, aManager, aDisplayListBuilder); } +#endif // MOZ_BUILD_WEBRENDER static nsCSSBorderRenderer ConstructBorderRenderer( - nsPresContext* aPresContext, ComputedStyle* aStyle, - DrawTarget* aDrawTarget, nsIFrame* aForFrame, const nsRect& aDirtyRect, - const nsRect& aBorderArea, const nsStyleBorder& aStyleBorder, - Sides aSkipSides, bool* aNeedsClip) { + nsPresContext* aPresContext, ComputedStyle* aStyle, DrawTarget* aDrawTarget, + nsIFrame* aForFrame, const nsRect& aDirtyRect, const nsRect& aBorderArea, + const nsStyleBorder& aStyleBorder, Sides aSkipSides, bool* aNeedsClip) { nsMargin border = aStyleBorder.GetComputedBorder(); // Compute the outermost boundary of the area that might be painted. @@ -891,8 +894,8 @@ ImgDrawResult nsCSSRendering::PaintBorderWithStyleBorder( bool needsClip = false; nsCSSBorderRenderer br = ConstructBorderRenderer( - aPresContext, aStyle, &aDrawTarget, aForFrame, aDirtyRect, - aBorderArea, aStyleBorder, aSkipSides, &needsClip); + aPresContext, aStyle, &aDrawTarget, aForFrame, aDirtyRect, aBorderArea, + aStyleBorder, aSkipSides, &needsClip); if (needsClip) { aDrawTarget.PushClipRect(NSRectToSnappedRect( aBorderArea, aForFrame->PresContext()->AppUnitsPerDevPixel(), @@ -950,8 +953,8 @@ nsCSSRendering::CreateNullBorderRendererWithStyleBorder( bool needsClip = false; nsCSSBorderRenderer br = ConstructBorderRenderer( - aPresContext, aStyle, aDrawTarget, aForFrame, aDirtyRect, - aBorderArea, aStyleBorder, aSkipSides, &needsClip); + aPresContext, aStyle, aDrawTarget, aForFrame, aDirtyRect, aBorderArea, + aStyleBorder, aSkipSides, &needsClip); return Some(br); } @@ -1865,6 +1868,7 @@ ImgDrawResult nsCSSRendering::PaintStyleImageLayer(const PaintBGParams& aParams, *aParams.frame->StyleBorder()); } +#ifdef MOZ_BUILD_WEBRENDER bool nsCSSRendering::CanBuildWebRenderDisplayItemsForStyleImageLayer( LayerManager* aManager, nsPresContext& aPresCtx, nsIFrame* aFrame, const nsStyleBackground* aBackgroundStyle, int32_t aLayer, @@ -1952,6 +1956,7 @@ ImgDrawResult nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer( aParams, aBuilder, aResources, aSc, aManager, aItem, sc, *aParams.frame->StyleBorder()); } +#endif // MOZ_BUILD_WEBRENDER static bool IsOpaqueBorderEdge(const nsStyleBorder& aBorder, mozilla::Side aSide) { @@ -2360,8 +2365,7 @@ static nscolor GetBackgroundColor(nsIFrame* aFrame, ComputedStyle* aStyle) { default: break; } - return aStyle->GetVisitedDependentColor( - &nsStyleBackground::mBackgroundColor); + return aStyle->GetVisitedDependentColor(&nsStyleBackground::mBackgroundColor); } nscolor nsCSSRendering::DetermineBackgroundColor(nsPresContext* aPresContext, @@ -2658,6 +2662,7 @@ ImgDrawResult nsCSSRendering::PaintStyleImageLayerWithSC( return result; } +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayerWithSC( const PaintBGParams& aParams, mozilla::wr::DisplayListBuilder& aBuilder, @@ -2713,6 +2718,7 @@ nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayerWithSC( return result; } +#endif nsRect nsCSSRendering::ComputeImageLayerPositioningArea( nsPresContext* aPresContext, nsIFrame* aForFrame, const nsRect& aBorderArea, @@ -4166,10 +4172,12 @@ void nsCSSRendering::PaintDecorationLineInternal( AutoPopClips autoPopClips(&aDrawTarget); +#ifdef MOZ_BUILD_WEBRENDER mozilla::layout::TextDrawTarget* textDrawer = nullptr; if (aDrawTarget.GetBackendType() == BackendType::WEBRENDER_TEXT) { textDrawer = static_cast(&aDrawTarget); } +#endif switch (aParams.style) { case NS_STYLE_TEXT_DECORATION_STYLE_SOLID: @@ -4239,12 +4247,16 @@ void nsCSSRendering::PaintDecorationLineInternal( case NS_STYLE_TEXT_DECORATION_STYLE_DASHED: { Point p1 = aRect.TopLeft(); Point p2 = aParams.vertical ? aRect.BottomLeft() : aRect.TopRight(); +#ifdef MOZ_BUILD_WEBRENDER if (textDrawer) { textDrawer->AppendDecoration(p1, p2, lineThickness, aParams.vertical, color, aParams.style); } else { +#endif aDrawTarget.StrokeLine(p1, p2, colorPat, strokeOptions, drawOptions); +#ifdef MOZ_BUILD_WEBRENDER } +#endif return; } case NS_STYLE_TEXT_DECORATION_STYLE_DOUBLE: { @@ -4274,6 +4286,7 @@ void nsCSSRendering::PaintDecorationLineInternal( Point p1b = aParams.vertical ? aRect.TopRight() : aRect.BottomLeft(); Point p2b = aRect.BottomRight(); +#ifdef MOZ_BUILD_WEBRENDER if (textDrawer) { textDrawer->AppendDecoration(p1a, p2a, lineThickness, aParams.vertical, color, @@ -4282,9 +4295,12 @@ void nsCSSRendering::PaintDecorationLineInternal( color, NS_STYLE_TEXT_DECORATION_STYLE_SOLID); } else { +#endif aDrawTarget.StrokeLine(p1a, p2a, colorPat, strokeOptions, drawOptions); aDrawTarget.StrokeLine(p1b, p2b, colorPat, strokeOptions, drawOptions); +#ifdef MOZ_BUILD_WEBRENDER } +#endif return; } case NS_STYLE_TEXT_DECORATION_STYLE_WAVY: { @@ -4334,6 +4350,7 @@ void nsCSSRendering::PaintDecorationLineInternal( aFrame, aParams.style, aRect, aParams.icoordInFrame, cycleLength, aParams.vertical); +#ifdef MOZ_BUILD_WEBRENDER if (textDrawer) { // Undo attempted centering Float& rectBCoord = aParams.vertical ? aRect.x : aRect.y; @@ -4343,6 +4360,7 @@ void nsCSSRendering::PaintDecorationLineInternal( color); return; } +#endif // figure out if we can trim whole cycles from the left and right edges // of the line, to try and avoid creating an unnecessarily long and diff --git a/layout/painting/nsCSSRendering.h b/layout/painting/nsCSSRendering.h index ea2d8e60b9..7ef3510386 100644 --- a/layout/painting/nsCSSRendering.h +++ b/layout/painting/nsCSSRendering.h @@ -33,15 +33,19 @@ class DrawTarget; namespace layers { class ImageContainer; +#ifdef MOZ_BUILD_WEBRENDER class StackingContextHelper; class WebRenderParentCommand; -class LayerManager; class RenderRootStateManager; +#endif +class LayerManager; } // namespace layers +#ifdef MOZ_BUILD_WEBRENDER namespace wr { class DisplayListBuilder; } // namespace wr +#endif enum class PaintBorderFlags : uint8_t { SyncDecodeImages = 1 << 0 }; MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PaintBorderFlags) @@ -203,6 +207,7 @@ struct nsCSSRendering { nsIFrame* aForFrame, const nsRect& aDirtyRect, const nsRect& aBorderArea, mozilla::ComputedStyle* aStyle); +#ifdef MOZ_BUILD_WEBRENDER static ImgDrawResult CreateWebRenderCommandsForBorder( nsDisplayItem* aItem, nsIFrame* aForFrame, const nsRect& aBorderArea, mozilla::wr::DisplayListBuilder& aBuilder, @@ -226,6 +231,7 @@ struct nsCSSRendering { mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder, const nsStyleBorder& aStyleBorder); +#endif /** * Render the outline for an element using css rendering rules @@ -340,9 +346,11 @@ struct nsCSSRendering { /** * Determine the background color to draw taking into account print settings. */ - static nscolor DetermineBackgroundColor( - nsPresContext* aPresContext, mozilla::ComputedStyle* aStyle, - nsIFrame* aFrame, bool& aDrawBackgroundImage, bool& aDrawBackgroundColor); + static nscolor DetermineBackgroundColor(nsPresContext* aPresContext, + mozilla::ComputedStyle* aStyle, + nsIFrame* aFrame, + bool& aDrawBackgroundImage, + bool& aDrawBackgroundColor); static nsRect ComputeImageLayerPositioningArea( nsPresContext* aPresContext, nsIFrame* aForFrame, @@ -490,10 +498,12 @@ struct nsCSSRendering { const PaintBGParams& aParams, gfxContext& aRenderingCtx, mozilla::ComputedStyle* mBackgroundSC, const nsStyleBorder& aBorder); +#ifdef MOZ_BUILD_WEBRENDER static bool CanBuildWebRenderDisplayItemsForStyleImageLayer( LayerManager* aManager, nsPresContext& aPresCtx, nsIFrame* aFrame, const nsStyleBackground* aBackgroundStyle, int32_t aLayer, uint32_t aPaintFlags); + static ImgDrawResult BuildWebRenderDisplayItemsForStyleImageLayer( const PaintBGParams& aParams, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -506,6 +516,7 @@ struct nsCSSRendering { const mozilla::layers::StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayItem* aItem, mozilla::ComputedStyle* mBackgroundSC, const nsStyleBorder& aBorder); +#endif /** * Returns the rectangle covered by the given background layer image, taking diff --git a/layout/painting/nsCSSRenderingBorders.cpp b/layout/painting/nsCSSRenderingBorders.cpp index 5c50305f6f..9f8bd16e83 100644 --- a/layout/painting/nsCSSRenderingBorders.cpp +++ b/layout/painting/nsCSSRenderingBorders.cpp @@ -27,9 +27,11 @@ #include "nsStyleStruct.h" #include "gfx2DGlue.h" #include "gfxGradientCache.h" -#include "mozilla/layers/StackingContextHelper.h" -#include "mozilla/layers/RenderRootStateManager.h" -#include "mozilla/layers/WebRenderLayerManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/RenderRootStateManager.h" +# include "mozilla/layers/StackingContextHelper.h" +# include "mozilla/layers/WebRenderLayerManager.h" +#endif #include "mozilla/Range.h" #include @@ -3333,6 +3335,7 @@ void nsCSSBorderRenderer::DrawBorders() { } } +#ifdef MOZ_BUILD_WEBRENDER void nsCSSBorderRenderer::CreateWebRenderCommands( nsDisplayItem* aItem, wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, @@ -3364,6 +3367,7 @@ void nsCSSBorderRenderer::CreateWebRenderCommands( mBorderWidths[2], mBorderWidths[3]), wrsides, borderRadius); } +#endif /* static */ Maybe @@ -3568,6 +3572,7 @@ ImgDrawResult nsCSSBorderImageRenderer::DrawBorderImage( return result; } +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult nsCSSBorderImageRenderer::CreateWebRenderCommands( nsDisplayItem* aItem, nsIFrame* aForFrame, mozilla::wr::DisplayListBuilder& aBuilder, @@ -3717,6 +3722,7 @@ ImgDrawResult nsCSSBorderImageRenderer::CreateWebRenderCommands( return drawResult; } +#endif // MOZ_BUILD_WEBRENDER nsCSSBorderImageRenderer::nsCSSBorderImageRenderer( const nsCSSBorderImageRenderer& aRhs) diff --git a/layout/painting/nsCSSRenderingBorders.h b/layout/painting/nsCSSRenderingBorders.h index e44c6df13a..33a3a357a7 100644 --- a/layout/painting/nsCSSRenderingBorders.h +++ b/layout/painting/nsCSSRenderingBorders.h @@ -28,9 +28,11 @@ enum class StyleBorderImageRepeat : uint8_t; namespace gfx { class GradientStops; } // namespace gfx +#ifdef MOZ_BUILD_WEBRENDER namespace layers { class StackingContextHelper; } // namespace layers +#endif } // namespace mozilla // define this to enable a bunch of debug dump info @@ -96,10 +98,12 @@ class nsCSSBorderRenderer final { // draw the entire border void DrawBorders(); +#ifdef MOZ_BUILD_WEBRENDER void CreateWebRenderCommands( nsDisplayItem* aItem, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const mozilla::layers::StackingContextHelper& aSc); +#endif // utility function used for background painting as well as borders static void ComputeInnerRadii(const RectCornerRadii& aRadii, @@ -269,6 +273,7 @@ class nsCSSBorderImageRenderer final { gfxContext& aRenderingContext, nsIFrame* aForFrame, const nsRect& aDirtyRect); +#ifdef MOZ_BUILD_WEBRENDER mozilla::image::ImgDrawResult CreateWebRenderCommands( nsDisplayItem* aItem, nsIFrame* aForFrame, mozilla::wr::DisplayListBuilder& aBuilder, @@ -276,6 +281,7 @@ class nsCSSBorderImageRenderer final { const mozilla::layers::StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder); +#endif nsCSSBorderImageRenderer(const nsCSSBorderImageRenderer& aRhs); nsCSSBorderImageRenderer& operator=(const nsCSSBorderImageRenderer& aRhs); diff --git a/layout/painting/nsCSSRenderingGradients.cpp b/layout/painting/nsCSSRenderingGradients.cpp index c32a124342..27183d7d7d 100644 --- a/layout/painting/nsCSSRenderingGradients.cpp +++ b/layout/painting/nsCSSRenderingGradients.cpp @@ -25,10 +25,12 @@ #include "gfxUtils.h" #include "gfxGradientCache.h" -#include "mozilla/layers/StackingContextHelper.h" -#include "mozilla/layers/WebRenderLayerManager.h" -#include "mozilla/webrender/WebRenderTypes.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/StackingContextHelper.h" +# include "mozilla/layers/WebRenderLayerManager.h" +# include "mozilla/webrender/WebRenderTypes.h" +# include "mozilla/webrender/WebRenderAPI.h" +#endif #include "Units.h" using namespace mozilla; @@ -1109,6 +1111,7 @@ bool nsCSSGradientRenderer::TryPaintTilesWithExtendMode( return true; } +#ifdef MOZ_BUILD_WEBRENDER void nsCSSGradientRenderer::BuildWebRenderParameters( float aOpacity, wr::ExtendMode& aMode, nsTArray& aStops, LayoutDevicePoint& aLineStart, LayoutDevicePoint& aLineEnd, @@ -1203,5 +1206,6 @@ void nsCSSGradientRenderer::BuildWebRenderDisplayItems( mozilla::wr::ToLayoutSize(tileSpacing)); } } +#endif // MOZ_BUILD_WEBRENDER } // namespace mozilla diff --git a/layout/painting/nsCSSRenderingGradients.h b/layout/painting/nsCSSRenderingGradients.h index 6e254ddf53..161c6c4adf 100644 --- a/layout/painting/nsCSSRenderingGradients.h +++ b/layout/painting/nsCSSRenderingGradients.h @@ -56,6 +56,7 @@ class nsCSSGradientRenderer final { const nsSize& aRepeatSize, const mozilla::CSSIntRect& aSrc, const nsRect& aDirtyRect, float aOpacity = 1.0); +#ifdef MOZ_BUILD_WEBRENDER /** * Collect the gradient parameters */ @@ -81,6 +82,7 @@ class nsCSSGradientRenderer final { const mozilla::CSSIntRect& aSrc, bool aIsBackfaceVisible, float aOpacity = 1.0); +#endif private: nsCSSGradientRenderer() diff --git a/layout/painting/nsDisplayItemTypesList.h b/layout/painting/nsDisplayItemTypesList.h index c235f5e021..3566820830 100644 --- a/layout/painting/nsDisplayItemTypesList.h +++ b/layout/painting/nsDisplayItemTypesList.h @@ -5,8 +5,10 @@ DECLARE_DISPLAY_ITEM_TYPE(ALT_FEEDBACK, 0) DECLARE_DISPLAY_ITEM_TYPE(ASYNC_ZOOM, TYPE_RENDERS_NO_IMAGES | TYPE_IS_CONTAINER) +#ifdef MOZ_BUILD_WEBRENDER DECLARE_DISPLAY_ITEM_TYPE(BACKDROP_FILTER, TYPE_IS_CONTAINER) DECLARE_DISPLAY_ITEM_TYPE(BACKDROP_ROOT_CONTAINER, TYPE_IS_CONTAINER) +#endif DECLARE_DISPLAY_ITEM_TYPE(BACKGROUND, TYPE_IS_CONTENTFUL) DECLARE_DISPLAY_ITEM_TYPE(BACKGROUND_COLOR, TYPE_RENDERS_NO_IMAGES) DECLARE_DISPLAY_ITEM_TYPE(BLEND_CONTAINER, diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 7d5dd02861..6e91ed7973 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -98,13 +98,15 @@ #include "nsFocusManager.h" #include "ClientLayerManager.h" #include "mozilla/layers/AnimationHelper.h" -#include "mozilla/layers/RenderRootStateManager.h" -#include "mozilla/layers/StackingContextHelper.h" #include "mozilla/layers/TreeTraversal.h" -#include "mozilla/layers/WebRenderBridgeChild.h" -#include "mozilla/layers/WebRenderLayerManager.h" -#include "mozilla/layers/WebRenderMessages.h" -#include "mozilla/layers/WebRenderScrollData.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/RenderRootStateManager.h" +# include "mozilla/layers/StackingContextHelper.h" +# include "mozilla/layers/WebRenderBridgeChild.h" +# include "mozilla/layers/WebRenderLayerManager.h" +# include "mozilla/layers/WebRenderMessages.h" +# include "mozilla/layers/WebRenderScrollData.h" +#endif #include "mozilla/layout/RenderFrame.h" using namespace mozilla; @@ -878,6 +880,7 @@ static void AddAnimationsForDisplayItem(nsIFrame* aFrame, } } +#ifdef MOZ_BUILD_WEBRENDER static uint64_t AddAnimationsForWebRender( nsDisplayItem* aItem, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder, wr::RenderRoot aRenderRoot) { @@ -907,6 +910,7 @@ static uint64_t AddAnimationsForWebRender( return animationsId; } +#endif static bool GenerateAndPushTextMask(nsIFrame* aFrame, gfxContext* aContext, const nsRect& aFillRect, @@ -1179,7 +1183,9 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame, mCurrentContainerASR(nullptr), mCurrentFrame(aReferenceFrame), mCurrentReferenceFrame(aReferenceFrame), +#ifdef MOZ_BUILD_WEBRENDER mNeedsDisplayListBuild{}, +#endif mRootAGR(AnimatedGeometryRoot::CreateAGRForFrame( aReferenceFrame, nullptr, true, aRetainingDisplayList)), mCurrentAGR(mRootAGR), @@ -1213,7 +1219,9 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame, mIsInChromePresContext(false), mSyncDecodeImages(false), mIsPaintingToWindow(false), +#ifdef MOZ_BUILD_WEBRENDER mIsPaintingForWebRender(false), +#endif mIsCompositingCheap(false), mContainsPluginItem(false), mAncestorHasApzAwareEventHandler(false), @@ -1230,8 +1238,10 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame, mPartialBuildFailed(false), mIsInActiveDocShell(false), mBuildAsyncZoomContainer(false), +#ifdef MOZ_BUILD_WEBRENDER mBuildBackdropRootContainer(false), mContainsBackdropFilter(false), +#endif mHitTestArea(), mHitTestInfo(CompositorHitTestInvisibleToHit) { MOZ_COUNT_CTOR(nsDisplayListBuilder); @@ -1270,6 +1280,7 @@ void nsDisplayListBuilder::BeginFrame() { mInTransform = false; mInFilter = false; mSyncDecodeImages = false; +#ifdef MOZ_BUILD_WEBRENDER for (auto& needsDisplayListBuild : mNeedsDisplayListBuild) { needsDisplayListBuild = false; } @@ -1277,6 +1288,7 @@ void nsDisplayListBuilder::BeginFrame() { for (auto& renderRootRect : mRenderRootRects) { renderRootRect = LayoutDeviceRect(); } +#endif if (!mBuildCaret) { return; @@ -1360,7 +1372,7 @@ void nsDisplayListBuilder::SetGlassDisplayItem(nsDisplayItem* aItem) { NS_WARNING("Multiple glass backgrounds found?"); } else #endif - if (!mHasGlassItemDuringPartial) { + if (!mHasGlassItemDuringPartial) { mHasGlassItemDuringPartial = true; aItem->SetIsGlassItem(); } @@ -1374,7 +1386,7 @@ void nsDisplayListBuilder::SetGlassDisplayItem(nsDisplayItem* aItem) { NS_WARNING("Multiple glass backgrounds found?"); } else #endif - if (!mGlassDisplayItem) { + if (!mGlassDisplayItem) { mGlassDisplayItem = aItem; mGlassDisplayItem->SetIsGlassItem(); } @@ -1465,10 +1477,12 @@ void nsDisplayListBuilder::UpdateShouldBuildAsyncZoomContainer() { mBuildAsyncZoomContainer = nsLayoutUtils::AllowZoomingForDocument(document); } +#ifdef MOZ_BUILD_WEBRENDER void nsDisplayListBuilder::UpdateShouldBuildBackdropRootContainer() { mBuildBackdropRootContainer = StaticPrefs::layout_css_backdrop_filter_enabled(); } +#endif // Certain prefs may cause display list items to be added or removed when they // are toggled. In those cases, we need to fully rebuild the display list. @@ -1485,6 +1499,7 @@ bool nsDisplayListBuilder::ShouldRebuildDisplayListDueToPrefChange() { shouldRebuild = true; } +#ifdef MOZ_BUILD_WEBRENDER // If backdrop-filter is enabled, backdrop root containers are added to the // display list. When the pref is toggled these containers may be added or // removed, so the display list should be rebuilt. @@ -1493,6 +1508,7 @@ bool nsDisplayListBuilder::ShouldRebuildDisplayListDueToPrefChange() { if (didBuildBackdropRootContainer != mBuildBackdropRootContainer) { shouldRebuild = true; } +#endif return shouldRebuild; } @@ -1583,14 +1599,19 @@ uint32_t nsDisplayListBuilder::GetImageDecodeFlags() const { return flags; } -void nsDisplayListBuilder::ComputeDefaultRenderRootRect(LayoutDeviceIntSize aClientSize) { +#ifdef MOZ_BUILD_WEBRENDER +void nsDisplayListBuilder::ComputeDefaultRenderRootRect( + LayoutDeviceIntSize aClientSize) { LayoutDeviceIntRegion cutout; LayoutDeviceIntRect clientRect(LayoutDeviceIntPoint(), aClientSize); cutout.OrWith(clientRect); - cutout.SubOut(RoundedToInt(mRenderRootRects[mozilla::wr::RenderRoot::Content])); + cutout.SubOut( + RoundedToInt(mRenderRootRects[mozilla::wr::RenderRoot::Content])); - mRenderRootRects[mozilla::wr::RenderRoot::Default] = LayoutDeviceRect(cutout.GetBounds()); + mRenderRootRects[mozilla::wr::RenderRoot::Default] = + LayoutDeviceRect(cutout.GetBounds()); } +#endif void nsDisplayListBuilder::SubtractFromVisibleRegion(nsRegion* aVisibleRegion, const nsRegion& aRegion) { @@ -2843,7 +2864,6 @@ FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder, bool aIsWidgetTransaction) { nsIFrame* frame = aBuilder->RootReferenceFrame(); nsPresContext* presContext = frame->PresContext(); - PresShell* presShell = presContext->PresShell(); FrameLayerBuilder* layerBuilder = new FrameLayerBuilder(); layerBuilder->Init(aBuilder, aLayerManager); @@ -3004,6 +3024,7 @@ already_AddRefed nsDisplayList::PaintRoot( rootPresContext->CollectPluginGeometryUpdates(layerManager); } +#ifdef MOZ_BUILD_WEBRENDER auto* wrManager = static_cast(layerManager.get()); nsIDocShell* docShell = presContext->GetDocShell(); @@ -3017,6 +3038,7 @@ already_AddRefed nsDisplayList::PaintRoot( wrManager->EndTransactionWithoutLayer(this, aBuilder, std::move(wrFilters)); +#endif } // For layers-free mode, we check the invalidation state bits in the @@ -3642,6 +3664,7 @@ nsDisplayContainer::nsDisplayContainer( nsDisplayItem::SetClipChain(nullptr, true); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayContainer::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -3652,6 +3675,7 @@ bool nsDisplayContainer::CreateWebRenderCommands( GetChildren(), this, aDisplayListBuilder, aSc, aBuilder, aResources); return true; } +#endif /** * Like |nsDisplayList::ComputeVisibilityForSublist()|, but restricts @@ -3792,6 +3816,7 @@ void nsDisplaySolidColor::WriteDebugInfo(std::stringstream& aStream) { << ")"; } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplaySolidColor::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -3824,6 +3849,7 @@ bool nsDisplaySolidColor::CreateWebRenderCommands( return true; } +#endif nsRect nsDisplaySolidColorRegion::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const { @@ -3848,6 +3874,7 @@ void nsDisplaySolidColorRegion::WriteDebugInfo(std::stringstream& aStream) { << "," << int(mColor.b * 255) << "," << mColor.a << ")"; } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplaySolidColorRegion::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -3865,6 +3892,7 @@ bool nsDisplaySolidColorRegion::CreateWebRenderCommands( return true; } +#endif static void RegisterThemeGeometry(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem, nsIFrame* aFrame, @@ -4488,6 +4516,7 @@ already_AddRefed nsDisplayBackgroundImage::BuildLayer( return layer.forget(); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayBackgroundImage::CanBuildWebRenderDisplayItems( LayerManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) { if (aDisplayListBuilder) { @@ -4528,6 +4557,7 @@ bool nsDisplayBackgroundImage::CreateWebRenderCommands( nsDisplayBackgroundGeometry::UpdateDrawResult(this, result); return true; } +#endif void nsDisplayBackgroundImage::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect, @@ -4866,6 +4896,7 @@ void nsDisplayThemedBackground::PaintInternal(nsDisplayListBuilder* aBuilder, drawing); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayThemedBackground::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -4877,6 +4908,7 @@ bool nsDisplayThemedBackground::CreateWebRenderCommands( aManager, StyleFrame(), mAppearance, mBackgroundRect); } +#endif bool nsDisplayThemedBackground::IsWindowActive() const { EventStates docState = mFrame->GetContent()->OwnerDoc()->GetDocumentState(); @@ -5101,6 +5133,7 @@ already_AddRefed nsDisplayBackgroundColor::BuildLayer( return layer.forget(); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayBackgroundColor::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -5124,6 +5157,7 @@ bool nsDisplayBackgroundColor::CreateWebRenderCommands( return true; } +#endif void nsDisplayBackgroundColor::PaintWithClip(nsDisplayListBuilder* aBuilder, gfxContext* aCtx, @@ -5292,6 +5326,7 @@ already_AddRefed nsDisplayClearBackground::BuildLayer( return layer.forget(); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayClearBackground::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -5306,6 +5341,7 @@ bool nsDisplayClearBackground::CreateWebRenderCommands( return true; } +#endif nsRect nsDisplayOutline::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const { @@ -5324,6 +5360,7 @@ void nsDisplayOutline::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { nsRect(offset, mFrame->GetSize()), mFrame->Style()); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayOutline::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -5358,6 +5395,7 @@ bool nsDisplayOutline::CreateWebRenderCommands( borderRenderer->CreateWebRenderCommands(this, aBuilder, aResources, aSc); return true; } +#endif bool nsDisplayOutline::IsInvisibleInRect(const nsRect& aRect) const { const nsStyleOutline* outline = mFrame->StyleOutline(); @@ -5385,6 +5423,7 @@ void nsDisplayEventReceiver::HitTest(nsDisplayListBuilder* aBuilder, aOutFrames->AppendElement(mFrame); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayEventReceiver::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -5396,6 +5435,7 @@ bool nsDisplayEventReceiver::CreateWebRenderCommands( MOZ_ASSERT(false); return true; } +#endif nsDisplayCompositorHitTestInfo::nsDisplayCompositorHitTestInfo( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, @@ -5440,6 +5480,7 @@ void nsDisplayCompositorHitTestInfo::InitializeScrollTarget( } } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayCompositorHitTestInfo::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -5482,6 +5523,7 @@ bool nsDisplayCompositorHitTestInfo::CreateWebRenderCommands( return true; } +#endif uint16_t nsDisplayCompositorHitTestInfo::CalculatePerFrameKey() const { return mIndex; @@ -5521,6 +5563,7 @@ void nsDisplayCaret::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { mCaret->PaintCaret(*aCtx->GetDrawTarget(), mFrame, ToReferenceFrame()); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayCaret::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -5558,6 +5601,7 @@ bool nsDisplayCaret::CreateWebRenderCommands( } return true; } +#endif nsDisplayBorder::nsDisplayBorder(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) @@ -5615,6 +5659,7 @@ LayerState nsDisplayBorder::GetLayerState( return LayerState::LAYER_NONE; } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayBorder::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -5634,6 +5679,7 @@ bool nsDisplayBorder::CreateWebRenderCommands( nsDisplayBorderGeometry::UpdateDrawResult(this, drawResult); return true; }; +#endif void nsDisplayBorder::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { nsPoint offset = ToReferenceFrame(); @@ -5742,6 +5788,7 @@ bool nsDisplayBoxShadowOuter::ComputeVisibility(nsDisplayListBuilder* aBuilder, return true; } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayBoxShadowOuter::CanBuildWebRenderDisplayItems() { auto shadows = mFrame->StyleEffects()->mBoxShadow.AsSpan(); if (shadows.IsEmpty()) { @@ -5849,6 +5896,7 @@ bool nsDisplayBoxShadowOuter::CreateWebRenderCommands( return true; } +#endif // MOZ_BUILD_WEBRENDER void nsDisplayBoxShadowOuter::ComputeInvalidationRegion( nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry, @@ -5897,6 +5945,7 @@ void nsDisplayBoxShadowInner::Paint(nsDisplayListBuilder* aBuilder, } } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayBoxShadowInner::CanCreateWebRenderCommands( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, const nsPoint& aReferenceOffset) { @@ -6001,6 +6050,7 @@ bool nsDisplayBoxShadowInner::CreateWebRenderCommands( return true; } +#endif // MOZ_BUILD_WEBRENDER bool nsDisplayBoxShadowInner::ComputeVisibility(nsDisplayListBuilder* aBuilder, nsRegion* aVisibleRegion) { @@ -6214,6 +6264,7 @@ void nsDisplayWrapList::SetReferenceFrame(const nsIFrame* aFrame) { mToReferenceFrame = mFrame->GetOffsetToCrossDoc(mReferenceFrame); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayWrapList::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -6224,6 +6275,7 @@ bool nsDisplayWrapList::CreateWebRenderCommands( GetChildren(), this, aDisplayListBuilder, aSc, aBuilder, aResources); return true; } +#endif static nsresult WrapDisplayList(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, @@ -6552,7 +6604,12 @@ bool nsDisplayOpacity::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) { // Return true if we successfully applied opacity to child items, or if // WebRender is not in use. In the latter case, the opacity gets flattened and // applied during layer building. - return ApplyOpacityToChildren(aBuilder) || !gfxVars::UseWebRender(); + return ApplyOpacityToChildren(aBuilder) || +#ifdef MOZ_BUILD_WEBRENDER + !gfxVars::UseWebRender(); +#else + true; +#endif } nsDisplayItem::LayerState nsDisplayOpacity::GetLayerState( @@ -6604,6 +6661,7 @@ void nsDisplayOpacity::WriteDebugInfo(std::stringstream& aStream) { aStream << " (opacity " << mOpacity << ")"; } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayOpacity::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -6631,6 +6689,7 @@ bool nsDisplayOpacity::CreateWebRenderCommands( &mList, this, aDisplayListBuilder, sc, aBuilder, aResources); return true; } +#endif nsDisplayBlendMode::nsDisplayBlendMode( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, @@ -6655,6 +6714,7 @@ LayerState nsDisplayBlendMode::GetLayerState( return LayerState::LAYER_ACTIVE; } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayBlendMode::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -6672,6 +6732,7 @@ bool nsDisplayBlendMode::CreateWebRenderCommands( return nsDisplayWrapList::CreateWebRenderCommands( aBuilder, aResources, sc, aManager, aDisplayListBuilder); } +#endif // nsDisplayBlendMode uses layers for rendering already_AddRefed nsDisplayBlendMode::BuildLayer( @@ -6779,6 +6840,7 @@ LayerState nsDisplayBlendContainer::GetLayerState( GetAnimatedGeometryRoot()); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayBlendContainer::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -6794,6 +6856,7 @@ bool nsDisplayBlendContainer::CreateWebRenderCommands( return nsDisplayWrapList::CreateWebRenderCommands( aBuilder, aResources, sc, aManager, aDisplayListBuilder); } +#endif /* static */ nsDisplayTableBlendContainer* @@ -6813,8 +6876,12 @@ nsDisplayOwnLayer::nsDisplayOwnLayer( aClearClipChain), mFlags(aFlags), mScrollbarData(aScrollbarData), - mForceActive(aForceActive), - mWrAnimationId(0) { + mForceActive(aForceActive) +#ifdef MOZ_BUILD_WEBRENDER + , + mWrAnimationId(0) +#endif +{ MOZ_COUNT_CTOR(nsDisplayOwnLayer); // For scroll thumb layers, override the AGR to be the thumb's AGR rather @@ -6870,6 +6937,7 @@ already_AddRefed nsDisplayOwnLayer::BuildLayer( return layer.forget(); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayOwnLayer::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -6945,6 +7013,7 @@ bool nsDisplayOwnLayer::UpdateScrollData( } return true; } +#endif // MOZ_BUILD_WEBRENDER void nsDisplayOwnLayer::WriteDebugInfo(std::stringstream& aStream) { aStream << nsPrintfCString(" (flags 0x%x) (scrolltarget %" PRIu64 ")", @@ -6952,6 +7021,7 @@ void nsDisplayOwnLayer::WriteDebugInfo(std::stringstream& aStream) { .get(); } +#ifdef MOZ_BUILD_WEBRENDER nsDisplayRenderRoot::nsDisplayRenderRoot( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, const ActiveScrolledRoot* aActiveScrolledRoot, wr::RenderRoot aRenderRoot) @@ -7069,6 +7139,7 @@ void nsDisplayRenderRoot::ExpandDisplayListBuilderRenderRootRect( mFrame->PresContext()->AppUnitsPerDevPixel()); aBuilder->ExpandRenderRootRect(rect, mRenderRoot); } +#endif // MOZ_BUILD_WEBRENDER nsDisplaySubDocument::nsDisplaySubDocument(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, @@ -7319,6 +7390,7 @@ ViewID nsDisplayFixedPosition::GetScrollTargetId() { return nsLayoutUtils::ScrollIdForRootScrollFrame(mFrame->PresContext()); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayFixedPosition::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -7343,6 +7415,7 @@ bool nsDisplayFixedPosition::UpdateScrollData( } return nsDisplayOwnLayer::UpdateScrollData(aData, aLayerData) | true; } +#endif void nsDisplayFixedPosition::WriteDebugInfo(std::stringstream& aStream) { aStream << nsPrintfCString(" (containerASR %s) (scrolltarget %" PRIu64 ")", @@ -7483,6 +7556,7 @@ already_AddRefed nsDisplayStickyPosition::BuildLayer( return layer.forget(); } +#ifdef MOZ_BUILD_WEBRENDER // Returns the smallest distance from "0" to the range [min, max] where // min <= max. static nscoord DistanceToRange(nscoord min, nscoord max) { @@ -7666,6 +7740,7 @@ bool nsDisplayStickyPosition::CreateWebRenderCommands( return true; } +#endif // MOZ_BUILD_WEBRENDER nsDisplayScrollInfoLayer::nsDisplayScrollInfoLayer( nsDisplayListBuilder* aBuilder, nsIFrame* aScrolledFrame, @@ -7717,6 +7792,7 @@ UniquePtr nsDisplayScrollInfoLayer::ComputeScrollMetadata( return UniquePtr(new ScrollMetadata(metadata)); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayScrollInfoLayer::UpdateScrollData( mozilla::layers::WebRenderScrollData* aData, mozilla::layers::WebRenderLayerScrollData* aLayerData) { @@ -7729,6 +7805,7 @@ bool nsDisplayScrollInfoLayer::UpdateScrollData( } return true; } +#endif void nsDisplayScrollInfoLayer::WriteDebugInfo(std::stringstream& aStream) { aStream << " (scrollframe " << mScrollFrame << " scrolledFrame " @@ -7945,10 +8022,12 @@ void nsDisplayTransform::Init(nsDisplayListBuilder* aBuilder, } bool nsDisplayTransform::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) { +#ifdef MOZ_BUILD_WEBRENDER if (gfxVars::UseWebRender() || !StaticPrefs::layout_display_list_flatten_transform()) { return false; } +#endif MOZ_ASSERT(!mShouldFlatten); mShouldFlatten = GetTransform().Is2D(); @@ -8304,6 +8383,7 @@ auto nsDisplayTransform::ShouldPrerenderTransformedContent( return FullPrerender; } +#ifdef MOZ_BUILD_WEBRENDER // If painting is for WebRender, allow full prerender even for large size // frame. With WebRender, memory usage increase for async animation is limited // compared to non-WebRender case. @@ -8311,6 +8391,7 @@ auto nsDisplayTransform::ShouldPrerenderTransformedContent( *aDirtyRect = overflow; return FullPrerender; } +#endif float viewportRatioX = StaticPrefs::layout_animation_prerender_viewport_ratio_limit_x(); @@ -8491,6 +8572,7 @@ const Matrix4x4& nsDisplayTransform::GetAccumulatedPreserved3DTransform( return *mTransformPreserves3D; } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayTransform::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -8582,6 +8664,7 @@ bool nsDisplayTransform::UpdateScrollData( } return true; } +#endif // MOZ_BUILD_WEBRENDER bool nsDisplayTransform::ShouldSkipTransform( nsDisplayListBuilder* aBuilder) const { @@ -9192,6 +9275,7 @@ nsRegion nsDisplayPerspective::GetOpaqueRegion(nsDisplayListBuilder* aBuilder, return GetChildren()->GetTop()->GetOpaqueRegion(aBuilder, aSnap); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayPerspective::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -9278,6 +9362,7 @@ bool nsDisplayPerspective::CreateWebRenderCommands( return true; } +#endif // MOZ_BUILD_WEBRENDER nsDisplayText::nsDisplayText(nsDisplayListBuilder* aBuilder, nsTextFrame* aFrame, @@ -9322,6 +9407,7 @@ void nsDisplayText::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { RenderToContext(aCtx, aBuilder); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayText::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -9361,6 +9447,7 @@ bool nsDisplayText::CreateWebRenderCommands( return textDrawer->GetTextDrawer()->Finish(); } +#endif void nsDisplayText::RenderToContext(gfxContext* aCtx, nsDisplayListBuilder* aBuilder, @@ -9397,11 +9484,13 @@ void nsDisplayText::RenderToContext(gfxContext* aCtx, if (f->Style()->IsTextCombined()) { float scaleFactor = nsTextFrame::GetTextCombineScaleFactor(f); if (scaleFactor != 1.0f) { +#ifdef MOZ_BUILD_WEBRENDER if (auto* textDrawer = aCtx->GetTextDrawer()) { // WebRender doesn't support scaling text like this yet textDrawer->FoundUnsupportedFeature(); return; } +#endif matrixSR.SetContext(aCtx); // Setup matrix to compress text for text-combine-upright if // necessary. This is done here because we want selection be @@ -9899,6 +9988,7 @@ void nsDisplayMasksAndClipPaths::PaintWithContentsPaintCallback( nsDisplayMasksAndClipPathsGeometry::UpdateDrawResult(this, imgParams.result); } +#ifdef MOZ_BUILD_WEBRENDER static Maybe CreateSimpleClipRegion( const nsDisplayMasksAndClipPaths& aDisplayItem, wr::DisplayListBuilder& aBuilder) { @@ -10047,6 +10137,7 @@ bool nsDisplayMasksAndClipPaths::CreateWebRenderCommands( return true; } +#endif Maybe nsDisplayMasksAndClipPaths::GetClipWithRespectToASR( nsDisplayListBuilder* aBuilder, const ActiveScrolledRoot* aASR) const { @@ -10108,6 +10199,7 @@ void nsDisplayMasksAndClipPaths::PrintEffects(nsACString& aTo) { } #endif +#ifdef MOZ_BUILD_WEBRENDER already_AddRefed nsDisplayBackdropRootContainer::BuildLayer( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) { @@ -10194,6 +10286,7 @@ bool nsDisplayBackdropFilters::CreateWebRenderCommands( aDisplayListBuilder); return true; } +#endif // MOZ_BUILD_WEBRENDER /* static */ nsDisplayFilters::nsDisplayFilters(nsDisplayListBuilder* aBuilder, @@ -10284,6 +10377,7 @@ void nsDisplayFilters::PaintAsLayer(nsDisplayListBuilder* aBuilder, nsDisplayFiltersGeometry::UpdateDrawResult(this, imgParams.result); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayFilters::CanCreateWebRenderCommands() { return nsSVGIntegrationUtils::CanCreateWebRenderFiltersForFrame(mFrame); } @@ -10331,6 +10425,7 @@ bool nsDisplayFilters::CreateWebRenderCommands( return true; } +#endif // MOZ_BUILD_WEBRENDER #ifdef MOZ_DUMP_PAINTING void nsDisplayFilters::PrintEffects(nsACString& aTo) { @@ -10396,6 +10491,7 @@ already_AddRefed nsDisplaySVGWrapper::BuildLayer( return container.forget(); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplaySVGWrapper::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -10413,11 +10509,11 @@ nsDisplayForeignObject::nsDisplayForeignObject(nsDisplayListBuilder* aBuilder, MOZ_COUNT_CTOR(nsDisplayForeignObject); } -#ifdef NS_BUILD_REFCNT_LOGGING +# ifdef NS_BUILD_REFCNT_LOGGING nsDisplayForeignObject::~nsDisplayForeignObject() { MOZ_COUNT_DTOR(nsDisplayForeignObject); } -#endif +# endif LayerState nsDisplayForeignObject::GetLayerState( nsDisplayListBuilder* aBuilder, LayerManager* aManager, @@ -10464,6 +10560,7 @@ bool nsDisplayForeignObject::CreateWebRenderCommands( return nsDisplayWrapList::CreateWebRenderCommands( aBuilder, aResources, aSc, aManager, aDisplayListBuilder); } +#endif // MOZ_BUILD_WEBRENDER void nsDisplayListCollection::SerializeWithCorrectZOrder( nsDisplayList* aOutResultList, nsIContent* aContent) { diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index 6947b2e902..63d498a9ff 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -39,7 +39,9 @@ #include "mozilla/TimeStamp.h" #include "mozilla/gfx/UserData.h" #include "mozilla/layers/LayerAttributes.h" -#include "mozilla/layers/RenderRootBoundary.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/RenderRootBoundary.h" +#endif #include "mozilla/layers/ScrollableLayerGuid.h" #include "nsCSSRenderingBorders.h" #include "nsPresArena.h" @@ -64,17 +66,20 @@ class nsDisplayCompositorHitTestInfo; class nsDisplayScrollInfoLayer; class nsCaret; enum class nsDisplayOwnLayerFlags; +#ifdef MOZ_BUILD_WEBRENDER struct WrFiltersHolder; +#endif namespace mozilla { class FrameLayerBuilder; class PresShell; namespace layers { struct FrameMetrics; -class RenderRootStateManager; class Layer; class ImageLayer; class ImageContainer; +#ifdef MOZ_BUILD_WEBRENDER +class RenderRootStateManager; class StackingContextHelper; class WebRenderCommand; class WebRenderScrollData; @@ -83,6 +88,9 @@ class WebRenderLayerScrollData; namespace wr { class DisplayListBuilder; } // namespace wr +#else +} // namespace layers +#endif namespace dom { class Selection; } // namespace dom @@ -626,9 +634,7 @@ class nsDisplayListBuilder { void SetPartialUpdate(bool aPartial) { mPartialUpdate = aPartial; } bool IsBuilding() const { return mIsBuilding; } - void SetIsBuilding(bool aIsBuilding) { - mIsBuilding = aIsBuilding; - } + void SetIsBuilding(bool aIsBuilding) { mIsBuilding = aIsBuilding; } bool InInvalidSubtree() const { return mInInvalidSubtree; } @@ -647,6 +653,7 @@ class nsDisplayListBuilder { */ void SetPaintingToWindow(bool aToWindow) { mIsPaintingToWindow = aToWindow; } bool IsPaintingToWindow() const { return mIsPaintingToWindow; } +#ifdef MOZ_BUILD_WEBRENDER /** * Call this if we're doing painting for WebRender */ @@ -654,6 +661,7 @@ class nsDisplayListBuilder { mIsPaintingForWebRender = true; } bool IsPaintingForWebRender() const { return mIsPaintingForWebRender; } +#endif /** * Call this to prevent descending into subdocuments. */ @@ -903,6 +911,7 @@ class nsDisplayListBuilder { void SubtractFromVisibleRegion(nsRegion* aVisibleRegion, const nsRegion& aRegion); +#ifdef MOZ_BUILD_WEBRENDER void SetNeedsDisplayListBuild(mozilla::wr::RenderRoot aRenderRoot) { MOZ_ASSERT(aRenderRoot != mozilla::wr::RenderRoot::Default); mNeedsDisplayListBuild[aRenderRoot] = true; @@ -925,6 +934,7 @@ class nsDisplayListBuilder { LayoutDeviceRect GetRenderRootRect(mozilla::wr::RenderRoot aRenderRoot) { return mRenderRootRects[aRenderRoot]; } +#endif /** * Mark the frames in aFrames to be displayed if they intersect aDirtyRect @@ -1612,10 +1622,12 @@ class nsDisplayListBuilder { * nsDisplayBackdropRootContainer in the stacking context of the nearest * ancestor that forms a backdrop root. */ +#ifdef MOZ_BUILD_WEBRENDER void SetContainsBackdropFilter(bool aContainsBackdropFilter) { mContainsBackdropFilter = aContainsBackdropFilter; } bool ContainsBackdropFilter() const { return mContainsBackdropFilter; } +#endif DisplayListClipState& ClipState() { return mClipState; } const ActiveScrolledRoot* CurrentActiveScrolledRoot() { @@ -1723,7 +1735,9 @@ class nsDisplayListBuilder { } void UpdateShouldBuildAsyncZoomContainer(); +#ifdef MOZ_BUILD_WEBRENDER void UpdateShouldBuildBackdropRootContainer(); +#endif bool ShouldRebuildDisplayListDueToPrefChange(); @@ -1881,8 +1895,10 @@ class nsDisplayListBuilder { // The offset from mCurrentFrame to mCurrentReferenceFrame. nsPoint mCurrentOffsetToReferenceFrame; +#ifdef MOZ_BUILD_WEBRENDER mozilla::wr::RenderRootArray mRenderRootRects; mozilla::wr::NonDefaultRenderRootArray mNeedsDisplayListBuild; +#endif RefPtr mRootAGR; RefPtr mCurrentAGR; @@ -1973,7 +1989,9 @@ class nsDisplayListBuilder { bool mIsInChromePresContext; bool mSyncDecodeImages; bool mIsPaintingToWindow; +#ifdef MOZ_BUILD_WEBRENDER bool mIsPaintingForWebRender; +#endif bool mIsCompositingCheap; bool mContainsPluginItem; bool mAncestorHasApzAwareEventHandler; @@ -1994,8 +2012,10 @@ class nsDisplayListBuilder { bool mPartialBuildFailed; bool mIsInActiveDocShell; bool mBuildAsyncZoomContainer; +#ifdef MOZ_BUILD_WEBRENDER bool mBuildBackdropRootContainer; bool mContainsBackdropFilter; +#endif nsRect mHitTestArea; CompositorHitTestInfo mHitTestInfo; @@ -2232,7 +2252,8 @@ class nsDisplayItemBase : public nsDisplayItemLink { // The middle 16 bits of the per frame key uniquely identify the display // item when there are more than one item of the same type for a frame. // The low 8 bits are the display item type. - return (static_cast(mExtraPageForPageNum) << (TYPE_BITS + (sizeof(mKey) * 8))) | + return (static_cast(mExtraPageForPageNum) + << (TYPE_BITS + (sizeof(mKey) * 8))) | (static_cast(mKey) << TYPE_BITS) | static_cast(mType); } @@ -2432,9 +2453,11 @@ class nsDisplayItem : public nsDisplayItemBase { typedef mozilla::layers::ScrollableLayerGuid::ViewID ViewID; typedef mozilla::layers::Layer Layer; typedef mozilla::layers::LayerManager LayerManager; +#ifdef MOZ_BUILD_WEBRENDER typedef mozilla::layers::StackingContextHelper StackingContextHelper; typedef mozilla::layers::WebRenderCommand WebRenderCommand; typedef mozilla::layers::WebRenderParentCommand WebRenderParentCommand; +#endif typedef mozilla::LayerState LayerState; typedef mozilla::image::imgDrawingParams imgDrawingParams; typedef mozilla::image::ImgDrawResult ImgDrawResult; @@ -2758,6 +2781,7 @@ class nsDisplayItem : public nsDisplayItemBase { void SetIsGlassItem() { mItemFlags += ItemFlag::IsGlassItem; } bool IsGlassItem() { return mItemFlags.contains(ItemFlag::IsGlassItem); } +#ifdef MOZ_BUILD_WEBRENDER /** * Function to create the WebRenderCommands. * We should check if the layer state is @@ -2795,6 +2819,7 @@ class nsDisplayItem : public nsDisplayItemBase { mozilla::layers::WebRenderLayerScrollData* aLayerData) { return false; } +#endif /** * On entry, aVisibleRegion contains the region (relative to ReferenceFrame()) @@ -3920,12 +3945,14 @@ class nsDisplayContainer final : public nsDisplayItem { bool ComputeVisibility(nsDisplayListBuilder* aBuilder, nsRegion* aVisibleRegion) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const override; @@ -4166,12 +4193,14 @@ class nsDisplayCaret : public nsPaintedDisplayItem { nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const override; void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif protected: RefPtr mCaret; @@ -4196,12 +4225,14 @@ class nsDisplayBorder : public nsPaintedDisplayItem { LayerState GetLayerState( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aParameters) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; nsDisplayItemGeometry* AllocateGeometry( nsDisplayListBuilder* aBuilder) override; @@ -4365,12 +4396,14 @@ class nsDisplaySolidColor : public nsDisplaySolidColorBase { const ContainerLayerParameters& aContainerParameters) override; void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; void WriteDebugInfo(std::stringstream& aStream) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif int32_t ZIndex() const override { if (mOverrideZIndex) { @@ -4441,12 +4474,14 @@ class nsDisplaySolidColorRegion : public nsPaintedDisplayItem { } } +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif protected: nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const override; @@ -4515,12 +4550,14 @@ class nsDisplayBackgroundImage : public nsDisplayImageContainer { already_AddRefed BuildLayer( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect, HitTestState* aState, nsTArray* aOutFrames) override; bool ComputeVisibility(nsDisplayListBuilder* aBuilder, @@ -4604,8 +4641,10 @@ class nsDisplayBackgroundImage : public nsDisplayImageContainer { typedef class mozilla::layers::ImageContainer ImageContainer; typedef class mozilla::layers::ImageLayer ImageLayer; +#ifdef MOZ_BUILD_WEBRENDER bool CanBuildWebRenderDisplayItems(LayerManager* aManager, nsDisplayListBuilder* aBuilder); +#endif nsRect GetBoundsInternal(nsDisplayListBuilder* aBuilder, nsIFrame* aFrameForBounds = nullptr); @@ -4741,12 +4780,14 @@ class nsDisplayThemedBackground : public nsPaintedDisplayItem { bool* aSnap) const override; mozilla::Maybe IsUniform( nsDisplayListBuilder* aBuilder) const override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif bool MustPaintOnContentSide() const override { return true; } @@ -4886,12 +4927,14 @@ class nsDisplayBackgroundColor : public nsPaintedDisplayItem { already_AddRefed BuildLayer( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder, bool* aSnap) const override; mozilla::Maybe IsUniform( @@ -5056,12 +5099,14 @@ class nsDisplayClearBackground : public nsPaintedDisplayItem { nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif }; /** @@ -5112,6 +5157,7 @@ class nsDisplayBoxShadowOuter final : public nsPaintedDisplayItem { return new nsDisplayBoxShadowOuterGeometry(this, aBuilder, mOpacity); } +#ifdef MOZ_BUILD_WEBRENDER bool CanBuildWebRenderDisplayItems(); bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, @@ -5119,6 +5165,7 @@ class nsDisplayBoxShadowOuter final : public nsPaintedDisplayItem { const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif nsRect GetBoundsInternal(); private: @@ -5172,6 +5219,7 @@ class nsDisplayBoxShadowInner : public nsPaintedDisplayItem { } } +#ifdef MOZ_BUILD_WEBRENDER static bool CanCreateWebRenderCommands(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, const nsPoint& aReferencePoint); @@ -5185,6 +5233,7 @@ class nsDisplayBoxShadowInner : public nsPaintedDisplayItem { const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif private: nsRegion mVisibleRegion; @@ -5206,12 +5255,14 @@ class nsDisplayOutline : public nsPaintedDisplayItem { NS_DISPLAY_DECL_NAME("Outline", TYPE_OUTLINE) +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif bool IsInvisibleInRect(const nsRect& aRect) const override; nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const override; void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; @@ -5236,12 +5287,14 @@ class nsDisplayEventReceiver : public nsPaintedDisplayItem { void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect, HitTestState* aState, nsTArray* aOutFrames) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif }; /** @@ -5272,12 +5325,14 @@ class nsDisplayCompositorHitTestInfo : public nsDisplayHitTestInfoItem { void InitializeScrollTarget(nsDisplayListBuilder* aBuilder); +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif uint16_t CalculatePerFrameKey() const override; int32_t ZIndex() const override; void SetOverrideZIndex(int32_t aZIndex); @@ -5524,12 +5579,14 @@ class nsDisplayWrapList : public nsDisplayHitTestInfoItem { return nullptr; } +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif const ActiveScrolledRoot* GetFrameActiveScrolledRoot() { return mFrameActiveScrolledRoot; @@ -5695,12 +5752,14 @@ class nsDisplayOpacity : public nsDisplayWrapList { bool aEnforceMinimumSize = true); void WriteDebugInfo(std::stringstream& aStream) override; bool CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif float GetOpacity() const { return mOpacity; } @@ -5770,12 +5829,14 @@ class nsDisplayBlendMode : public nsDisplayWrapList { LayerState GetLayerState( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aParameters) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif bool ComputeVisibility(nsDisplayListBuilder* aBuilder, nsRegion* aVisibleRegion) override; @@ -5874,12 +5935,14 @@ class nsDisplayBlendContainer : public nsDisplayWrapList { LayerState GetLayerState( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aParameters) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif bool CanMerge(const nsDisplayItem* aItem) const override { // Items for the same content element should be merged into a single @@ -6018,8 +6081,12 @@ class nsDisplayOwnLayer : public nsDisplayWrapList { : nsDisplayWrapList(aBuilder, aOther), mFlags(aOther.mFlags), mScrollbarData(aOther.mScrollbarData), - mForceActive(aOther.mForceActive), - mWrAnimationId(aOther.mWrAnimationId) { + mForceActive(aOther.mForceActive) +#ifdef MOZ_BUILD_WEBRENDER + , + mWrAnimationId(aOther.mWrAnimationId) +#endif + { MOZ_COUNT_CTOR(nsDisplayOwnLayer); } @@ -6032,6 +6099,7 @@ class nsDisplayOwnLayer : public nsDisplayWrapList { already_AddRefed BuildLayer( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -6041,6 +6109,7 @@ class nsDisplayOwnLayer : public nsDisplayWrapList { bool UpdateScrollData( mozilla::layers::WebRenderScrollData* aData, mozilla::layers::WebRenderLayerScrollData* aLayerData) override; +#endif LayerState GetLayerState( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aParameters) override; @@ -6072,18 +6141,21 @@ class nsDisplayOwnLayer : public nsDisplayWrapList { */ ScrollbarData mScrollbarData; bool mForceActive; +#ifdef MOZ_BUILD_WEBRENDER uint64_t mWrAnimationId; +#endif }; +#ifdef MOZ_BUILD_WEBRENDER class nsDisplayRenderRoot : public nsDisplayWrapList { nsDisplayRenderRoot(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList, const ActiveScrolledRoot* aActiveScrolledRoot, mozilla::wr::RenderRoot aRenderRoot); -#ifdef NS_BUILD_REFCNT_LOGGING +# ifdef NS_BUILD_REFCNT_LOGGING ~nsDisplayRenderRoot() override { MOZ_COUNT_DTOR(nsDisplayRenderRoot); } -#endif +# endif NS_DISPLAY_DECL_NAME("RenderRoot", TYPE_RENDER_ROOT) @@ -6113,6 +6185,7 @@ class nsDisplayRenderRoot : public nsDisplayWrapList { bool mBuiltWRCommands; mozilla::Maybe mBoundary; }; +#endif /** * A display item for subdocuments. This is more or less the same as @@ -6226,12 +6299,14 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer { return mozilla::LayerState::LAYER_ACTIVE; } +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif const ActiveScrolledRoot* GetContainerASR() const { return mContainerASR; } @@ -6291,6 +6366,7 @@ class nsDisplayFixedPosition : public nsDisplayOwnLayer { return mAnimatedGeometryRootForScrollMetadata; } +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -6300,6 +6376,7 @@ class nsDisplayFixedPosition : public nsDisplayOwnLayer { bool UpdateScrollData( mozilla::layers::WebRenderScrollData* aData, mozilla::layers::WebRenderLayerScrollData* aLayerData) override; +#endif void WriteDebugInfo(std::stringstream& aStream) override; protected: @@ -6405,9 +6482,11 @@ class nsDisplayScrollInfoLayer : public nsDisplayWrapList { mozilla::UniquePtr ComputeScrollMetadata( LayerManager* aLayerManager, const ContainerLayerParameters& aContainerParameters); +#ifdef MOZ_BUILD_WEBRENDER bool UpdateScrollData( mozilla::layers::WebRenderScrollData* aData, mozilla::layers::WebRenderLayerScrollData* aLayerData) override; +#endif protected: nsIFrame* mScrollFrame; @@ -6639,12 +6718,14 @@ class nsDisplayMasksAndClipPaths : public nsDisplayEffectsBase { const nsTArray& GetDestRects() { return mDestRects; } +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif mozilla::Maybe GetClipWithRespectToASR( nsDisplayListBuilder* aBuilder, @@ -6660,6 +6741,7 @@ class nsDisplayMasksAndClipPaths : public nsDisplayEffectsBase { nsTArray mDestRects; }; +#ifdef MOZ_BUILD_WEBRENDER class nsDisplayBackdropRootContainer : public nsDisplayWrapList { public: nsDisplayBackdropRootContainer(nsDisplayListBuilder* aBuilder, @@ -6669,11 +6751,11 @@ class nsDisplayBackdropRootContainer : public nsDisplayWrapList { MOZ_COUNT_CTOR(nsDisplayBackdropRootContainer); } -#ifdef NS_BUILD_REFCNT_LOGGING +# ifdef NS_BUILD_REFCNT_LOGGING ~nsDisplayBackdropRootContainer() override { MOZ_COUNT_DTOR(nsDisplayBackdropRootContainer); } -#endif +# endif NS_DISPLAY_DECL_NAME("BackdropRootContainer", TYPE_BACKDROP_ROOT_CONTAINER) @@ -6705,11 +6787,11 @@ class nsDisplayBackdropFilters : public nsDisplayWrapList { MOZ_COUNT_CTOR(nsDisplayBackdropFilters); } -#ifdef NS_BUILD_REFCNT_LOGGING +# ifdef NS_BUILD_REFCNT_LOGGING ~nsDisplayBackdropFilters() override { MOZ_COUNT_DTOR(nsDisplayBackdropFilters); } -#endif +# endif NS_DISPLAY_DECL_NAME("BackdropFilter", TYPE_BACKDROP_FILTER) @@ -6730,6 +6812,7 @@ class nsDisplayBackdropFilters : public nsDisplayWrapList { private: nsRect mBackdropRect; }; +#endif // MOZ_BUILD_WEBRENDER /** * A display item to paint a stacking context with filter effects set by the @@ -6802,6 +6885,7 @@ class nsDisplayFilters : public nsDisplayEffectsBase { void PaintAsLayer(nsDisplayListBuilder* aBuilder, gfxContext* aCtx, LayerManager* aManager); +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -6809,6 +6893,7 @@ class nsDisplayFilters : public nsDisplayEffectsBase { mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; bool CanCreateWebRenderCommands(); +#endif private: NS_DISPLAY_ALLOW_CLONING() @@ -6917,6 +7002,7 @@ class nsDisplayTransform : public nsDisplayHitTestInfoItem { already_AddRefed BuildLayer( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aContainerParameters) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -6926,6 +7012,7 @@ class nsDisplayTransform : public nsDisplayHitTestInfoItem { bool UpdateScrollData( mozilla::layers::WebRenderScrollData* aData, mozilla::layers::WebRenderLayerScrollData* aLayerData) override; +#endif bool ComputeVisibility(nsDisplayListBuilder* aBuilder, nsRegion* aVisibleRegion) override; @@ -7244,12 +7331,14 @@ class nsDisplayPerspective : public nsDisplayHitTestInfoItem { LayerState GetLayerState( nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aParameters) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif already_AddRefed BuildLayer( nsDisplayListBuilder* aBuilder, LayerManager* aManager, @@ -7316,12 +7405,14 @@ class nsDisplayText final : public nsPaintedDisplayItem { } } +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) final; +#endif void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) final; nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder) const final { @@ -7431,14 +7522,17 @@ class nsDisplaySVGWrapper : public nsDisplayWrapList { nsDisplayListBuilder* aBuilder, LayerManager* aManager, const ContainerLayerParameters& aParameters) override; bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif }; +#ifdef MOZ_BUILD_WEBRENDER /** * A display item for webrender to handle SVG foreign object */ @@ -7446,9 +7540,9 @@ class nsDisplayForeignObject : public nsDisplayWrapList { public: nsDisplayForeignObject(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, nsDisplayList* aList); -#ifdef NS_BUILD_REFCNT_LOGGING +# ifdef NS_BUILD_REFCNT_LOGGING virtual ~nsDisplayForeignObject(); -#endif +# endif NS_DISPLAY_DECL_NAME("ForeignObject", TYPE_FOREIGN_OBJECT) @@ -7467,6 +7561,7 @@ class nsDisplayForeignObject : public nsDisplayWrapList { mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; }; +#endif class FlattenedDisplayListIterator { public: diff --git a/layout/painting/nsImageRenderer.cpp b/layout/painting/nsImageRenderer.cpp index 745d613626..c88665fc5f 100644 --- a/layout/painting/nsImageRenderer.cpp +++ b/layout/painting/nsImageRenderer.cpp @@ -6,15 +6,16 @@ #include "nsImageRenderer.h" -#include "mozilla/webrender/WebRenderAPI.h" - #include "gfxContext.h" #include "gfxDrawable.h" #include "ImageOps.h" #include "ImageRegion.h" -#include "mozilla/layers/RenderRootStateManager.h" -#include "mozilla/layers/StackingContextHelper.h" -#include "mozilla/layers/WebRenderLayerManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderAPI.h" +# include "mozilla/layers/RenderRootStateManager.h" +# include "mozilla/layers/StackingContextHelper.h" +# include "mozilla/layers/WebRenderLayerManager.h" +#endif #include "nsContentUtils.h" #include "nsCSSRendering.h" #include "nsCSSRenderingGradients.h" @@ -549,6 +550,7 @@ ImgDrawResult nsImageRenderer::Draw(nsPresContext* aPresContext, return result; } +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult nsImageRenderer::BuildWebRenderDisplayItems( nsPresContext* aPresContext, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -679,6 +681,7 @@ ImgDrawResult nsImageRenderer::BuildWebRenderDisplayItems( } return drawResult; } +#endif // MOZ_BUILD_WEBRENDER already_AddRefed nsImageRenderer::DrawableForElement( const nsRect& aImageRect, gfxContext& aContext) { @@ -743,6 +746,7 @@ ImgDrawResult nsImageRenderer::DrawLayer( aOpacity); } +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult nsImageRenderer::BuildWebRenderDisplayItemsForLayer( nsPresContext* aPresContext, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -768,6 +772,7 @@ ImgDrawResult nsImageRenderer::BuildWebRenderDisplayItemsForLayer( nsPresContext::AppUnitsToIntCSSPixels(mSize.height)), aOpacity); } +#endif /** * Compute the size and position of the master copy of the image. I.e., a single diff --git a/layout/painting/nsImageRenderer.h b/layout/painting/nsImageRenderer.h index 366dfc6765..e629764614 100644 --- a/layout/painting/nsImageRenderer.h +++ b/layout/painting/nsImageRenderer.h @@ -13,6 +13,7 @@ class gfxDrawable; namespace mozilla { +#ifdef MOZ_BUILD_WEBRENDER namespace layers { class StackingContextHelper; class WebRenderParentCommand; @@ -23,6 +24,7 @@ namespace wr { class DisplayListBuilder; class IpcResourceUpdateQueue; } // namespace wr +#endif // A CSSSizeOrRatio represents a (possibly partially specified) size for use // in computing image sizes. Either or both of the width and height might be @@ -184,6 +186,7 @@ class nsImageRenderer { const nsRect& aDirty, const nsSize& aRepeatSize, float aOpacity); +#ifdef MOZ_BUILD_WEBRENDER /** * Builds WebRender DisplayItems for an image using * {background|mask}-specific arguments. @@ -196,6 +199,7 @@ class nsImageRenderer { mozilla::layers::RenderRootStateManager* aManager, nsDisplayItem* aItem, const nsRect& aDest, const nsRect& aFill, const nsPoint& aAnchor, const nsRect& aDirty, const nsSize& aRepeatSize, float aOpacity); +#endif /** * Draw the image to a single component of a border-image style rendering. @@ -265,6 +269,7 @@ class nsImageRenderer { const nsSize& aRepeatSize, const mozilla::CSSIntRect& aSrc, float aOpacity = 1.0); +#ifdef MOZ_BUILD_WEBRENDER /** * Builds WebRender DisplayItems for the image. * aSrc is a rect on the source image which will be mapped to aDest; it's @@ -280,6 +285,7 @@ class nsImageRenderer { const nsRect& aDirtyRect, const nsRect& aDest, const nsRect& aFill, const nsPoint& aAnchor, const nsSize& aRepeatSize, const mozilla::CSSIntRect& aSrc, float aOpacity = 1.0); +#endif /** * Helper method for creating a gfxDrawable from mPaintServerFrame or diff --git a/layout/style/ImageLoader.cpp b/layout/style/ImageLoader.cpp index 962984580d..ce8226d20b 100644 --- a/layout/style/ImageLoader.cpp +++ b/layout/style/ImageLoader.cpp @@ -20,7 +20,9 @@ #include "imgIContainer.h" #include "GeckoProfiler.h" #include "mozilla/PresShell.h" -#include "mozilla/layers/WebRenderUserData.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderUserData.h" +#endif using namespace mozilla::dom; @@ -421,7 +423,6 @@ static CORSMode EffectiveCorsMode(nsIURI* aURI, return CORSMode::CORS_ANONYMOUS; } - /* static */ void ImageLoader::LoadImage(const StyleComputedImageUrl& aImage, Document& aLoadingDoc) { @@ -496,6 +497,7 @@ static void InvalidateImages(nsIFrame* aFrame, imgIRequest* aRequest) { invalidateFrame = true; } } +#ifdef MOZ_BUILD_WEBRENDER if (auto userDataTable = aFrame->GetProperty(layers::WebRenderUserDataProperty::Key())) { for (auto iter = userDataTable->Iter(); !iter.Done(); iter.Next()) { @@ -521,6 +523,7 @@ static void InvalidateImages(nsIFrame* aFrame, imgIRequest* aRequest) { } } } +#endif if (invalidateFrame) { aFrame->SchedulePaint(); diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 30f9afa9ed..838786ffcb 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -3746,10 +3746,12 @@ nsChangeHint nsStyleEffects::CalcDifference( hint |= nsChangeHint_RepaintFrame; } +#ifdef MOZ_BUILD_WEBRENDER if (HasBackdropFilters() != aNewData.HasBackdropFilters()) { // A change from/to being a containing block for position:fixed. hint |= nsChangeHint_UpdateContainingBlock; } +#endif if (mBackdropFilters != aNewData.mBackdropFilters) { hint |= nsChangeHint_UpdateEffects | nsChangeHint_RepaintFrame; diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 31cc57152b..d97507d312 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1252,7 +1252,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility { mozilla::StyleDirection mDirection; mozilla::StyleVisibility mVisible; mozilla::StyleImageRendering mImageRendering; - uint8_t mWritingMode; // NS_STYLE_WRITING_MODE_* + uint8_t mWritingMode; // NS_STYLE_WRITING_MODE_* mozilla::StyleTextOrientation mTextOrientation; mozilla::StyleColorAdjust mColorAdjust; @@ -2217,7 +2217,9 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleEffects { bool HasFilters() const { return !mFilters.IsEmpty(); } +#ifdef MOZ_BUILD_WEBRENDER bool HasBackdropFilters() const { return !mBackdropFilters.IsEmpty(); } +#endif bool HasBoxShadowWithInset(bool aInset) const { for (auto& shadow : mBoxShadow.AsSpan()) { @@ -2228,9 +2230,11 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleEffects { return false; } +#ifdef MOZ_BUILD_WEBRENDER bool HasMixBlendMode() const { return mMixBlendMode != NS_STYLE_BLEND_NORMAL; } +#endif mozilla::StyleOwnedSlice mFilters; mozilla::StyleOwnedSlice mBoxShadow; diff --git a/layout/style/nsStyleStructInlines.h b/layout/style/nsStyleStructInlines.h index bad7ab7214..1948fec901 100644 --- a/layout/style/nsStyleStructInlines.h +++ b/layout/style/nsStyleStructInlines.h @@ -114,8 +114,11 @@ bool nsStyleDisplay::IsFixedPosContainingBlockForNonSVGTextFrames( return true; } - return aStyle.StyleEffects()->HasFilters() || - aStyle.StyleEffects()->HasBackdropFilters(); + return aStyle.StyleEffects()->HasFilters() +#ifdef MOZ_BUILD_WEBRENDER + || aStyle.StyleEffects()->HasBackdropFilters() +#endif + ; } bool nsStyleDisplay:: diff --git a/layout/svg/SVGObserverUtils.cpp b/layout/svg/SVGObserverUtils.cpp index fd76665c40..291f490f5e 100644 --- a/layout/svg/SVGObserverUtils.cpp +++ b/layout/svg/SVGObserverUtils.cpp @@ -1716,8 +1716,11 @@ already_AddRefed SVGObserverUtils::GetBaseURLForLocalRef( already_AddRefed SVGObserverUtils::GetFilterURI( nsIFrame* aFrame, const StyleFilter& aFilter) { - MOZ_ASSERT(!aFrame->StyleEffects()->mFilters.IsEmpty() || - !aFrame->StyleEffects()->mBackdropFilters.IsEmpty()); + MOZ_ASSERT(!aFrame->StyleEffects()->mFilters.IsEmpty() +#ifdef MOZ_BUILD_WEBRENDER + || !aFrame->StyleEffects()->mBackdropFilters.IsEmpty() +#endif + ); MOZ_ASSERT(aFilter.IsUrl()); return ResolveURLUsingLocalRef(aFrame, aFilter.AsUrl()); } diff --git a/layout/svg/nsFilterInstance.cpp b/layout/svg/nsFilterInstance.cpp index ef567c53b1..fa12a54c77 100644 --- a/layout/svg/nsFilterInstance.cpp +++ b/layout/svg/nsFilterInstance.cpp @@ -95,6 +95,7 @@ void nsFilterInstance::PaintFilteredFrame( } } +#ifdef MOZ_BUILD_WEBRENDER static mozilla::wr::ComponentTransferFuncType FuncTypeToWr(uint8_t aFuncType) { switch (aFuncType) { case SVG_FECOMPONENTTRANSFER_TYPE_TABLE: @@ -108,7 +109,6 @@ static mozilla::wr::ComponentTransferFuncType FuncTypeToWr(uint8_t aFuncType) { case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: default: return mozilla::wr::ComponentTransferFuncType::Identity; - } MOZ_ASSERT_UNREACHABLE("all func types not handled?"); return mozilla::wr::ComponentTransferFuncType::Identity; @@ -367,6 +367,7 @@ bool nsFilterInstance::BuildWebRenderFilters(nsIFrame* aFilteredFrame, } return true; } +#endif // MOZ_BUILD_WEBRENDER nsRegion nsFilterInstance::GetPostFilterDirtyArea( nsIFrame* aFilteredFrame, const nsRegion& aPreFilterDirtyRegion) { diff --git a/layout/svg/nsFilterInstance.h b/layout/svg/nsFilterInstance.h index 9f10f1fcde..cd57adc258 100644 --- a/layout/svg/nsFilterInstance.h +++ b/layout/svg/nsFilterInstance.h @@ -17,7 +17,9 @@ #include "nsTArray.h" #include "nsIFrame.h" #include "mozilla/gfx/2D.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif class gfxContext; class nsIFrame; @@ -121,6 +123,7 @@ class nsFilterInstance { const gfxRect* aOverrideBBox = nullptr, const nsRect* aPreFilterBounds = nullptr); +#ifdef MOZ_BUILD_WEBRENDER /** * Try to build WebRender filters for a frame if the filters applied to it are * supported. @@ -129,6 +132,7 @@ class nsFilterInstance { nsIFrame* aFilteredFrame, mozilla::Span aFilters, WrFiltersHolder& aWrFilters, mozilla::Maybe& aPostFilterClip); +#endif private: /** diff --git a/layout/svg/nsSVGForeignObjectFrame.cpp b/layout/svg/nsSVGForeignObjectFrame.cpp index e0e9897651..c82c6cf034 100644 --- a/layout/svg/nsSVGForeignObjectFrame.cpp +++ b/layout/svg/nsSVGForeignObjectFrame.cpp @@ -156,8 +156,10 @@ void nsSVGForeignObjectFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, &newList); DisplayOutline(aBuilder, set); BuildDisplayListForNonBlockChildren(aBuilder, set); +#ifdef MOZ_BUILD_WEBRENDER aLists.Content()->AppendNewToTop(aBuilder, this, &newList); +#endif } bool nsSVGForeignObjectFrame::IsSVGTransformed( diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/nsSVGIntegrationUtils.cpp index 0dde08d4a8..ed73335169 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/nsSVGIntegrationUtils.cpp @@ -162,7 +162,10 @@ bool nsSVGIntegrationUtils::UsingEffectsForFrame(const nsIFrame* aFrame) { const nsStyleEffects* effects = aFrame->StyleEffects(); // TODO(cbrewster): remove backdrop-filter from this list once it is supported // in preserve-3d cases. - return effects->HasFilters() || effects->HasBackdropFilters() || + return effects->HasFilters() || +#ifdef MOZ_BUILD_WEBRENDER + effects->HasBackdropFilters() || +#endif style->HasClipPath() || style->HasMask(); } @@ -1104,6 +1107,7 @@ void nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams) { aParams.imgParams, opacity); } +#ifdef MOZ_BUILD_WEBRENDER static float ClampStdDeviation(float aStdDeviation) { // Cap software blur radius for performance reasons. return std::min(std::max(0.0f, aStdDeviation), 100.0f); @@ -1206,17 +1210,26 @@ bool nsSVGIntegrationUtils::CanCreateWebRenderFiltersForFrame( return CreateWebRenderCSSFilters(filterChain, aFrame, wrFilters) || BuildWebRenderFilters(aFrame, filterChain, wrFilters, filterClip); } +#endif // MOZ_BUILD_WEBRENDER bool nsSVGIntegrationUtils::UsesSVGEffectsNotSupportedInCompositor( nsIFrame* aFrame) { // WebRender supports masks / clip-paths and some filters in the compositor. // Non-WebRender doesn't support any SVG effects in the compositor. if (aFrame->StyleEffects()->HasFilters()) { +#ifdef MOZ_BUILD_WEBRENDER return !gfx::gfxVars::UseWebRender() || !nsSVGIntegrationUtils::CanCreateWebRenderFiltersForFrame(aFrame); +#else + return true; +#endif } if (nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(aFrame)) { +#ifdef MOZ_BUILD_WEBRENDER return !gfx::gfxVars::UseWebRender(); +#else + return true; +#endif } return false; } diff --git a/layout/svg/nsSVGIntegrationUtils.h b/layout/svg/nsSVGIntegrationUtils.h index 3e041e30e4..e536b91afc 100644 --- a/layout/svg/nsSVGIntegrationUtils.h +++ b/layout/svg/nsSVGIntegrationUtils.h @@ -10,7 +10,9 @@ #include "gfxRect.h" #include "nsRegionFwd.h" #include "mozilla/gfx/Rect.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif class gfxContext; class gfxDrawable; @@ -32,6 +34,7 @@ class LayerManager; struct nsPoint; struct nsSize; +#ifdef MOZ_BUILD_WEBRENDER struct WrFiltersHolder { nsTArray filters; nsTArray filter_datas; @@ -39,6 +42,7 @@ struct WrFiltersHolder { // rust. nsTArray> values; }; +#endif /** * Integration of SVG effects (clipPath clipping, masking and filters) into @@ -203,6 +207,7 @@ class nsSVGIntegrationUtils final { */ static void PaintFilter(const PaintFramesParams& aParams); +#ifdef MOZ_BUILD_WEBRENDER /** * Build WebRender filters for a frame with CSS filters applied to it. */ @@ -223,6 +228,7 @@ class nsSVGIntegrationUtils final { * Check if the filters present on |aFrame| are supported by WebRender. */ static bool CanCreateWebRenderFiltersForFrame(nsIFrame* aFrame); +#endif /** * Check if |aFrame| uses any SVG effects that cannot be rendered in the diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index c9a2771c52..f2a53d4e14 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -54,6 +54,7 @@ class nsDisplayTableCellSelection final : public nsPaintedDisplayItem { } NS_DISPLAY_DECL_NAME("TableCellSelection", TYPE_TABLE_CELL_SELECTION) +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -68,6 +69,7 @@ class nsDisplayTableCellSelection final : public nsPaintedDisplayItem { return true; } +#endif }; nsTableCellFrame::nsTableCellFrame(ComputedStyle* aStyle, diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 5ae2893311..c17dccb646 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -48,8 +48,10 @@ #include "nsStyleChangeList.h" #include -#include "mozilla/layers/StackingContextHelper.h" -#include "mozilla/layers/RenderRootStateManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/StackingContextHelper.h" +# include "mozilla/layers/RenderRootStateManager.h" +#endif using namespace mozilla; using namespace mozilla::image; @@ -1176,11 +1178,13 @@ class nsDisplayTableBorderCollapse final : public nsDisplayTableItem { #endif void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; +#ifdef MOZ_BUILD_WEBRENDER bool CreateWebRenderCommands( wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif NS_DISPLAY_DECL_NAME("TableBorderCollapse", TYPE_TABLE_BORDER_COLLAPSE) }; @@ -1202,6 +1206,7 @@ void nsDisplayTableBorderCollapse::Paint(nsDisplayListBuilder* aBuilder, GetPaintRect() - pt); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayTableBorderCollapse::CreateWebRenderCommands( wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, @@ -1211,6 +1216,7 @@ bool nsDisplayTableBorderCollapse::CreateWebRenderCommands( aBuilder, aSc, GetPaintRect(), ToReferenceFrame()); return true; } +#endif /* static */ void nsTableFrame::GenericTraversal(nsDisplayListBuilder* aBuilder, @@ -6091,11 +6097,13 @@ struct BCBlockDirSeg { BCPixelSize aInlineSegBSize); void Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget, BCPixelSize aInlineSegBSize); +#ifdef MOZ_BUILD_WEBRENDER void CreateWebRenderCommands(BCPaintBorderIterator& aIter, BCPixelSize aInlineSegBSize, wr::DisplayListBuilder& aBuilder, const layers::StackingContextHelper& aSc, const nsPoint& aPt); +#endif void AdvanceOffsetB(); void IncludeCurrentBorder(BCPaintBorderIterator& aIter); @@ -6141,10 +6149,12 @@ struct BCInlineDirSeg { void IncludeCurrentBorder(BCPaintBorderIterator& aIter); Maybe BuildBorderParameters(BCPaintBorderIterator& aIter); void Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget); +#ifdef MOZ_BUILD_WEBRENDER void CreateWebRenderCommands(BCPaintBorderIterator& aIter, wr::DisplayListBuilder& aBuilder, const layers::StackingContextHelper& aSc, const nsPoint& aPt); +#endif nscoord mOffsetI; // i-offset with respect to the table edge nscoord mOffsetB; // b-offset with respect to the table edge @@ -6173,6 +6183,7 @@ struct BCPaintData { DrawTarget& mDrawTarget; }; +#ifdef MOZ_BUILD_WEBRENDER struct BCCreateWebRenderCommandsData { BCCreateWebRenderCommandsData(wr::DisplayListBuilder& aBuilder, const layers::StackingContextHelper& aSc, @@ -6185,11 +6196,13 @@ struct BCCreateWebRenderCommandsData { const layers::StackingContextHelper& mSc; const nsPoint& mOffsetToReferenceFrame; }; +#endif struct BCPaintBorderAction { explicit BCPaintBorderAction(DrawTarget& aDrawTarget) : mMode(Mode::Paint), mPaintData(aDrawTarget) {} +#ifdef MOZ_BUILD_WEBRENDER BCPaintBorderAction(wr::DisplayListBuilder& aBuilder, const layers::StackingContextHelper& aSc, const nsPoint& aOffsetToReferenceFrame) @@ -6204,18 +6217,26 @@ struct BCPaintBorderAction { mCreateWebRenderCommandsData.~BCCreateWebRenderCommandsData(); } } +#endif enum class Mode { - Paint, + Paint +#ifdef MOZ_BUILD_WEBRENDER + , CreateWebRenderCommands, +#endif }; Mode mMode; +#ifdef MOZ_BUILD_WEBRENDER union { +#endif BCPaintData mPaintData; +#ifdef MOZ_BUILD_WEBRENDER BCCreateWebRenderCommandsData mCreateWebRenderCommandsData; }; +#endif }; // Iterates over borders (iStart border, corner, bStart border) in the cell map @@ -6996,6 +7017,7 @@ void BCBlockDirSeg::Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget, param->mStartBevelOffset, param->mEndBevelSide, param->mEndBevelOffset); } +#ifdef MOZ_BUILD_WEBRENDER // Pushes a border bevel triangle and substracts the relevant rectangle from // aRect, which, after all the bevels, will end up being a solid segment rect. static void AdjustAndPushBevel(wr::DisplayListBuilder& aBuilder, @@ -7166,6 +7188,7 @@ void BCBlockDirSeg::CreateWebRenderCommands( CreateWRCommandsForBorderSegment(*param, aBuilder, aSc, aOffset); } +#endif // MOZ_BUILD_WEBRENDER /** * Advance the start point of a segment @@ -7385,6 +7408,7 @@ void BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter, param->mStartBevelOffset, param->mEndBevelSide, param->mEndBevelOffset); } +#ifdef MOZ_BUILD_WEBRENDER void BCInlineDirSeg::CreateWebRenderCommands( BCPaintBorderIterator& aIter, wr::DisplayListBuilder& aBuilder, const layers::StackingContextHelper& aSc, const nsPoint& aPt) { @@ -7395,6 +7419,7 @@ void BCInlineDirSeg::CreateWebRenderCommands( CreateWRCommandsForBorderSegment(*param, aBuilder, aSc, aPt); } +#endif /** * Advance the start point of a segment @@ -7472,6 +7497,7 @@ void BCPaintBorderIterator::AccumulateOrDoActionInlineDirSegment( if (mInlineSeg.mWidth > 0) { if (aAction.mMode == BCPaintBorderAction::Mode::Paint) { mInlineSeg.Paint(*this, aAction.mPaintData.mDrawTarget); +#ifdef MOZ_BUILD_WEBRENDER } else { MOZ_ASSERT(aAction.mMode == BCPaintBorderAction::Mode::CreateWebRenderCommands); @@ -7479,6 +7505,7 @@ void BCPaintBorderIterator::AccumulateOrDoActionInlineDirSegment( *this, aAction.mCreateWebRenderCommandsData.mBuilder, aAction.mCreateWebRenderCommandsData.mSc, aAction.mCreateWebRenderCommandsData.mOffsetToReferenceFrame); +#endif } } mInlineSeg.AdvanceOffsetI(); @@ -7524,6 +7551,7 @@ void BCPaintBorderIterator::AccumulateOrDoActionBlockDirSegment( if (aAction.mMode == BCPaintBorderAction::Mode::Paint) { blockDirSeg.Paint(*this, aAction.mPaintData.mDrawTarget, inlineSegBSize); +#ifdef MOZ_BUILD_WEBRENDER } else { MOZ_ASSERT(aAction.mMode == BCPaintBorderAction::Mode::CreateWebRenderCommands); @@ -7532,6 +7560,7 @@ void BCPaintBorderIterator::AccumulateOrDoActionBlockDirSegment( aAction.mCreateWebRenderCommandsData.mBuilder, aAction.mCreateWebRenderCommandsData.mSc, aAction.mCreateWebRenderCommandsData.mOffsetToReferenceFrame); +#endif } } blockDirSeg.AdvanceOffsetB(); @@ -7597,6 +7626,7 @@ void nsTableFrame::PaintBCBorders(DrawTarget& aDrawTarget, IterateBCBorders(action, aDirtyRect); } +#ifdef MOZ_BUILD_WEBRENDER void nsTableFrame::CreateWebRenderCommandsForBCBorders( wr::DisplayListBuilder& aBuilder, const mozilla::layers::StackingContextHelper& aSc, @@ -7606,6 +7636,7 @@ void nsTableFrame::CreateWebRenderCommandsForBCBorders( // dirty rect. IterateBCBorders(action, aVisibleRect - aOffsetToReferenceFrame); } +#endif bool nsTableFrame::RowHasSpanningCells(int32_t aRowIndex, int32_t aNumEffCols) { bool result = false; diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index c898451050..1de3af65ba 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -27,9 +27,11 @@ class LogicalMargin; class PresShell; class WritingMode; struct TableReflowInput; +#ifdef MOZ_BUILD_WEBRENDER namespace layers { class StackingContextHelper; } +#endif } // namespace mozilla struct BCPropertyData; @@ -255,10 +257,12 @@ class nsTableFrame : public nsContainerFrame { bool BCRecalcNeeded(ComputedStyle* aOldComputedStyle, ComputedStyle* aNewComputedStyle); void PaintBCBorders(DrawTarget& aDrawTarget, const nsRect& aDirtyRect); +#ifdef MOZ_BUILD_WEBRENDER void CreateWebRenderCommandsForBCBorders( mozilla::wr::DisplayListBuilder& aBuilder, const mozilla::layers::StackingContextHelper& aSc, const nsRect& aVisibleRect, const nsPoint& aOffsetToReferenceFrame); +#endif virtual void MarkIntrinsicISizesDirty() override; // For border-collapse tables, the caller must not add padding and diff --git a/layout/xul/nsBoxFrame.cpp b/layout/xul/nsBoxFrame.cpp index 8417c47e46..d089732046 100644 --- a/layout/xul/nsBoxFrame.cpp +++ b/layout/xul/nsBoxFrame.cpp @@ -1051,8 +1051,10 @@ void nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // long term we may want to add a specific element in which we can wrap // alternate renderroot content, but we're electing to not go down that // rabbit hole today. +#ifdef MOZ_BUILD_WEBRENDER wr::RenderRoot renderRoot = gfxUtils::GetRenderRootForFrame(this).valueOr(wr::RenderRoot::Default); +#endif if (GetContent()->IsXULElement()) { // forcelayer is only supported on XUL elements with box layout @@ -1071,13 +1073,22 @@ void nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, nsDisplayListCollection tempLists(aBuilder); const nsDisplayListSet& destination = - (forceLayer || renderRoot != wr::RenderRoot::Default) ? tempLists - : aLists; + (forceLayer +#ifdef MOZ_BUILD_WEBRENDER + || renderRoot != wr::RenderRoot::Default +#endif + ) + ? tempLists + : aLists; DisplayBorderBackgroundOutline(aBuilder, destination); Maybe contASRTracker; - if (forceLayer || renderRoot != wr::RenderRoot::Default) { + if (forceLayer +#ifdef MOZ_BUILD_WEBRENDER + || renderRoot != wr::RenderRoot::Default +#endif + ) { contASRTracker.emplace(aBuilder); } @@ -1086,7 +1097,11 @@ void nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, // see if we have to draw a selection frame around this container DisplaySelectionOverlay(aBuilder, destination.Content()); - if (forceLayer || renderRoot != wr::RenderRoot::Default) { + if (forceLayer +#ifdef MOZ_BUILD_WEBRENDER + || renderRoot != wr::RenderRoot::Default +#endif + ) { // This is a bit of a hack. Collect up all descendant display items // and merge them into a single Content() list. This can cause us // to violate CSS stacking order, but forceLayer is a magic @@ -1101,18 +1116,22 @@ void nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const ActiveScrolledRoot* ownLayerASR = contASRTracker->GetContainerASR(); DisplayListClipState::AutoSaveRestore ownLayerClipState(aBuilder); +#ifdef MOZ_BUILD_WEBRENDER if (forceLayer) { MOZ_ASSERT(renderRoot == wr::RenderRoot::Default); +#endif // Wrap the list to make it its own layer aLists.Content()->AppendNewToTop( aBuilder, this, &masterList, ownLayerASR, nsDisplayOwnLayerFlags::None, mozilla::layers::ScrollbarData{}, true, true); +#ifdef MOZ_BUILD_WEBRENDER } else { MOZ_ASSERT(!XRE_IsContentProcess()); aLists.Content()->AppendNewToTop( aBuilder, this, &masterList, ownLayerASR, renderRoot); } +#endif } } diff --git a/layout/xul/nsImageBoxFrame.cpp b/layout/xul/nsImageBoxFrame.cpp index c892fadd59..f9c997ca94 100644 --- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -47,8 +47,10 @@ #include "mozilla/PresShell.h" #include "SVGImageContext.h" #include "Units.h" -#include "mozilla/layers/RenderRootStateManager.h" -#include "mozilla/layers/WebRenderLayerManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/RenderRootStateManager.h" +# include "mozilla/layers/WebRenderLayerManager.h" +#endif #if defined(XP_WIN) // Undefine LoadImage to prevent naming conflict with Windows. @@ -387,6 +389,7 @@ ImgDrawResult nsImageBoxFrame::PaintImage(gfxContext& aRenderingContext, aFlags, anchorPoint.ptrOr(nullptr), hasSubRect ? &mSubRect : nullptr); } +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult nsImageBoxFrame::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -442,6 +445,7 @@ ImgDrawResult nsImageBoxFrame::CreateWebRenderCommands( return result; } +#endif nsRect nsImageBoxFrame::GetDestRect(const nsPoint& aOffset, Maybe& aAnchorPoint) { @@ -505,6 +509,7 @@ void nsDisplayXULImage::Paint(nsDisplayListBuilder* aBuilder, nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayXULImage::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -537,6 +542,7 @@ bool nsDisplayXULImage::CreateWebRenderCommands( nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result); return true; } +#endif nsDisplayItemGeometry* nsDisplayXULImage::AllocateGeometry( nsDisplayListBuilder* aBuilder) { @@ -835,10 +841,12 @@ nsresult nsImageBoxFrame::OnFrameUpdate(imgIRequest* aRequest) { // Check if WebRender has interacted with this frame. If it has // we need to let it know that things have changed. const auto type = DisplayItemType::TYPE_XUL_IMAGE; +#ifdef MOZ_BUILD_WEBRENDER const auto producerId = aRequest->GetProducerId(); if (WebRenderUserData::ProcessInvalidateForImage(this, type, producerId)) { return NS_OK; } +#endif InvalidateLayer(type); diff --git a/layout/xul/nsImageBoxFrame.h b/layout/xul/nsImageBoxFrame.h index fc5426f0d1..2e78523d9c 100644 --- a/layout/xul/nsImageBoxFrame.h +++ b/layout/xul/nsImageBoxFrame.h @@ -99,12 +99,14 @@ class nsImageBoxFrame final : public nsLeafBoxFrame { const nsRect& aDirtyRect, nsPoint aPt, uint32_t aFlags); +#ifdef MOZ_BUILD_WEBRENDER ImgDrawResult CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const mozilla::layers::StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayItem* aItem, nsPoint aPt, uint32_t aFlags); +#endif bool CanOptimizeToImageLayer(); @@ -172,12 +174,14 @@ class nsDisplayXULImage final : public nsDisplayImageContainer { // event receiver for us virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override; +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif NS_DISPLAY_DECL_NAME("XULImage", TYPE_XUL_IMAGE) }; diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index 0b342423d7..8328d8aa25 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -11,7 +11,6 @@ #include "mozilla/EventStateManager.h" #include "mozilla/Preferences.h" #include "mozilla/PresShell.h" -#include "mozilla/layers/RenderRootStateManager.h" #include "mozilla/gfx/2D.h" #include "nsFontMetrics.h" #include "nsReadableUtils.h" @@ -33,7 +32,10 @@ #include "nsBoxFrame.h" #include "nsLayoutUtils.h" #include "nsUnicodeProperties.h" -#include "TextDrawTarget.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/RenderRootStateManager.h" +# include "TextDrawTarget.h" +#endif #ifdef ACCESSIBILITY # include "nsAccessibilityService.h" @@ -258,12 +260,14 @@ class nsDisplayXULTextBox final : public nsPaintedDisplayItem { void PaintTextToContext(gfxContext* aCtx, nsPoint aOffset, const nscolor* aColor); +#ifdef MOZ_BUILD_WEBRENDER virtual bool CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) override; +#endif }; static void PaintTextShadowCallback(gfxContext* aCtx, nsPoint aShadowOffset, @@ -293,6 +297,7 @@ void nsDisplayXULTextBox::PaintTextToContext(gfxContext* aCtx, nsPoint aOffset, *aCtx, GetPaintRect(), ToReferenceFrame() + aOffset, aColor); } +#ifdef MOZ_BUILD_WEBRENDER bool nsDisplayXULTextBox::CreateWebRenderCommands( mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, @@ -322,6 +327,7 @@ bool nsDisplayXULTextBox::CreateWebRenderCommands( return textDrawer->Finish(); } +#endif nsRect nsDisplayXULTextBox::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) const { diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index d0da7986f6..9dd5538db7 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -3292,6 +3292,7 @@ value: 10 mirror: once +#ifdef MOZ_BUILD_WEBRENDER # We expose two prefs: gfx.webrender.all and gfx.webrender.enabled. # The first enables WR+additional features, and the second just enables WR. # For developer convenience, building with --enable-webrender=true or just @@ -3381,6 +3382,7 @@ value: false mirror: always #endif +#endif # Use vsync events generated by hardware - name: gfx.work-around-driver-bugs @@ -3569,6 +3571,7 @@ value: @IS_ANDROID@ mirror: always +#ifdef MOZ_BUILD_WEBRENDER # Enable extra information for debugging in the image memory reports. - name: image.mem.debug-reporting type: RelaxedAtomicBool @@ -3581,6 +3584,7 @@ type: RelaxedAtomicBool value: true mirror: always +#endif # How much of the data in the surface cache is discarded when we get a memory # pressure notification, as a fraction. The discard factor is interpreted as a diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 1dcc872ae7..16901ef030 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -640,6 +640,7 @@ pref("gfx.font_rendering.graphite.enabled", true); pref("gfx.content.azure.backends", "skia"); #endif +#ifdef MOZ_BUILD_WEBRENDER #ifdef XP_WIN pref("gfx.webrender.force-angle", true); pref("gfx.webrender.flip-sequential", false); @@ -674,6 +675,7 @@ pref("gfx.webrender.debug.primitives", false); pref("gfx.webrender.debug.small-screen", false); pref("gfx.webrender.debug.obscure-images", false); pref("gfx.webrender.debug.glyph-flashing", false); +#endif pref("accessibility.warn_on_browsewithcaret", true); diff --git a/old-configure.in b/old-configure.in index d43b97fc64..0c6bd79590 100644 --- a/old-configure.in +++ b/old-configure.in @@ -2058,6 +2058,19 @@ x86_64) ;; esac +dnl ======================================================== +dnl = Webrender +dnl ======================================================== +MOZ_ARG_DISABLE_BOOL(webrender, +[ --disable-webrender Disable webrender build], + MOZ_BUILD_WEBRENDER=, + MOZ_BUILD_WEBRENDER=1 ) + +AC_SUBST(MOZ_BUILD_WEBRENDER) +if test -n "$MOZ_BUILD_WEBRENDER"; then + AC_DEFINE(MOZ_BUILD_WEBRENDER) +fi + dnl ======================================================== dnl D3D compiler DLL dnl ======================================================== diff --git a/toolkit/library/rust/gkrust-features.mozbuild b/toolkit/library/rust/gkrust-features.mozbuild index cdc01b8c48..1a45528a34 100644 --- a/toolkit/library/rust/gkrust-features.mozbuild +++ b/toolkit/library/rust/gkrust-features.mozbuild @@ -7,9 +7,10 @@ gkrust_features = [] if CONFIG['MOZ_DEBUG']: gkrust_features += ['gecko_debug'] -gkrust_features += ['quantum_render'] -if CONFIG['MOZ_WEBRENDER_DEBUGGER']: - gkrust_features += ['webrender_debugger'] +if CONFIG['MOZ_BUILD_WEBRENDER']: + gkrust_features += ['quantum_render'] + if CONFIG['MOZ_WEBRENDER_DEBUGGER']: + gkrust_features += ['webrender_debugger'] if CONFIG['MOZ_PULSEAUDIO']: gkrust_features += ['cubeb_pulse_rust'] diff --git a/toolkit/library/rust/shared/lib.rs b/toolkit/library/rust/shared/lib.rs index d235215a88..63f6f69a3b 100644 --- a/toolkit/library/rust/shared/lib.rs +++ b/toolkit/library/rust/shared/lib.rs @@ -64,6 +64,7 @@ use std::os::raw::c_char; use std::os::raw::c_int; extern "C" { + #[cfg(feature = "quantum_render")] fn gfx_critical_note(msg: *const c_char); #[cfg(target_os = "android")] fn __android_log_write(prio: c_int, tag: *const c_char, text: *const c_char) -> c_int; @@ -96,6 +97,7 @@ impl GeckoLogger { log::set_boxed_logger(Box::new(gecko_logger)) } + #[cfg(feature = "quantum_render")] fn should_log_to_gfx_critical_note(record: &log::Record) -> bool { if record.level() == log::Level::Error && record.target().contains("webrender") { true @@ -104,6 +106,7 @@ impl GeckoLogger { } } + #[cfg(feature = "quantum_render")] fn maybe_log_to_gfx_critical_note(&self, record: &log::Record) { if Self::should_log_to_gfx_critical_note(record) { let msg = CString::new(format!("{}", record.args())).unwrap(); @@ -142,12 +145,18 @@ impl log::Log for GeckoLogger { self.logger.enabled(metadata) } + #[cfg(feature = "quantum_render")] fn log(&self, record: &log::Record) { // Forward log to gfxCriticalNote, if the log should be in gfx crash log. self.maybe_log_to_gfx_critical_note(record); self.log_out(record); } + #[cfg(not(feature = "quantum_render"))] + fn log(&self, record: &log::Record) { + self.log_out(record); + } + fn flush(&self) {} } diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 8e4dba6fd8..95d40502c9 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -13,7 +13,9 @@ #include "mozilla/IMEStateManager.h" #include "mozilla/layers/APZChild.h" #include "mozilla/layers/PLayerTransactionChild.h" -#include "mozilla/layers/WebRenderLayerManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderLayerManager.h" +#endif #include "mozilla/Preferences.h" #include "mozilla/PresShell.h" #include "mozilla/StaticPrefs_browser.h" @@ -507,7 +509,12 @@ nsresult PuppetWidget::ClearNativeTouchSequence(nsIObserver* aObserver) { void PuppetWidget::SetConfirmedTargetAPZC( uint64_t aInputBlockId, - const nsTArray& aTargets) const { +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif +) const { if (mBrowserChild) { mBrowserChild->SetTargetAPZC(aInputBlockId, aTargets); } @@ -562,11 +569,15 @@ bool PuppetWidget::CreateRemoteLayerManager( const std::function& aInitializeFunc) { RefPtr lm; MOZ_ASSERT(mBrowserChild); +#ifdef MOZ_BUILD_WEBRENDER if (mBrowserChild->GetCompositorOptions().UseWebRender()) { lm = new WebRenderLayerManager(this); } else { lm = new ClientLayerManager(this); } +#else + lm = new ClientLayerManager(this); +#endif if (!aInitializeFunc(lm)) { return false; diff --git a/widget/PuppetWidget.h b/widget/PuppetWidget.h index 59e79c0ebf..ac686b2b67 100644 --- a/widget/PuppetWidget.h +++ b/widget/PuppetWidget.h @@ -145,9 +145,13 @@ class PuppetWidget : public nsBaseWidget, virtual nsresult DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override; nsEventStatus DispatchInputEvent(WidgetInputEvent* aEvent) override; - void SetConfirmedTargetAPZC( - uint64_t aInputBlockId, - const nsTArray& aTargets) const override; + void SetConfirmedTargetAPZC(uint64_t aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) const override; void UpdateZoomConstraints( const uint32_t& aPresShellId, const ScrollableLayerGuid::ViewID& aViewId, const mozilla::Maybe& aConstraints) override; diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index bba6804043..8434e5004b 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -1400,8 +1400,13 @@ nsWindow::nsWindow() : mScreenId(0), // Use 0 (primary screen) as the default value. mIsVisible(false), mParent(nullptr), - mIsFullScreen(false), - mIsDisablingWebRender(false) {} + mIsFullScreen(false) +#ifdef MOZ_BUILD_WEBRENDER + , + mIsDisablingWebRender(false) +#endif +{ +} nsWindow::~nsWindow() { gTopLevelWindows.RemoveElement(this); @@ -1817,11 +1822,13 @@ mozilla::layers::LayerManager* nsWindow::GetLayerManager( return mLayerManager; } +#ifdef MOZ_BUILD_WEBRENDER if (mIsDisablingWebRender) { CreateLayerManager(); mIsDisablingWebRender = false; return mLayerManager; } +#endif return nullptr; } @@ -1857,10 +1864,12 @@ void nsWindow::CreateLayerManager() { } } +#ifdef MOZ_BUILD_WEBRENDER void nsWindow::NotifyDisablingWebRender() { mIsDisablingWebRender = true; RedrawAll(); } +#endif void nsWindow::OnSizeChanged(const gfx::IntSize& aSize) { ALOG("nsWindow: %p OnSizeChanged [%d %d]", (void*)this, aSize.width, diff --git a/widget/android/nsWindow.h b/widget/android/nsWindow.h index eee983d9b3..710d893d69 100644 --- a/widget/android/nsWindow.h +++ b/widget/android/nsWindow.h @@ -218,7 +218,9 @@ class nsWindow final : public nsBaseWidget { return nullptr; } +#ifdef MOZ_BUILD_WEBRENDER void NotifyDisablingWebRender(); +#endif // // nsIWidget @@ -345,7 +347,9 @@ class nsWindow final : public nsBaseWidget { nsCOMPtr mIdleService; bool mIsFullScreen; +#ifdef MOZ_BUILD_WEBRENDER bool mIsDisablingWebRender; +#endif bool UseExternalCompositingSurface() const override { return true; } diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index 620dc154d1..37fd8a75a3 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -452,9 +452,11 @@ class nsChildView final : public nsBaseWidget { virtual void PrepareWindowEffects() override; virtual void CleanupWindowEffects() override; +#ifdef MOZ_BUILD_WEBRENDER virtual void AddWindowOverlayWebRenderCommands( mozilla::layers::WebRenderBridgeChild* aWrBridge, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResourceUpdates) override; +#endif virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) override; virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext) override; diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 4996509f71..09c67f92e7 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -59,7 +59,10 @@ #include "mozilla/layers/CompositorOptions.h" #include "mozilla/layers/InputAPZContext.h" #include "mozilla/layers/APZCCallbackHelper.h" -#include "mozilla/layers/WebRenderLayerManager.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/layers/WebRenderLayerManager.h" +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/BrowserParent.h" #include "mozilla/gfx/GPUProcessManager.h" @@ -67,7 +70,6 @@ #include "mozilla/Move.h" #include "mozilla/Sprintf.h" #include "mozilla/StaticPrefs_layout.h" -#include "mozilla/webrender/WebRenderTypes.h" #include "nsRefPtrHashtable.h" #include "TouchEvents.h" #include "WritingModes.h" @@ -825,12 +827,14 @@ bool nsBaseWidget::IsSmallPopup() const { } bool nsBaseWidget::ComputeShouldAccelerate() { +#ifdef MOZ_BUILD_WEBRENDER if (gfx::gfxVars::UseWebRender() && !AllowWebRenderForThisWindow()) { // If WebRender is enabled, non-WebRender widgets use the basic compositor // (at least for now), even though they would get an accelerated compositor // if WebRender wasn't enabled. return false; } +#endif return gfx::gfxConfig::IsEnabled(gfx::Feature::HW_COMPOSITING) && WidgetTypeSupportsAcceleration(); } @@ -843,12 +847,14 @@ bool nsBaseWidget::UseAPZ() { StaticPrefs::apz_popups_enabled()))); } +#ifdef MOZ_BUILD_WEBRENDER bool nsBaseWidget::AllowWebRenderForThisWindow() { return WindowType() == eWindowType_toplevel || WindowType() == eWindowType_child || WindowType() == eWindowType_dialog || (WindowType() == eWindowType_popup && HasRemoteContent()); } +#endif void nsBaseWidget::CreateCompositor() { LayoutDeviceIntRect rect = GetBounds(); @@ -927,10 +933,20 @@ void nsBaseWidget::ConfigureAPZControllerThread() { void nsBaseWidget::SetConfirmedTargetAPZC( uint64_t aInputBlockId, - const nsTArray& aTargets) const { +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif +) const { APZThreadUtils::RunOnControllerThread( - NewRunnableMethod>>( + NewRunnableMethod>>( "layers::IAPZCTreeManager::SetTargetAPZC", mAPZC, &IAPZCTreeManager::SetTargetAPZC, aInputBlockId, aTargets)); } @@ -957,8 +973,12 @@ void nsBaseWidget::UpdateZoomConstraints( } LayersId layersId = mCompositorSession->RootLayerTreeId(); mAPZC->UpdateZoomConstraints( +#ifdef MOZ_BUILD_WEBRENDER SLGuidAndRenderRoot(layersId, aPresShellId, aViewId, wr::RenderRoot::Default), +#else + ScrollableLayerGuid(layersId, aPresShellId, aViewId), +#endif aConstraints); } @@ -1194,11 +1214,18 @@ already_AddRefed nsBaseWidget::CreateCompositorSession( // If widget type does not supports acceleration, we use ClientLayerManager // even when gfxVars::UseWebRender() is true. WebRender could coexist only // with BasicCompositor. +#ifdef MOZ_BUILD_WEBRENDER bool enableWR = gfx::gfxVars::UseWebRender() && WidgetTypeSupportsAcceleration() && AllowWebRenderForThisWindow(); +#endif bool enableAPZ = UseAPZ(); - CompositorOptions options(enableAPZ, enableWR); + CompositorOptions options(enableAPZ +#ifdef MOZ_BUILD_WEBRENDER + , + enableWR +#endif + ); bool enableAL = gfx::gfxConfig::IsEnabled(gfx::Feature::ADVANCED_LAYERS); options.SetUseAdvancedLayers(enableAL); @@ -1212,17 +1239,22 @@ already_AddRefed nsBaseWidget::CreateCompositorSession( #endif RefPtr lm; +#ifdef MOZ_BUILD_WEBRENDER if (options.UseWebRender()) { lm = new WebRenderLayerManager(this); } else { lm = new ClientLayerManager(this); } +#else + lm = new ClientLayerManager(this); +#endif bool retry = false; mCompositorSession = gpu->CreateTopLevelCompositor( this, lm, GetDefaultScale(), options, UseExternalCompositingSurface(), gfx::IntSize(aWidth, aHeight), &retry); +#ifdef MOZ_BUILD_WEBRENDER if (lm->AsWebRenderLayerManager() && mCompositorSession) { TextureFactoryIdentifier textureFactoryIdentifier; lm->AsWebRenderLayerManager()->Initialize( @@ -1236,6 +1268,7 @@ already_AddRefed nsBaseWidget::CreateCompositorSession( wr::WebRenderError::INITIALIZE); } } +#endif // We need to retry in a loop because the act of failing to create the // compositor can change our state (e.g. disable WebRender). @@ -1295,16 +1328,18 @@ void nsBaseWidget::CreateCompositor(int aWidth, int aHeight) { mInitialZoomConstraints.reset(); } +#ifdef MOZ_BUILD_WEBRENDER if (lm->AsWebRenderLayerManager()) { TextureFactoryIdentifier textureFactoryIdentifier = lm->GetTextureFactoryIdentifier(); MOZ_ASSERT(textureFactoryIdentifier.mParentBackend == LayersBackend::LAYERS_WR); ImageBridgeChild::IdentifyCompositorTextureHost(textureFactoryIdentifier); -#ifdef MOZ_VR +# ifdef MOZ_VR gfx::VRManagerChild::IdentifyTextureHost(textureFactoryIdentifier); -#endif +# endif } +#endif ShadowLayerForwarder* lf = lm->AsShadowForwarder(); if (lf) { @@ -1787,12 +1822,23 @@ void nsBaseWidget::ZoomToRect(const uint32_t& aPresShellId, } LayersId layerId = mCompositorSession->RootLayerTreeId(); APZThreadUtils::RunOnControllerThread( - NewRunnableMethod( - "layers::IAPZCTreeManager::ZoomToRect", mAPZC, - &IAPZCTreeManager::ZoomToRect, - SLGuidAndRenderRoot(layerId, aPresShellId, aViewId, - wr::RenderRoot::Default), - aRect, aFlags)); + NewRunnableMethod< +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot +#else + ScrollableLayerGuid +#endif + , + CSSRect, uint32_t>("layers::IAPZCTreeManager::ZoomToRect", mAPZC, + &IAPZCTreeManager::ZoomToRect, +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot(layerId, aPresShellId, aViewId, + wr::RenderRoot::Default), +#else + ScrollableLayerGuid(layerId, aPresShellId, + aViewId), +#endif + aRect, aFlags)); } #ifdef ACCESSIBILITY @@ -1830,23 +1876,44 @@ void nsBaseWidget::StartAsyncScrollbarDrag( MOZ_ASSERT(XRE_IsParentProcess() && mCompositorSession); LayersId layersId = mCompositorSession->RootLayerTreeId(); +#ifdef MOZ_BUILD_WEBRENDER SLGuidAndRenderRoot guid(layersId, aDragMetrics.mPresShellId, aDragMetrics.mViewId, wr::RenderRoot::Default); +#else + ScrollableLayerGuid guid(layersId, aDragMetrics.mPresShellId, + aDragMetrics.mViewId); +#endif - APZThreadUtils::RunOnControllerThread( - NewRunnableMethod( - "layers::IAPZCTreeManager::StartScrollbarDrag", mAPZC, - &IAPZCTreeManager::StartScrollbarDrag, guid, aDragMetrics)); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod< +#ifdef MOZ_BUILD_WEBRENDER + SLGuidAndRenderRoot, +#else + ScrollableLayerGuid, +#endif + AsyncDragMetrics>( + "layers::IAPZCTreeManager::StartScrollbarDrag", mAPZC, + &IAPZCTreeManager::StartScrollbarDrag, guid, aDragMetrics)); } bool nsBaseWidget::StartAsyncAutoscroll(const ScreenPoint& aAnchorLocation, - const SLGuidAndRenderRoot& aGuid) { +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif +) { MOZ_ASSERT(XRE_IsParentProcess() && AsyncPanZoomEnabled()); return mAPZC->StartAutoscroll(aGuid, aAnchorLocation); } -void nsBaseWidget::StopAsyncAutoscroll(const SLGuidAndRenderRoot& aGuid) { +void nsBaseWidget::StopAsyncAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif +) { MOZ_ASSERT(XRE_IsParentProcess() && AsyncPanZoomEnabled()); mAPZC->StopAutoscroll(aGuid); diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index 6145f27910..47fc1e9f2e 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -126,7 +126,9 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference { typedef mozilla::layers::CompositorBridgeParent CompositorBridgeParent; typedef mozilla::layers::IAPZCTreeManager IAPZCTreeManager; typedef mozilla::layers::GeckoContentController GeckoContentController; +#ifdef MOZ_BUILD_WEBRENDER typedef mozilla::layers::SLGuidAndRenderRoot SLGuidAndRenderRoot; +#endif typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid; typedef mozilla::layers::APZEventState APZEventState; typedef mozilla::layers::SetAllowedTouchBehaviorCallback @@ -323,9 +325,13 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference { nsEventStatus DispatchInputEvent(mozilla::WidgetInputEvent* aEvent) override; void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) override; - void SetConfirmedTargetAPZC( - uint64_t aInputBlockId, - const nsTArray& aTargets) const override; + void SetConfirmedTargetAPZC(uint64_t aInputBlockId, +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) const override; void UpdateZoomConstraints( const uint32_t& aPresShellId, const ScrollableLayerGuid::ViewID& aViewId, @@ -381,9 +387,20 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference { const AsyncDragMetrics& aDragMetrics) override; virtual bool StartAsyncAutoscroll(const ScreenPoint& aAnchorLocation, - const SLGuidAndRenderRoot& aGuid) override; +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif + ) override; - virtual void StopAsyncAutoscroll(const SLGuidAndRenderRoot& aGuid) override; + virtual void StopAsyncAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif + ) override; /** * Use this when GetLayerManager() returns a BasicLayerManager @@ -591,7 +608,9 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference { bool UseAPZ(); +#ifdef MOZ_BUILD_WEBRENDER bool AllowWebRenderForThisWindow(); +#endif /** * For widgets that support synthesizing native touch events, this function diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 9c87741d99..97d3861f9b 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -64,8 +64,10 @@ struct FrameMetrics; class LayerManager; class LayerManagerComposite; class PLayerTransactionChild; +#ifdef MOZ_BUILD_WEBRENDER struct SLGuidAndRenderRoot; class WebRenderBridgeChild; +#endif } // namespace layers namespace gfx { class DrawTarget; @@ -343,7 +345,9 @@ class nsIWidget : public nsISupports { typedef mozilla::layers::LayerManagerComposite LayerManagerComposite; typedef mozilla::layers::LayersBackend LayersBackend; typedef mozilla::layers::PLayerTransactionChild PLayerTransactionChild; +#ifdef MOZ_BUILD_WEBRENDER typedef mozilla::layers::SLGuidAndRenderRoot SLGuidAndRenderRoot; +#endif typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid; typedef mozilla::layers::ZoomConstraints ZoomConstraints; typedef mozilla::widget::IMEMessage IMEMessage; @@ -1270,10 +1274,12 @@ class nsIWidget : public nsISupports { /** * Called on the main thread at the end of WebRender display list building. */ +#ifdef MOZ_BUILD_WEBRENDER virtual void AddWindowOverlayWebRenderCommands( mozilla::layers::WebRenderBridgeChild* aWrBridge, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources) {} +#endif /** * Called when Gecko knows which themed widgets exist in this window. @@ -1401,7 +1407,12 @@ class nsIWidget : public nsISupports { */ virtual void SetConfirmedTargetAPZC( uint64_t aInputBlockId, - const nsTArray& aTargets) const = 0; +#ifdef MOZ_BUILD_WEBRENDER + const nsTArray& aTargets +#else + const nsTArray& aTargets +#endif + ) const = 0; /** * Returns true if APZ is in use, false otherwise. @@ -1668,13 +1679,24 @@ class nsIWidget : public nsISupports { * @return true if APZ has been successfully notified */ virtual bool StartAsyncAutoscroll(const ScreenPoint& aAnchorLocation, - const SLGuidAndRenderRoot& aGuid) = 0; +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif + ) = 0; /** * Notify APZ to stop autoscrolling. * @param aGuid identifies the scroll frame which is being autoscrolled. */ - virtual void StopAsyncAutoscroll(const SLGuidAndRenderRoot& aGuid) = 0; + virtual void StopAsyncAutoscroll( +#ifdef MOZ_BUILD_WEBRENDER + const SLGuidAndRenderRoot& aGuid +#else + const ScrollableLayerGuid& aGuid +#endif + ) = 0; // If this widget supports out-of-process compositing, it can override // this method to provide additional information to the compositor. diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index b3cc5eb780..5c8834a4a1 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -207,7 +207,9 @@ #include "mozilla/Telemetry.h" #include "mozilla/plugins/PluginProcessParent.h" -#include "mozilla/webrender/WebRenderAPI.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderAPI.h" +#endif using namespace mozilla; using namespace mozilla::dom; @@ -266,7 +268,7 @@ LONG nsWindow::sLastClickCount = 0L; BYTE nsWindow::sLastMouseButton = 0; // Trim heap on minimize. (initialized, but still true.) -int nsWindow::sTrimOnMinimize = 2; +int nsWindow::sTrimOnMinimize = 2; TriStateBool nsWindow::sHasBogusPopupsDropShadowOnMultiMonitor = TRI_UNKNOWN; @@ -496,7 +498,8 @@ class TIPMessageHandler { DWORD aGeneratingTid, DWORD aEventTime) { A11yInstantiationBlocker block; - //sProcessCaretEventsStub(aWinEventHook, aEvent, aHwnd, aObjectId, aChildId, + // sProcessCaretEventsStub(aWinEventHook, aEvent, aHwnd, aObjectId, + // aChildId, // aGeneratingTid, aEventTime); } @@ -753,7 +756,8 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent, parent = nullptr; } - if (IsVistaOrLater() && !IsWin8OrLater() && HasBogusPopupsDropShadowOnMultiMonitor() && + if (IsVistaOrLater() && !IsWin8OrLater() && + HasBogusPopupsDropShadowOnMultiMonitor() && ShouldUseOffMainThreadCompositing()) { extendedStyle |= WS_EX_COMPOSITED; } @@ -815,8 +819,8 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent, if (mIsRTL && WinUtils::dwmSetWindowAttributePtr) { DWORD dwAttribute = TRUE; - WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_NONCLIENT_RTL_LAYOUT, &dwAttribute, - sizeof dwAttribute); + WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_NONCLIENT_RTL_LAYOUT, + &dwAttribute, sizeof dwAttribute); } if (mOpeningAnimationSuppressed) { @@ -897,9 +901,8 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent, // the working set when windows are minimized, but on Vista and up it has // little to no effect. Since this feature has been the source of numerous // bugs over the years, disable it (sTrimOnMinimize=1) on Vista and up. - sTrimOnMinimize = - Preferences::GetBool("config.trim_on_minimize", - IsVistaOrLater() ? 1 : 0); + sTrimOnMinimize = Preferences::GetBool("config.trim_on_minimize", + IsVistaOrLater() ? 1 : 0); sSwitchKeyboardLayout = Preferences::GetBool("intl.keyboard.per_window_layout", false); } @@ -1786,7 +1789,10 @@ void nsWindow::Move(double aX, double aY) { // Workaround SetWindowPos bug with D3D9. If our window has a clip // region, some drivers or OSes may incorrectly copy into the clipped-out // area. - if (IsPlugin() && (!mLayerManager || mLayerManager->GetBackendType() == LayersBackend::LAYERS_D3D9) && mClipRects && + if (IsPlugin() && + (!mLayerManager || + mLayerManager->GetBackendType() == LayersBackend::LAYERS_D3D9) && + mClipRects && (mClipRectCount != 1 || !mClipRects[0].IsEqualInterior( LayoutDeviceIntRect(0, 0, mBounds.Width(), mBounds.Height())))) { @@ -2036,12 +2042,12 @@ void nsWindow::SetSizeMode(nsSizeMode aMode) { break; case nsSizeMode_Minimized: - // Using SW_SHOWMINIMIZED prevents the working set from being trimmed but - // keeps the window active in the tray. So after the window is minimized, - // windows will fire WM_WINDOWPOSCHANGED (OnWindowPosChanged) at which point - // we will do some additional processing to get the active window set right. - // If sTrimOnMinimize is set, we let windows handle minimization normally - // using SW_MINIMIZE. + // Using SW_SHOWMINIMIZED prevents the working set from being trimmed + // but keeps the window active in the tray. So after the window is + // minimized, windows will fire WM_WINDOWPOSCHANGED (OnWindowPosChanged) + // at which point we will do some additional processing to get the + // active window set right. If sTrimOnMinimize is set, we let windows + // handle minimization normally using SW_MINIMIZE. mode = sTrimOnMinimize ? SW_MINIMIZE : SW_SHOWMINIMIZED; break; @@ -2063,10 +2069,10 @@ void nsWindow::SetSizeMode(nsSizeMode aMode) { } void nsWindow::SuppressAnimation(bool aSuppress) { - if(WinUtils::dwmSetWindowAttributePtr) { + if (WinUtils::dwmSetWindowAttributePtr) { DWORD dwAttribute = aSuppress ? TRUE : FALSE; - WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_TRANSITIONS_FORCEDISABLED, &dwAttribute, - sizeof dwAttribute); + WinUtils::dwmSetWindowAttributePtr(mWnd, DWMWA_TRANSITIONS_FORCEDISABLED, + &dwAttribute, sizeof dwAttribute); } } @@ -2383,7 +2389,7 @@ static WindowsDllInterceptor::FuncHookType BOOL WINAPI GetWindowInfoHook(HWND hWnd, PWINDOWINFO pwi) { if (!sGetWindowInfoPtrStub) { - NS_ASSERTION(FALSE, "Something is horribly wrong in GetWindowInfoHook!"); + NS_ASSERTION(FALSE, "Something is horribly wrong in GetWindowInfoHook!"); return FALSE; } int windowStatus = @@ -3742,7 +3748,12 @@ LayerManager* nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager, reinterpret_cast(static_cast(this)), mTransparencyMode); // If we're not using the compositor, the options don't actually matter. - CompositorOptions options(false, false); + CompositorOptions options(false +#ifdef MOZ_BUILD_WEBRENDER + , + false +#endif + ); mBasicLayersSurface = new InProcessWinCompositorWidget(initData, options, this); mCompositorWidgetDelegate = mBasicLayersSurface; @@ -3880,6 +3891,7 @@ void nsWindow::UpdateThemeGeometries( layerManager->SetRegionToClear(clearRegion); } +#ifdef MOZ_BUILD_WEBRENDER void nsWindow::AddWindowOverlayWebRenderCommands( layers::WebRenderBridgeChild* aWrBridge, wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources) { @@ -3891,6 +3903,7 @@ void nsWindow::AddWindowOverlayWebRenderCommands( aBuilder.PushClearRectWithComplexRegion(rect, complexRegion); } } +#endif uint32_t nsWindow::GetMaxTouchPoints() const { return WinUtils::GetMaxTouchPoints(); @@ -4910,7 +4923,8 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, /* We don't do this for win10 glass with a custom titlebar, * in order to avoid the caption buttons breaking. */ !(IsWin10OrLater() && HasGlass()) && - WinUtils::dwmDwmDefWindowProcPtr(mWnd, msg, wParam, lParam, &dwmHitResult)) { + WinUtils::dwmDwmDefWindowProcPtr(mWnd, msg, wParam, lParam, + &dwmHitResult)) { *aRetValue = dwmHitResult; return true; } @@ -4935,7 +4949,6 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, obsServ->NotifyObservers(cancelQuit, "quit-application-requested", nullptr); - bool abortQuit; cancelQuit->GetData(&abortQuit); sCanQuit = abortQuit ? TRI_FALSE : TRI_TRUE; @@ -4964,12 +4977,12 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, mozilla::services::GetObserverService(); const char16_t* context = u"shutdown-persist"; const char16_t* syncShutdown = u"syncShutdown"; - //const char16_t* quitType = GetQuitType(); + // const char16_t* quitType = GetQuitType(); obsServ->NotifyObservers(nullptr, "quit-application-granted", syncShutdown); obsServ->NotifyObservers(nullptr, "quit-application-forced", nullptr); - //obsServ->NotifyObservers(nullptr, "quit-application", quitType); + // obsServ->NotifyObservers(nullptr, "quit-application", quitType); obsServ->NotifyObservers(nullptr, "quit-application", nullptr); obsServ->NotifyObservers(nullptr, "profile-change-net-teardown", context); @@ -5034,8 +5047,8 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, } break; case WM_SETTINGCHANGE: { - if (//wParam == SPI_SETCLIENTAREAANIMATION || - // CaretBlinkTime is cached in nsLookAndFeel + if ( // wParam == SPI_SETCLIENTAREAANIMATION || + // CaretBlinkTime is cached in nsLookAndFeel wParam == SPI_SETKEYBOARDDELAY) { NotifyThemeChanged(); break; @@ -6519,8 +6532,9 @@ void nsWindow::OnWindowPosChanged(WINDOWPOS* wp) { void nsWindow::ActivateOtherWindowHelper(HWND aWnd) { // Find the next window that is enabled, visible, and not minimized. HWND hwndBelow = ::GetNextWindow(aWnd, GW_HWNDNEXT); - while (hwndBelow && (!::IsWindowEnabled(hwndBelow) || !::IsWindowVisible(hwndBelow) || - ::IsIconic(hwndBelow))) { + while (hwndBelow && + (!::IsWindowEnabled(hwndBelow) || !::IsWindowVisible(hwndBelow) || + ::IsIconic(hwndBelow))) { hwndBelow = ::GetNextWindow(hwndBelow, GW_HWNDNEXT); } @@ -6528,8 +6542,7 @@ void nsWindow::ActivateOtherWindowHelper(HWND aWnd) { // next window. ::SetWindowPos(aWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); - if (hwndBelow) - ::SetForegroundWindow(hwndBelow); + if (hwndBelow) ::SetForegroundWindow(hwndBelow); // Play the minimize sound while we're here, since that is also // forgotten when we use SW_SHOWMINIMIZED. diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index 10a9eb12bb..1a54365e20 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -27,7 +27,9 @@ #include "mozilla/Maybe.h" #include "mozilla/MouseEvents.h" #include "mozilla/TimeStamp.h" -#include "mozilla/webrender/WebRenderTypes.h" +#ifdef MOZ_BUILD_WEBRENDER +# include "mozilla/webrender/WebRenderTypes.h" +#endif #include "mozilla/dom/MouseEventBinding.h" #include "nsMargin.h" #include "nsRegionFwd.h" @@ -504,10 +506,12 @@ class nsWindow final : public nsWindowBase { void ClearCachedResources(); nsIWidgetListener* GetPaintListener(); +#ifdef MOZ_BUILD_WEBRENDER virtual void AddWindowOverlayWebRenderCommands( mozilla::layers::WebRenderBridgeChild* aWrBridge, mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResourceUpdates) override; +#endif already_AddRefed CreateScrollSnapshot() override;