#include "third_party/blink/renderer/platform/graphics/dark_mode_filter.h"
#include <cmath>
#include <optional>
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/containers/lru_cache.h"
#include "base/notreached.h"
#include "third_party/blink/public/common/switches.h"
#include "third_party/blink/renderer/platform/graphics/color.h"
#include "third_party/blink/renderer/platform/graphics/dark_mode_color_classifier.h"
#include "third_party/blink/renderer/platform/graphics/dark_mode_color_filter.h"
#include "third_party/blink/renderer/platform/graphics/dark_mode_image_cache.h"
#include "third_party/blink/renderer/platform/graphics/dark_mode_image_classifier.h"
#include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkPixmap.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "ui/gfx/color_utils.h"
namespace blink {
namespace {
const size_t kMaxCacheSize = …;
constexpr SkColor SK_ColorDark = …;
bool IsRasterSideDarkModeForImagesEnabled() { … }
bool ShouldUseRasterSidePath(Image* image) { … }
sk_sp<cc::ColorFilter> GetDarkModeFilterForImageOnMainThread(
DarkModeFilter* filter,
Image* image,
const SkIRect& rounded_src) { … }
}
class DarkModeInvertedColorCache { … };
DarkModeFilter::DarkModeFilter(const DarkModeSettings& settings)
: … { … }
DarkModeFilter::~DarkModeFilter() { … }
DarkModeFilter::ImmutableData::ImmutableData(const DarkModeSettings& settings)
: … { … }
DarkModeImagePolicy DarkModeFilter::GetDarkModeImagePolicy() const { … }
SkColor4f DarkModeFilter::AdjustDarkenColor(
const SkColor4f& color,
DarkModeFilter::ElementRole role,
const SkColor4f& contrast_background) { … }
SkColor4f DarkModeFilter::InvertColorIfNeeded(
const SkColor4f& color,
ElementRole role,
const SkColor4f& contrast_background) { … }
SkColor4f DarkModeFilter::InvertColorIfNeeded(const SkColor4f& color,
ElementRole role) { … }
void DarkModeFilter::ApplyFilterToImage(Image* image,
cc::PaintFlags* flags,
const SkRect& src) { … }
bool DarkModeFilter::ShouldApplyFilterToImage(ImageType type) const { … }
sk_sp<cc::ColorFilter> DarkModeFilter::GenerateImageFilter(
const SkPixmap& pixmap,
const SkIRect& src) const { … }
sk_sp<cc::ColorFilter> DarkModeFilter::GetImageFilter() const { … }
std::optional<cc::PaintFlags> DarkModeFilter::ApplyToFlagsIfNeeded(
const cc::PaintFlags& flags,
ElementRole role,
SkColor4f contrast_background) { … }
bool DarkModeFilter::ShouldApplyToColor(const SkColor4f& color,
ElementRole role) { … }
size_t DarkModeFilter::GetInvertedColorCacheSizeForTesting() { … }
}