Bug 1600472 - Disable allowing sacrificing subpixel anti-aliasing for small screens. r=jrmuizel

This patch only allows sacrificing subpixel anti-aliasing when the
screen size is larger than WUXGA, and when the force disable pref is not
set. In the future, we may also add disable this for high end GPUs.

This also consolidates the WebRender debug flags to use the same
signaling infrastructure to avoid needing to store the debug flag state
and check on each transaction. Instead it now applies the debug flag
updates when the gfxVar changes.

Differential Revision: https://phabricator.services.mozilla.com/D57469

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew Osmond 2020-01-10 16:57:55 +00:00
parent 7faf19260e
commit 3a7b9515de
12 changed files with 158 additions and 11 deletions

View File

@ -56,7 +56,8 @@ class gfxVarReceiver;
_(LayersWindowRecordingPath, nsCString, nsCString()) \
_(RemoteCanvasEnabled, bool, false) \
_(UseDoubleBufferingWithCompositor, bool, false) \
_(UseGLSwizzle, bool, true)
_(UseGLSwizzle, bool, true) \
_(AllowSacrificingSubpixelAA, bool, false)
/* Add new entries above this line. */

View File

@ -134,6 +134,7 @@ bool GPUParent::Init(base::ProcessId aParentPid, const char* aParentBuildID,
APZThreadUtils::SetControllerThread(MessageLoop::current());
apz::InitializeGlobalState();
LayerTreeOwnerTracker::Initialize();
CompositorBridgeParent::InitializeStatics();
mozilla::ipc::SetThisProcessName("GPU Process");
#ifdef XP_WIN
wmf::MFStartup();

View File

@ -262,6 +262,18 @@ inline void CompositorBridgeParent::ForEachIndirectLayerTree(
}
}
/*static*/ template <typename Lambda>
inline void CompositorBridgeParent::ForEachWebRenderBridgeParent(
const Lambda& aCallback) {
sIndirectLayerTreesLock->AssertCurrentThreadOwns();
for (auto it : sIndirectLayerTrees) {
LayerTreeState* state = &it.second;
if (state->mWrBridge) {
aCallback(state->mWrBridge);
}
}
}
/**
* A global map referencing each compositor by ID.
*
@ -1996,6 +2008,52 @@ void CompositorBridgeParent::AccumulateMemoryReport(wr::MemoryReport* aReport) {
}
}
/*static*/
void CompositorBridgeParent::InitializeStatics() {
gfxVars::SetAllowSacrificingSubpixelAAListener(&UpdateQualitySettings);
gfxVars::SetWebRenderDebugFlagsListener(&UpdateDebugFlags);
}
/*static*/
void CompositorBridgeParent::UpdateQualitySettings() {
if (!CompositorThreadHolder::IsInCompositorThread()) {
if (CompositorLoop()) {
CompositorLoop()->PostTask(
NewRunnableFunction("CompositorBridgeParent::UpdateQualitySettings",
&CompositorBridgeParent::UpdateQualitySettings));
}
// If there is no compositor loop, e.g. due to shutdown, then we can
// safefully just ignore this request.
return;
}
MonitorAutoLock lock(*sIndirectLayerTreesLock);
ForEachWebRenderBridgeParent([&](WebRenderBridgeParent* wrBridge) -> void {
wrBridge->UpdateQualitySettings();
});
}
/*static*/
void CompositorBridgeParent::UpdateDebugFlags() {
if (!CompositorThreadHolder::IsInCompositorThread()) {
if (CompositorLoop()) {
CompositorLoop()->PostTask(
NewRunnableFunction("CompositorBridgeParent::UpdateDebugFlags",
&CompositorBridgeParent::UpdateDebugFlags));
}
// If there is no compositor loop, e.g. due to shutdown, then we can
// safefully just ignore this request.
return;
}
MonitorAutoLock lock(*sIndirectLayerTreesLock);
ForEachWebRenderBridgeParent([&](WebRenderBridgeParent* wrBridge) -> void {
wrBridge->UpdateDebugFlags();
});
}
RefPtr<WebRenderBridgeParent> CompositorBridgeParent::GetWebRenderBridgeParent()
const {
return mWrBridge;

View File

@ -526,6 +526,11 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase,
*/
void InvalidateRemoteLayers();
/**
* Initialize statics.
*/
static void InitializeStatics();
/**
* Returns a pointer to the CompositorBridgeParent corresponding to the given
* ID.
@ -717,6 +722,16 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase,
*/
static void DeallocateLayerTreeId(LayersId aId);
/**
* Notify the compositor the quality settings have been updated.
*/
static void UpdateQualitySettings();
/**
* Notify the compositor the debug flags have been updated.
*/
static void UpdateDebugFlags();
/**
* Wrap the data structure to be sent over IPC.
*/
@ -797,6 +812,11 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase,
template <typename Lambda>
inline void ForEachIndirectLayerTree(const Lambda& aCallback);
// The indirect layer tree lock must be held before calling this function.
// Callback should take (LayerTreeState* aState, const LayersId& aLayersId)
template <typename Lambda>
static inline void ForEachWebRenderBridgeParent(const Lambda& aCallback);
RefPtr<HostLayerManager> mLayerManager;
RefPtr<Compositor> mCompositor;
RefPtr<AsyncCompositionManager> mCompositionManager;

View File

@ -16,6 +16,7 @@
#include "mozilla/Range.h"
#include "mozilla/StaticPrefs_gfx.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/layers/AnimationHelper.h"
#include "mozilla/layers/APZSampler.h"
#include "mozilla/layers/APZUpdater.h"
@ -358,6 +359,9 @@ WebRenderBridgeParent::WebRenderBridgeParent(
MOZ_ASSERT(api);
mApis[api->GetRenderRoot()] = api;
}
UpdateDebugFlags();
UpdateQualitySettings();
}
WebRenderBridgeParent::WebRenderBridgeParent(const wr::PipelineId& aPipelineId)
@ -1728,6 +1732,26 @@ void WebRenderBridgeParent::FlushFramePresentation() {
mApis[wr::RenderRoot::Default]->WaitFlushed();
}
void WebRenderBridgeParent::UpdateQualitySettings() {
for (auto& api : mApis) {
if (!api) {
continue;
}
wr::TransactionBuilder txn;
txn.UpdateQualitySettings(gfxVars::AllowSacrificingSubpixelAA());
api->SendTransaction(txn);
}
}
void WebRenderBridgeParent::UpdateDebugFlags() {
for (auto& api : mApis) {
if (!api) {
continue;
}
api->UpdateDebugFlags(gfxVars::WebRenderDebugFlags());
}
}
#if defined(MOZ_WIDGET_ANDROID)
void WebRenderBridgeParent::RequestScreenPixels(
UiCompositorControllerParent* aController) {

View File

@ -103,6 +103,9 @@ class WebRenderBridgeParent final
return mCompositorBridge;
}
void UpdateQualitySettings();
void UpdateDebugFlags();
mozilla::ipc::IPCResult RecvEnsureConnected(
TextureFactoryIdentifier* aTextureFactoryIdentifier,
MaybeIdNamespace* aMaybeIdNamespace) override;

