File: fast_ink_host_frame_utils.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 (91 lines) | stat: -rw-r--r-- 3,060 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
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_FAST_INK_FAST_INK_HOST_FRAME_UTILS_H_
#define ASH_FAST_INK_FAST_INK_HOST_FRAME_UTILS_H_

#include <memory>
#include <vector>

#include "ash/ash_export.h"
#include "ash/frame_sink/ui_resource.h"
#include "base/memory/raw_ptr.h"
#include "components/viz/common/quads/compositor_frame.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "ui/gfx/geometry/rect.h"

namespace viz {
class CompositorFrame;
}  // namespace viz

namespace gfx {
class Size;
}  // namespace gfx

namespace gpu {
class ClientSharedImage;
}

namespace aura {
class Window;
}  // namespace aura

namespace ash {
class UiResourceManager;

namespace fast_ink_internal {

inline constexpr viz::SharedImageFormat kFastInkSharedImageFormat =
    SK_B32_SHIFT ? viz::SinglePlaneFormat::kRGBA_8888
                 : viz::SinglePlaneFormat::kBGRA_8888;
inline constexpr UiSourceId kFastInkUiSourceId = 1u;

// Converts the rect in window's coordinate to the buffer's coordinate.  If the
// window is rotated, the window_rect will also be rotated, for example. The
// size is clamped by `buffer_size` to ensure it does not exceeds the buffer
// size.
ASH_EXPORT gfx::Rect BufferRectFromWindowRect(
    const gfx::Transform& window_to_buffer_transform,
    const gfx::Size& buffer_size,
    const gfx::Rect& window_rect);

// Creates a Mappable SharedImage of given `size`, `shared_image_usage`, and
// `buffer_usage`. The returned ClientSharedImage will be null if creation
// failed.
ASH_EXPORT scoped_refptr<gpu::ClientSharedImage> CreateMappableSharedImage(
    const gfx::Size& size,
    gpu::SharedImageUsageSet shared_image_usage,
    gfx::BufferUsage buffer_usage);

// Creates a UiResource of a given `size` and `format` using the SharedImage
// that `mailbox` (which must be non-zero) is referencing. The created
// UiResource does not own that SharedImage.
ASH_EXPORT std::unique_ptr<UiResource> CreateUiResource(
    const gfx::Size& size,
    UiSourceId ui_source_id,
    bool is_overlay_candidate,
    gpu::Mailbox mailbox,
    gpu::SyncToken sync_token);

// Creates and configures a compositor frame. Uses the SharedImage that
// `shared_image` (which must be non-null) is referencing. The created
// UiResource does not own that SharedImage.
ASH_EXPORT std::unique_ptr<viz::CompositorFrame> CreateCompositorFrame(
    const viz::BeginFrameAck& begin_frame_ack,
    const gfx::Rect& content_rect,
    const gfx::Rect& total_damage_rect,
    bool auto_update,
    const aura::Window& host_window,
    const gfx::Size& buffer_size,
    UiResourceManager* resource_manager,
    const scoped_refptr<gpu::ClientSharedImage>& shared_image,
    gpu::SyncToken sync_token);

// Returns the RasterContextProvider used within FastInk.
ASH_EXPORT scoped_refptr<viz::RasterContextProvider> GetContextProvider();

}  // namespace fast_ink_internal
}  // namespace ash

#endif  // ASH_FAST_INK_FAST_INK_HOST_FRAME_UTILS_H_