38808be4创建于 2025年1月19日历史提交
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/base/features.h"

#include <string>

#include "base/feature_list.h"
#include "build/build_config.h"
#include "ui/base/ui_base_features.h"

namespace features {

// Uses the Resume method instead of the Catch-up method for animated images.
// - Catch-up behavior tries to keep animated images in pace with wall-clock
//   time. This might require decoding several animation frames if the
//   animation has fallen behind.
// - Resume behavior presents what would have been the next presented frame.
//   This means it might only decode one frame, resuming where it left off.
//   However, if the animation updates faster than the display's refresh rate,
//   it is possible to decode more than a single frame.
BASE_FEATURE(kAnimatedImageResume,
             "AnimatedImageResume",
             base::FEATURE_DISABLED_BY_DEFAULT);

bool IsImpulseScrollAnimationEnabled() {
  return base::FeatureList::IsEnabled(features::kWindowsScrollingPersonality);
}

// Whether the compositor should attempt to sync with the scroll handlers before
// submitting a frame.
BASE_FEATURE(kSynchronizedScrolling,
             "SynchronizedScrolling",
#if BUILDFLAG(IS_ANDROID)
             base::FEATURE_DISABLED_BY_DEFAULT);
#else
             base::FEATURE_ENABLED_BY_DEFAULT);
#endif

BASE_FEATURE(kAvoidRasterDuringElasticOverscroll,
             "AvoidRasterDuringElasticOverscroll",
             base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kRemoveMobileViewportDoubleTap,
             "RemoveMobileViewportDoubleTap",
             base::FEATURE_ENABLED_BY_DEFAULT);

// Design doc: bit.ly/scrollunification
// Disabled on Windows due to crbug.com/1378021.
BASE_FEATURE(kScrollUnification,
             "ScrollUnification",
#if BUILDFLAG(IS_WIN)
             base::FEATURE_DISABLED_BY_DEFAULT);
#else
             base::FEATURE_ENABLED_BY_DEFAULT);
#endif

BASE_FEATURE(kMainRepaintScrollPrefersNewContent,
             "MainRepaintScrollPrefersNewContent",
             base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kFlushGpuAtDraw,
             "FlushGpuAtDraw",
             base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kSchedulerSmoothnessForAnimatedScrolls,
             "SmoothnessModeForAnimatedScrolls",
             base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kHudDisplayForPerformanceMetrics,
             "HudDisplayForPerformanceMetrics",
             base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kRenderSurfaceCommonAncestorClip,
             "RenderSurfaceCommonAncestorClip",
             base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kJankInjectionAblationFeature,
             "JankInjectionAblation",
             base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kPreferNewContentForCheckerboardedScrolls,
             "PreferNewContentForCheckerboardedScrolls",
             base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kDurationEstimatesInCompositorTimingHistory,
             "DurationEstimatesInCompositorTimingHistory",
             base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kNonBlockingCommit,
             "NonBlockingCommit",
             base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kSlidingWindowForDroppedFrameCounter,
             "SlidingWindowForDroppedFrameCounter",
             base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kNormalPriorityImageDecoding,
             "NormalPriorityImageDecoding",
             base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kUseDMSAAForTiles,
             "UseDMSAAForTiles",
#if BUILDFLAG(IS_OHOS)
             base::FEATURE_ENABLED_BY_DEFAULT);
#else
             base::FEATURE_DISABLED_BY_DEFAULT);
#endif

BASE_FEATURE(kUpdateBrowserControlsWithoutProxy,
             "UpdateBrowserControlsWithoutProxy",
             base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kRasterTilePriorityQueue,
             "RasterTilePriorityQueue",
             base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kUIEnableSharedImageCacheForGpu,
             "UIEnableSharedImageCacheForGpu",
#if BUILDFLAG(IS_CHROMEOS_LACROS)
             base::FEATURE_ENABLED_BY_DEFAULT);
#else
             base::FEATURE_DISABLED_BY_DEFAULT);
#endif

BASE_FEATURE(kReclaimResourcesFlushInBackground,
             "ReclaimResourcesFlushInBackground",
             base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kMoreAggressiveSolidColorDetection,
             "MoreAggressiveSolidColorDetection",
             base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kReducedFrameRateEstimation,
             "kReducedFrameRateEstimation",
             base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kWaitForLateScrollEvents,
             "WaitForLateScrollEvents",
             base::FEATURE_ENABLED_BY_DEFAULT);

const base::FeatureParam<double> kWaitForLateScrollEventsDeadlineRatio{
    &kWaitForLateScrollEvents, "deadline_ratio", 0.333};

const base::FeatureParam<std::string> kScrollEventDispatchMode(
    &kWaitForLateScrollEvents,
    "mode",
    "DispatchScrollEventsImmediately");
constexpr const char kScrollEventDispatchModeEnqueueScrollEvents[] =
    "EnqueueScrollEvents";
constexpr const char kScrollEventDispatchModeDispatchScrollEventsImmediately[] =
    "DispatchScrollEventsImmediately";
constexpr const char kScrollEventDispatchModeUseScrollPredictorForEmptyQueue[] =
    "UseScrollPredictorForEmptyQueue";
constexpr const char kScrollEventDispatchModeUseScrollPredictorForDeadline[] =
    "UseScrollPredictorForDeadline";

}  // namespace features