#include "components/viz/service/display/overlay_candidate_factory.h"
#include "base/containers/contains.h"
#include "build/build_config.h"
#include "cc/base/math_util.h"
#include "components/viz/common/quads/aggregated_render_pass_draw_quad.h"
#include "components/viz/common/quads/draw_quad.h"
#include "components/viz/common/quads/shared_quad_state.h"
#include "components/viz/common/quads/solid_color_draw_quad.h"
#include "components/viz/common/quads/texture_draw_quad.h"
#include "components/viz/common/quads/tile_draw_quad.h"
#include "components/viz/common/quads/video_hole_draw_quad.h"
#include "components/viz/common/quads/yuv_video_draw_quad.h"
#include "components/viz/common/resources/resource_id.h"
#include "components/viz/common/viz_utils.h"
#include "components/viz/service/debugger/viz_debugger.h"
#include "components/viz/service/display/display_resource_provider.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/overlay_transform_utils.h"
#include "ui/gfx/video_types.h"
namespace viz {
namespace {
const SharedImageFormat kOverlayFormats[] = …;
enum Axis { … };
Axis VectorToAxis(const gfx::Vector3dF& vec) { … }
gfx::OverlayTransform GetOverlayTransform(const gfx::Transform& quad_transform,
bool y_flipped,
bool supports_flip_rotate_transform) { … }
constexpr double kEpsilon = …;
OverlayCandidate::CandidateStatus GetReasonForTransformNotAxisAligned(
const gfx::Transform& transform) { … }
bool ShouldApplyRoundedCorner(OverlayCandidate& candidate,
const DrawQuad* quad) { … }
bool RequiresBlendingForReasonOtherThanRoundedCorners(const DrawQuad* quad) { … }
}
OverlayCandidateFactory::OverlayContext::OverlayContext() = default;
OverlayCandidateFactory::OverlayContext::OverlayContext(const OverlayContext&) =
default;
OverlayCandidate::CandidateStatus OverlayCandidateFactory::FromDrawQuad(
const DrawQuad* quad,
OverlayCandidate& candidate) const { … }
OverlayCandidateFactory::OverlayCandidateFactory(
const AggregatedRenderPass* render_pass,
const DisplayResourceProvider* resource_provider,
const SurfaceDamageRectList* surface_damage_rect_list,
const SkM44* output_color_matrix,
const gfx::RectF primary_rect,
const OverlayProcessorInterface::FilterOperationsMap* render_pass_filters,
const OverlayContext& context)
: … { … }
OverlayCandidateFactory::~OverlayCandidateFactory() = default;
float OverlayCandidateFactory::EstimateVisibleDamage(
const DrawQuad* quad,
const OverlayCandidate& candidate,
QuadList::ConstIterator quad_list_begin,
QuadList::ConstIterator quad_list_end) const { … }
bool OverlayCandidateFactory::IsOccludedByFilteredQuad(
const OverlayCandidate& candidate,
QuadList::ConstIterator quad_list_begin,
QuadList::ConstIterator quad_list_end,
const base::flat_map<AggregatedRenderPassId, cc::FilterOperations*>&
render_pass_backdrop_filters) const { … }
bool OverlayCandidateFactory::IsOccluded(
const OverlayCandidate& candidate,
QuadList::ConstIterator quad_list_begin,
QuadList::ConstIterator quad_list_end) const { … }
OverlayCandidate::CandidateStatus OverlayCandidateFactory::FromDrawQuadResource(
const DrawQuad* quad,
ResourceId resource_id,
bool y_flipped,
OverlayCandidate& candidate) const { … }
void OverlayCandidateFactory::SetDisplayRect(
const DrawQuad& quad,
OverlayCandidate& candidate) const { … }
OverlayCandidate::CandidateStatus OverlayCandidateFactory::DoGeometricClipping(
const DrawQuad* quad,
OverlayCandidate& candidate) const { … }
OverlayCandidate::CandidateStatus OverlayCandidateFactory::ApplyTransform(
const gfx::Transform& quad_to_target_transform,
const bool y_flipped,
OverlayCandidate& candidate) const { … }
OverlayCandidate::CandidateStatus OverlayCandidateFactory::FromAggregateQuad(
const AggregatedRenderPassDrawQuad* quad,
OverlayCandidate& candidate) const { … }
OverlayCandidate::CandidateStatus OverlayCandidateFactory::FromSolidColorQuad(
const SolidColorDrawQuad* quad,
OverlayCandidate& candidate) const { … }
OverlayCandidate::CandidateStatus OverlayCandidateFactory::FromVideoHoleQuad(
const VideoHoleDrawQuad* quad,
OverlayCandidate& candidate) const { … }
OverlayCandidate::CandidateStatus OverlayCandidateFactory::FromTileQuad(
const TileDrawQuad* quad,
OverlayCandidate& candidate) const { … }
OverlayCandidate::CandidateStatus OverlayCandidateFactory::FromTextureQuad(
const TextureDrawQuad* quad,
OverlayCandidate& candidate) const { … }
void OverlayCandidateFactory::HandleClipAndSubsampling(
OverlayCandidate& candidate) const { … }
void OverlayCandidateFactory::AssignDamage(const DrawQuad* quad,
OverlayCandidate& candidate) const { … }
gfx::RectF OverlayCandidateFactory::GetDamageEstimate(
const OverlayCandidate& candidate) const { … }
gfx::RectF OverlayCandidateFactory::GetDamageRect(const DrawQuad* quad) const { … }
}