File: overlay_processor_delegated.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (109 lines) | stat: -rw-r--r-- 5,103 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_OVERLAY_PROCESSOR_DELEGATED_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_OVERLAY_PROCESSOR_DELEGATED_H_

#include <memory>
#include <vector>

#include "components/viz/common/display/overlay_strategy.h"
#include "components/viz/common/quads/aggregated_render_pass.h"
#include "components/viz/service/display/output_surface.h"
#include "components/viz/service/display/overlay_candidate.h"
#include "components/viz/service/display/overlay_processor_delegated_support.h"
#include "components/viz/service/display/overlay_processor_ozone.h"
#include "components/viz/service/viz_service_export.h"

#include "ui/ozone/public/overlay_candidates_ozone.h"

namespace viz {

// OverlayProcessor subclass that attempts to promote to overlay all the draw
// quads of the root render pass. This was only used by LaCros.
// TODO(petermcneeley): This class and its Apple equivalent(s) will eventually
// be refactored in merged together into a unified delegation processor.
// Delegation will just become an extended feature of ozone and we avoid/push
// down platform specific defines and files where possible.
//
// TODO(crbug.com/375523817): consider either merging that with
// OverlayProcessorOzone or completely remove it.
class VIZ_SERVICE_EXPORT OverlayProcessorDelegated
    : public OverlayProcessorOzone {
 public:
  OverlayProcessorDelegated(
      std::unique_ptr<ui::OverlayCandidatesOzone> overlay_candidates,
      std::vector<OverlayStrategy> available_strategies,
      std::unique_ptr<PixmapProvider> pixmap_provider);
  OverlayProcessorDelegated(const OverlayProcessorDelegated&) = delete;
  OverlayProcessorDelegated& operator=(const OverlayProcessorDelegated&) =
      delete;
  ~OverlayProcessorDelegated() override;

  bool DisableSplittingQuads() const override;

  void ProcessForOverlays(
      DisplayResourceProvider* resource_provider,
      AggregatedRenderPassList* render_passes,
      const SkM44& output_color_matrix,
      const FilterOperationsMap& render_pass_filters,
      const FilterOperationsMap& render_pass_backdrop_filters,
      SurfaceDamageRectList surface_damage_rect_list,
      OutputSurfaceOverlayPlane* output_surface_plane,
      CandidateList* overlay_candidates,
      gfx::Rect* damage_rect,
      std::vector<gfx::Rect>* content_bounds) final;

  // This function takes a pointer to the std::optional instance so the
  // instance can be reset. When the overlay strategy covers the entire output
  // surface, we no longer need the output surface as a separate overlay. This
  // is also used by SurfaceControl to adjust rotation.
  // TODO(weiliangc): Internalize the |output_surface_plane| inside the overlay
  // processor.
  void AdjustOutputSurfaceOverlay(
      std::optional<OutputSurfaceOverlayPlane>* output_surface_plane) override;

  gfx::RectF GetUnassignedDamage() const override;

 private:
  gfx::RectF GetPrimaryPlaneDisplayRect(
      const OverlayProcessorInterface::OutputSurfaceOverlayPlane*
          primary_plane);
  // Iterate through a list of strategies and attempt to overlay with each.
  // Returns true if one of the attempts is successful. Has to be called after
  // InitializeStrategies(). A |primary_plane| represents the output surface's
  // buffer that comes from |BufferQueue|. It is passed in here so it could be
  // pass through to hardware through CheckOverlaySupport. It is not passed
  // through as a const member because the underlay strategy changes the
  // |primary_plane|'s blending setting.
  bool AttemptWithStrategies(
      const SkM44& output_color_matrix,
      const OverlayProcessorInterface::FilterOperationsMap& render_pass_filters,
      const OverlayProcessorInterface::FilterOperationsMap&
          render_pass_backdrop_filters,
      const DisplayResourceProvider* resource_provider,
      AggregatedRenderPassList* render_pass_list,
      SurfaceDamageRectList* surface_damage_rect_list,
      OverlayProcessorInterface::OutputSurfaceOverlayPlane* primary_plane,
      OverlayCandidateList* candidates,
      std::vector<gfx::Rect>* content_bounds);

  // Should delegation be blocked because we have recently had copy output
  // requests on any render passes. The root render pass must not be delegated
  // if there is a copy request in order to draw correctly. For non-root passes,
  // this is done to prevent execessive power usage that can occur if copy
  // output requests happen approximately every other frame, causing a lot of
  // delegation overhead.
  bool BlockForCopyRequests(const AggregatedRenderPassList* render_pass_list);

  DelegationStatus delegated_status_ = DelegationStatus::kCompositedOther;
  bool needs_background_image_ = false;
  gfx::RectF unassigned_damage_;
  // Used to count the number of frames we should wait until allowing delegation
  // again.
  int copy_request_counter_ = 0;
};
}  // namespace viz

#endif  // COMPONENTS_VIZ_SERVICE_DISPLAY_OVERLAY_PROCESSOR_DELEGATED_H_