View File

@ -608,6 +608,10 @@ static void WebRenderDebugPrefChangeCallback(const char* aPrefName, void*) {
gfx::gfxVars::SetWebRenderDebugFlags(flags.bits);
}
static void WebRenderQualityPrefChangeCallback(const char* aPref, void*) {
gfxPlatform::GetPlatform()->UpdateAllowSacrificingSubpixelAA();
}
#if defined(USE_SKIA)
static uint32_t GetSkiaGlyphCacheSize() {
// Only increase font cache size on non-android to save memory.
@ -2518,6 +2522,15 @@ void gfxPlatform::UpdateCanUseHardwareVideoDecoding() {
}
}
void gfxPlatform::UpdateAllowSacrificingSubpixelAA() {
int64_t kMaxPixels = 1920 * 1200; // WUXGA
bool allowSacrificingSubpixelAA =
mScreenPixels > kMaxPixels &&
!StaticPrefs::
gfx_webrender_quality_force_disable_sacrificing_subpixel_aa();
gfxVars::SetAllowSacrificingSubpixelAA(allowSacrificingSubpixelAA);
}
void gfxPlatform::InitAcceleration() {
if (sLayersAccelerationPrefsInitialized) {
return;
@ -3272,6 +3285,12 @@ void gfxPlatform::InitWebRenderConfig() {
if (XRE_IsParentProcess()) {
Preferences::RegisterPrefixCallbackAndCall(
WebRenderDebugPrefChangeCallback, WR_DEBUG_PREF);
Preferences::RegisterCallback(
WebRenderQualityPrefChangeCallback,
nsDependentCString(
StaticPrefs::
GetPrefName_gfx_webrender_quality_force_disable_sacrificing_subpixel_aa()));
UpdateAllowSacrificingSubpixelAA();
}
}
#if defined(MOZ_WIDGET_GTK)

View File

@ -664,6 +664,12 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
*/
static void ReInitFrameRate();
/**
* Update allow sacrificing subpixel AA quality setting (called after pref
* changes).
*/
void UpdateAllowSacrificingSubpixelAA();
/**
* Used to test which input types are handled via APZ.
*/

View File

@ -363,7 +363,6 @@ WebRenderAPI::WebRenderAPI(wr::DocumentHandle* aHandle, wr::WindowId aId,
mUseDComp(aUseDComp),
mUseTripleBuffering(aUseTripleBuffering),
mSyncHandle(aSyncHandle),
mDebugFlags({0}),
mRenderRoot(aRenderRoot) {}
WebRenderAPI::~WebRenderAPI() {
@ -386,14 +385,10 @@ WebRenderAPI::~WebRenderAPI() {
}
void WebRenderAPI::UpdateDebugFlags(uint32_t aFlags) {
if (mDebugFlags.bits != aFlags) {
mDebugFlags.bits = aFlags;
wr_api_set_debug_flags(mDocHandle, mDebugFlags);
}
wr_api_set_debug_flags(mDocHandle, wr::DebugFlags{aFlags});
}
void WebRenderAPI::SendTransaction(TransactionBuilder& aTxn) {
UpdateDebugFlags(gfx::gfxVars::WebRenderDebugFlags());
wr_api_send_transaction(mDocHandle, aTxn.Raw(), aTxn.UseSceneBuilderThread());
}
@ -405,8 +400,6 @@ void WebRenderAPI::SendTransactions(
return;
}
aApis[RenderRoot::Default]->UpdateDebugFlags(
gfx::gfxVars::WebRenderDebugFlags());
AutoTArray<DocumentHandle*, kRenderRootCount> documentHandles;
AutoTArray<Transaction*, kRenderRootCount> txns;
Maybe<bool> useSceneBuilderThread;
@ -844,6 +837,11 @@ void TransactionBuilder::DeleteFontInstance(wr::FontInstanceKey aKey) {
wr_resource_updates_delete_font_instance(mTxn, aKey);
}
void TransactionBuilder::UpdateQualitySettings(
bool aAllowSacrificingSubpixelAA) {
wr_transaction_set_quality_settings(mTxn, aAllowSacrificingSubpixelAA);
}
class FrameStartTime : public RendererEvent {
public:
explicit FrameStartTime(const TimeStamp& aTime) : mTime(aTime) {

View File

@ -179,6 +179,8 @@ class TransactionBuilder final {
void DeleteFontInstance(wr::FontInstanceKey aKey);
void UpdateQualitySettings(bool aAllowSacrificingSubpixelAA);
void Notify(wr::Checkpoint aWhen, UniquePtr<NotificationHandler> aHandler);
void Clear();
@ -308,7 +310,6 @@ class WebRenderAPI final {
bool mUseDComp;
bool mUseTripleBuffering;
layers::SyncHandle mSyncHandle;
wr::DebugFlags mDebugFlags;
wr::RenderRoot mRenderRoot;
// We maintain alive the root api to know when to shut the render backend

View File

@ -104,7 +104,6 @@ type WrColorDepth = ColorDepth;
/// cbindgen:field-names=[mNamespace, mHandle]
type WrColorRange = ColorRange;
#[repr(C)]
pub struct WrSpaceAndClip {
space: WrSpatialId,
@ -1824,6 +1823,16 @@ pub extern "C" fn wr_transaction_set_is_transform_async_zooming(
txn.set_is_transform_async_zooming(is_zooming, PropertyBindingId::new(animation_id));
}
#[no_mangle]
pub extern "C" fn wr_transaction_set_quality_settings(
txn: &mut Transaction,
allow_sacrificing_subpixel_aa: bool
) {
txn.set_quality_settings(QualitySettings {
allow_sacrificing_subpixel_aa
});
}
#[no_mangle]
pub extern "C" fn wr_resource_updates_add_image(
txn: &mut Transaction,

View File

@ -3828,6 +3828,13 @@
#endif
mirror: always
# Force disables allowing sacrificing subpixel anti-aliasing for less
# powerful configurations.
- name: gfx.webrender.quality.force-disable-sacrificing-subpixel-aa
type: bool
value: false
mirror: always
# Use vsync events generated by hardware
- name: gfx.work-around-driver-bugs
type: bool