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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// These Mojo structs are converted from
// third_party/lens_server_proto/lens_overlay_text.proto and
// third_party/lens_server_proto/lens_overlay_deep_gleam_data.proto.
module lens.mojom;
import "chrome/browser/lens/core/mojom/geometry.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "mojo/public/mojom/base/big_buffer.mojom";
import "skia/public/mojom/skcolor.mojom";
// The text reading order.
enum WritingDirection {
kLeftToRight = 0,
kRightToLeft = 1,
kTopToBottom = 2,
};
// The text alignment.
enum Alignment {
kDefaultLeftAlgined = 0,
kRightAligned = 1,
kCenterAligned = 2,
};
struct Text {
// Information regarding the layout and position of text.
TextLayout? text_layout;
// Dominant content language of the text. Language code is CLDR/BCP-47.
string? content_language;
};
// Nested text structure.
struct TextLayout {
// The actual detected text on the page in an array of paragraphs and the
// translated text if provided.
array<Paragraph> paragraphs;
};
struct Word {
// Required. The text in a plain text, which can be an empty string.
string plain_text;
// Optional. The text separator that should be appended after this word when
// it is concatenated with the subsequent word in the same or next
// line/paragraph into a single-line string.
string? text_separator;
// Optional. The geometry of the word.
Geometry? geometry;
// Optional. The text writing direction (aka reading order). All words in a
// paragraph must have the same writing direction.
WritingDirection? writing_direction;
// Optional. Metadata for formulas. This is populated for entities of
// `type=FORMULA`.
FormulaMetadata? formula_metadata;
};
struct Line {
// Optional. List of words in natural reading order.
array<Word> words;
// Optional. The geometry of the line.
Geometry? geometry;
};
struct BackgroundImageData {
// Image bytes to inpaint the source text.
mojo_base.mojom.BigBuffer background_image;
// Size of background_image in pixels.
gfx.mojom.Size image_size;
// Vertical padding to apply to the text box before drawing the background
// image. Expressed as a fraction of the text box height, i.e. 1.0 means
// that the height should be doubled. Half of the padding should be added on
// the top and half on the bottom.
float vertical_padding;
// Horizontal padding to apply to the text box before drawing the background
// image. Expressed as a fraction of the text box height. Half of the
// padding should be added on the left and half on the right.
float horizontal_padding;
// Text mask for the generated background image.
mojo_base.mojom.BigBuffer text_mask;
};
struct TranslatedLine {
// Optional. List of words in natural reading order.
array<Word> words;
// Full translation of the line.
string translation;
// Required. The color of the text to render.
skia.mojom.SkColor text_color;
// Required. The color of the background used to mask the actual text.
skia.mojom.SkColor background_primary_color;
// Optional. The background image data used to mask the text underneath the
// line.
BackgroundImageData? background_image_data;
// Optional. The geometry of the line.
Geometry? geometry;
};
// This struct is used to transport a response from a trusted server to be
// displayed/consumed in WebUI. Specifically, any detected text that was
// requested to be translated in the server request.
struct TranslatedParagraph {
// Optional. List of lines in natural reading order (see also
// `writing_direction`). The amount of translated lines should be equal to the
// amount of lines returned in the detected text. See comment in `Paragraph`
// struct.
array<TranslatedLine> lines;
// Size of the resized screenshot in pixels.
gfx.mojom.Size resized_bitmap_size;
// Optional. The alignment of the text in the paragraph.
Alignment? alignment;
// Optional. The text writing direction (aka reading order).
WritingDirection? writing_direction;
// Optional. BCP-47 language code of the dominant language in this
// paragraph.
string? content_language;
};
// This struct is used to transport a response from a trusted server to be
// displayed/consumed in WebUI. Specifically, any detected text that was found
// on the full page screenshot sent in the original server request.
struct Paragraph {
// Optional. List of lines in natural reading order (see also
// `writing_direction`).
array<Line> lines;
// Optional. A paragraph struct corresponding to this one containing the
// translated text if provided. When present, the number of elements in
// translation.lines must match the number of elements in lines. This is
// normally discouraged in Mojo, but there isn't a good way to
// represent/enforce this sort of invariant purely through struct definitions.
// This is considered acceptable here, since this data only flows from a
// trusted source to an untrusted sink.
TranslatedParagraph? translation;
// Optional. Geometry of the paragraph.
Geometry? geometry;
// Optional. The text writing direction (aka reading order).
WritingDirection? writing_direction;
// Optional. BCP-47 language code of the dominant language in this
// paragraph.
string? content_language;
};
struct FormulaMetadata {
// Optional. LaTeX representation of a formula. Can be the same as
// `plain_text`. Example: "\frac{2}{x}=y".
string? latex;
};
|