File: drm_window.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (133 lines) | stat: -rw-r--r-- 4,113 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_WINDOW_H_
#define UI_OZONE_PLATFORM_DRM_GPU_DRM_WINDOW_H_

#include <memory>
#include <vector>

#include "base/memory/raw_ptr.h"
#include "base/timer/timer.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/swap_result.h"
#include "ui/gfx/vsync_provider.h"
#include "ui/ozone/platform/drm/gpu/drm_overlay_plane.h"
#include "ui/ozone/platform/drm/gpu/page_flip_request.h"
#include "ui/ozone/public/overlay_surface_candidate.h"
#include "ui/ozone/public/swap_completion_callback.h"

class SkBitmap;

namespace base {
class TimeDelta;
}  // namespace base

namespace gfx {
class Point;
class Rect;
}  // namespace gfx

namespace ui {

class DrmDeviceManager;
class DrmOverlayValidator;
class HardwareDisplayController;
class ScreenManager;

// The GPU object representing a window.
//
// The main purpose of this object is to associate drawing surfaces with
// displays. A surface created with the same id as the window (from
// GetAcceleratedWidget()) will paint onto that window. A window with
// the same bounds as a display will paint onto that display.
//
// If there's no display whose bounds match the window's, the window is
// disconnected and its contents will not be visible to the user.
class DrmWindow {
 public:
  DrmWindow(gfx::AcceleratedWidget widget,
            DrmDeviceManager* device_manager,
            ScreenManager* screen_manager);

  DrmWindow(const DrmWindow&) = delete;
  DrmWindow& operator=(const DrmWindow&) = delete;

  ~DrmWindow();

  gfx::Rect bounds() const { return bounds_; }

  void Initialize();

  void Shutdown();

  // Returns the accelerated widget associated with the window.
  gfx::AcceleratedWidget GetAcceleratedWidget() const;

  // Returns the current controller the window is displaying on. Callers should
  // not cache the result as the controller may change as the window is moved.
  HardwareDisplayController* GetController() const;

  void SetController(HardwareDisplayController* controller);

  // Called when the window is resized/moved.
  void SetBounds(const gfx::Rect& bounds);

  // Update the HW cursor bitmap & move to the location if specified.
  // If the bitmap is empty, the cursor is hidden.
  void SetCursor(const std::vector<SkBitmap>& bitmaps,
                 const std::optional<gfx::Point>& location,
                 base::TimeDelta frame_delay);

  // Move the HW cursor to the specified location.
  void MoveCursor(const gfx::Point& location);

  void SchedulePageFlip(std::vector<DrmOverlayPlane> planes,
                        SwapCompletionOnceCallback submission_callback,
                        PresentationOnceCallback presentation_callback);
  OverlayStatusList TestPageFlip(
      const OverlaySurfaceCandidateList& overlay_params);

  const DrmOverlayPlaneList& last_submitted_planes() const {
    return last_submitted_planes_;
  }

 private:
  // Draw next frame in an animated cursor.
  void OnCursorAnimationTimeout();

  void UpdateCursorImage();
  void UpdateCursorLocation();

  // Draw the last set cursor & update the cursor plane.
  void ResetCursor();

  const gfx::AcceleratedWidget widget_;

  const raw_ptr<DrmDeviceManager> device_manager_;  // Not owned.
  const raw_ptr<ScreenManager> screen_manager_;     // Not owned.

  // The current bounds of the window.
  gfx::Rect bounds_;

  // The controller associated with the current window. This may be nullptr if
  // the window isn't over an active display.
  raw_ptr<HardwareDisplayController, DanglingUntriaged> controller_ = nullptr;
  std::unique_ptr<DrmOverlayValidator> overlay_validator_;

  base::RepeatingTimer cursor_timer_;
  std::vector<SkBitmap> cursor_bitmaps_;
  gfx::Point cursor_location_;
  int cursor_frame_ = 0;

  DrmOverlayPlaneList last_submitted_planes_;

  bool force_buffer_reallocation_ = false;
};

}  // namespace ui

#endif  // UI_OZONE_PLATFORM_DRM_GPU_DRM_WINDOW_H_