#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/viz/common/viz_utils.h"
#include <algorithm>
#include <vector>
#include "base/command_line.h"
#include "base/system/sys_info.h"
#include "build/build_config.h"
#include "cc/base/math_util.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rrect_f.h"
#if BUILDFLAG(IS_ANDROID)
#include <array>
#include <string>
#include "base/android/build_info.h"
#endif
#if BUILDFLAG(IS_POSIX)
#include <poll.h>
#include <sys/resource.h>
#endif
namespace viz {
#if BUILDFLAG(IS_ANDROID)
bool PreferRGB565ResourcesForDisplay() {
return base::SysInfo::AmountOfPhysicalMemoryMB() <= 512;
}
#endif
#if BUILDFLAG(IS_ANDROID)
bool AlwaysUseWideColorGamut() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
static const char kDisableWCGForTest[] = "disable-wcg-for-test";
if (command_line.HasSwitch(kDisableWCGForTest))
return false;
static bool is_always_use_wide_color_gamut_enabled = [] {
const char* current_model =
base::android::BuildInfo::GetInstance()->model();
const std::array<std::string, 2> enabled_models = {
std::string{"Pixel 4"}, std::string{"Pixel 4 XL"}};
for (const std::string& model : enabled_models) {
if (model == current_model)
return true;
}
return false;
}();
return is_always_use_wide_color_gamut_enabled;
}
#endif
bool GetScaledRegion(const gfx::Rect& rect,
const gfx::QuadF* clip,
gfx::QuadF* scaled_region) { … }
bool GetScaledRRectF(const gfx::Rect& space,
const gfx::RRectF& rect,
gfx::RRectF* scaled_rect) { … }
bool GetScaledUVs(const gfx::Rect& rect, const gfx::QuadF* clip, float uvs[8]) { … }
bool GatherFDStats(base::TimeDelta* delta_time_taken,
int* fd_max,
int* active_fd_count,
int* rlim_cur) { … }
gfx::RectF ClippedQuadRectangleF(const DrawQuad* quad) { … }
gfx::Rect ClippedQuadRectangle(const DrawQuad* quad) { … }
gfx::Rect GetExpandedRectWithPixelMovingForegroundFilter(
const DrawQuad& rpdq,
const cc::FilterOperations& filters) { … }
gfx::Transform GetViewTransitionTransform(
gfx::Rect shared_element_quad,
gfx::Rect view_transition_content_output) { … }
bool QuadRoundedCornersBoundsIntersects(const DrawQuad* quad,
const gfx::RectF& target_quad) { … }
void SetCopyOutoutRequestResultSize(CopyOutputRequest* request,
const gfx::Rect& src_rect,
const gfx::Size& output_size,
const gfx::Size& surface_size_in_pixels) { … }
}