#include "ui/gfx/color_conversion_sk_filter_cache.h"
#include <string>
#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GpuTypes.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
#include "third_party/skia/include/gpu/graphite/Recorder.h"
#include "third_party/skia/include/gpu/graphite/Surface.h"
#include "third_party/skia/include/private/SkGainmapInfo.h"
#include "third_party/skia/include/private/SkGainmapShader.h"
#include "ui/gfx/color_transform.h"
namespace gfx {
namespace {
static sk_sp<SkSurface> MakeSurfaceForResult(
SkImageInfo image_info,
GrDirectContext* gr_context,
skgpu::graphite::Recorder* graphite_recorder) { … }
}
ColorConversionSkFilterCache::ColorConversionSkFilterCache() = default;
ColorConversionSkFilterCache::~ColorConversionSkFilterCache() = default;
bool ColorConversionSkFilterCache::Key::Key::operator==(
const Key& other) const { … }
bool ColorConversionSkFilterCache::Key::operator!=(const Key& other) const { … }
bool ColorConversionSkFilterCache::Key::operator<(const Key& other) const { … }
ColorConversionSkFilterCache::Key::Key(const gfx::ColorSpace& src,
uint32_t src_bit_depth,
const gfx::ColorSpace& dst,
float dst_sdr_max_luminance_nits)
: … { … }
ColorConversionSkFilterCache::Value::Value() = default;
ColorConversionSkFilterCache::Value::Value(Value&& other)
: … { … }
ColorConversionSkFilterCache::Value&
ColorConversionSkFilterCache::Value::operator=(Value&& other) { … }
ColorConversionSkFilterCache::Value::~Value() = default;
sk_sp<SkColorFilter> ColorConversionSkFilterCache::Get(
const gfx::ColorSpace& src,
const gfx::ColorSpace& dst,
std::optional<uint32_t> src_bit_depth,
std::optional<gfx::HDRMetadata> src_hdr_metadata,
float dst_sdr_max_luminance_nits,
float dst_max_luminance_relative) { … }
sk_sp<SkImage> ColorConversionSkFilterCache::ApplyGainmap(
sk_sp<SkImage> base_image,
sk_sp<SkImage> gainmap_image,
const SkGainmapInfo& gainmap_info,
float dst_max_luminance_relative,
GrDirectContext* gr_context,
skgpu::graphite::Recorder* graphite_recorder) { … }
bool ColorConversionSkFilterCache::UseToneCurve(sk_sp<SkImage> image) { … }
sk_sp<SkImage> ColorConversionSkFilterCache::ApplyToneCurve(
sk_sp<SkImage> image,
std::optional<HDRMetadata> src_hdr_metadata,
float dst_sdr_max_luminance_nits,
float dst_max_luminance_relative,
GrDirectContext* gr_context,
skgpu::graphite::Recorder* graphite_recorder) { … }
}