#include "components/viz/service/surfaces/surface.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <limits>
#include <tuple>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/ranges/algorithm.h"
#include "base/time/tick_clock.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
#include "components/viz/common/features.h"
#include "components/viz/common/quads/compositor_render_pass.h"
#include "components/viz/common/resources/returned_resource.h"
#include "components/viz/common/resources/transferable_resource.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "components/viz/service/surfaces/referenced_surface_tracker.h"
#include "components/viz/service/surfaces/surface_allocation_group.h"
#include "components/viz/service/surfaces/surface_client.h"
#include "components/viz/service/surfaces/surface_manager.h"
#include "components/viz/service/viz_service_export.h"
#include "ui/gfx/presentation_feedback.h"
#include "ui/gfx/swap_result.h"
namespace viz {
namespace {
void RequestCopyOfOutputOnRenderPass(std::unique_ptr<CopyOutputRequest> request,
CompositorRenderPass& render_pass) { … }
bool ShouldBlockActivationOnDependenciesWhenInteractive() { … }
}
Surface::PresentationHelper::PresentationHelper(
base::WeakPtr<SurfaceClient> surface_client,
uint32_t frame_token)
: … { … }
Surface::PresentationHelper::~PresentationHelper() { … }
void Surface::PresentationHelper::DidPresent(
base::TimeTicks draw_start_timestamp,
const gfx::SwapTimings& swap_timings,
const gfx::PresentationFeedback& feedback) { … }
Surface::Surface(const SurfaceInfo& surface_info,
SurfaceManager* surface_manager,
SurfaceAllocationGroup* allocation_group,
base::WeakPtr<SurfaceClient> surface_client,
const SurfaceId& pending_copy_surface_id,
size_t max_uncommitted_frames)
: … { … }
Surface::~Surface() { … }
void Surface::SetDependencyDeadline(
std::unique_ptr<SurfaceDependencyDeadline> deadline) { … }
void Surface::SetPreviousFrameSurface(Surface* surface) { … }
void Surface::UpdateSurfaceReferences() { … }
void Surface::OnChildActivatedForActiveFrame(const SurfaceId& activated_id) { … }
void Surface::SetIsFallbackAndMaybeActivate() { … }
void Surface::ActivateIfDeadlinePassed() { … }
Surface::QueueFrameResult Surface::QueueFrame(
CompositorFrame frame,
uint64_t frame_index,
base::ScopedClosureRunner frame_rejected_callback) { … }
Surface::QueueFrameResult Surface::CommitFrame(FrameData frame) { … }
void Surface::RequestCopyOfOutput(
PendingCopyOutputRequest pending_copy_output_request) { … }
void Surface::RequestCopyOfOutputOnRootRenderPass(
std::unique_ptr<CopyOutputRequest> copy_request) { … }
bool Surface::RequestCopyOfOutputOnActiveFrameRenderPassId(
std::unique_ptr<CopyOutputRequest> copy_request,
CompositorRenderPassId render_pass_id) { … }
void Surface::OnActivationDependencyResolved(
const SurfaceId& activation_dependency,
SurfaceAllocationGroup* group) { … }
void Surface::ActivatePendingFrameForDeadline() { … }
Surface::FrameData::FrameData(CompositorFrame&& frame, uint64_t frame_index)
: … { … }
Surface::FrameData::FrameData(FrameData&& other) = default;
Surface::FrameData& Surface::FrameData::operator=(FrameData&& other) = default;
Surface::FrameData::~FrameData() = default;
void Surface::FrameData::SendAckIfNeeded(SurfaceClient* client) { … }
void Surface::ActivatePendingFrame() { … }
void Surface::CommitFramesRecursively(const CommitPredicate& predicate) { … }
std::optional<uint64_t> Surface::GetFirstUncommitedFrameIndex() { … }
std::optional<uint64_t> Surface::GetUncommitedFrameIndexNewerThan(
uint64_t frame_index) { … }
void Surface::ResetPendingCopySurfaceId() { … }
void Surface::UpdateReferencedAllocationGroups(
std::vector<SurfaceAllocationGroup*> new_referenced_allocation_groups) { … }
void Surface::RecomputeActiveReferencedSurfaces() { … }
void Surface::ActivateFrame(FrameData frame_data) { … }
FrameDeadline Surface::ResolveFrameDeadline(
const CompositorFrame& current_frame) { … }
void Surface::UpdateActivationDependencies(
const CompositorFrame& current_frame) { … }
void Surface::TakeCopyOutputRequests(Surface::CopyRequestsMap* copy_requests) { … }
void Surface::TakeCopyOutputRequestsFromClient() { … }
bool Surface::HasCopyOutputRequests() const { … }
const CompositorFrame& Surface::GetActiveFrame() const { … }
const CompositorFrameMetadata& Surface::GetActiveFrameMetadata() const { … }
const FrameIntervalInputs& Surface::GetFrameIntervalInputs() const { … }
void Surface::SetActiveFrameForViewTransition(CompositorFrame frame) { … }
const CompositorFrame& Surface::GetPendingFrame() { … }
void Surface::TakeActiveLatencyInfo(
std::vector<ui::LatencyInfo>* latency_info) { … }
void Surface::TakeActiveAndPendingLatencyInfo(
std::vector<ui::LatencyInfo>* latency_info) { … }
std::unique_ptr<Surface::PresentationHelper>
Surface::TakePresentationHelperForPresentNotification() { … }
void Surface::SendAckToClient() { … }
void Surface::MarkAsDrawn() { … }
void Surface::NotifyAggregatedDamage(const gfx::Rect& damage_rect,
base::TimeTicks expected_display_time) { … }
bool Surface::IsVideoCaptureOnFromClient() { … }
base::flat_set<base::PlatformThreadId> Surface::GetThreadIds() { … }
void Surface::UnrefFrameResourcesAndRunCallbacks(
std::optional<FrameData> frame_data) { … }
void Surface::ClearCopyRequests() { … }
void Surface::TakePendingLatencyInfo(
std::vector<ui::LatencyInfo>* latency_info) { … }
void Surface::TakeLatencyInfoFromFrame(
CompositorFrame* frame,
std::vector<ui::LatencyInfo>* latency_info) { … }
void Surface::OnWillBeDrawn() { … }
void Surface::ActivatePendingFrameForInheritedDeadline() { … }
std::unique_ptr<gfx::DelegatedInkMetadata> Surface::TakeDelegatedInkMetadata() { … }
}