summaryrefslogtreecommitdiffstats
path: root/components/mus/public/interfaces/quads.mojom
blob: 1b0ada83e679acf3ffa5756f6d10b3829d8b1c92 (plain)
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module mus.mojom;

import "components/mus/public/interfaces/surface_id.mojom";
import "ui/mojo/geometry/geometry.mojom";

struct Color {
  uint32 rgba;
};

struct CheckerboardQuadState {
  // Checkerboard color.
  Color color;

  // The scale factor of checkers. Chromium uses device scale factor for
  // it.
  float scale;
};

struct DebugBorderQuadState {
  // Debug border color.
  Color color;

  // Debug border width.
  int32 width;
};

// TODO(jamesr): Populate subtype fields.
struct IoSurfaceContentQuadState {};

struct RenderPassId {
  int32 layer_id;
  uint32 index;
};

struct RenderPassQuadState {
  RenderPassId render_pass_id;

  // If nonzero, resource id of mask to use when drawing this pass.
  uint32 mask_resource_id;
  mojo.PointF mask_uv_scale;
  mojo.Size mask_texture_size;

  // Post-processing filters, applied to the pixels in the render pass' texture.
  // TODO(jamesr): Support
  // FilterOperations filters;

  // The scale from layer space of the root layer of the render pass to
  // the render pass physical pixels. This scale is applied to the filter
  // parameters for pixel-moving filters. This scale should include
  // content-to-target-space scale, and device pixel ratio.
  mojo.PointF filters_scale;

  // Post-processing filters, applied to the pixels showing through the
  // background of the render pass, from behind it.
  // TODO(jamesr): Support
  // FilterOperations background_filters;
};

struct SolidColorQuadState {
  Color color;
  bool force_anti_aliasing_off;
};

struct SurfaceQuadState {
  mus.mojom.SurfaceId surface;
};

struct TextureQuadState {
  uint32 resource_id;
  bool premultiplied_alpha;
  mojo.PointF uv_top_left;
  mojo.PointF uv_bottom_right;
  Color background_color;
  array<float, 4> vertex_opacity;
  bool y_flipped;
  bool nearest_neighbor;
};

struct TileQuadState {
  mojo.RectF tex_coord_rect;
  mojo.Size texture_size;
  bool swizzle_contents;
  uint32 resource_id;
  bool nearest_neighbor;
};

struct StreamVideoQuadState {};

enum YUVColorSpace {
  REC_601,       // SDTV standard with restricted "studio swing" color range.
  REC_709,       // HDTV standard with restricted "studio swing" color range.
  JPEG,          // Full color range [0, 255] JPEG color space.
};

struct YUVVideoQuadState {
  mojo.RectF ya_tex_coord_rect;
  mojo.RectF uv_tex_coord_rect;
  mojo.Size ya_tex_size;
  mojo.Size uv_tex_size;
  uint32 y_plane_resource_id;
  uint32 u_plane_resource_id;
  uint32 v_plane_resource_id;
  uint32 a_plane_resource_id;
  YUVColorSpace color_space;
  float resource_offset;
  float resource_multiplier;
};

enum Material {
  DEBUG_BORDER = 1,
  IO_SURFACE_CONTENT,
  PICTURE_CONTENT,
  RENDER_PASS,
  SOLID_COLOR,
  STREAM_VIDEO_CONTENT,
  SURFACE_CONTENT,
  TEXTURE_CONTENT,
  TILED_CONTENT,
  YUV_VIDEO_CONTENT,
};

struct Quad {
  Material material;

  // This rect, after applying the quad_transform(), gives the geometry that
  // this quad should draw to. This rect lives in content space.
  mojo.Rect rect;

  // This specifies the region of the quad that is opaque. This rect lives in
  // content space.
  mojo.Rect opaque_rect;

  // Allows changing the rect that gets drawn to make it smaller. This value
  // should be clipped to |rect|. This rect lives in content space.
  mojo.Rect visible_rect;

  // Allows changing the rect that gets drawn to make it smaller. This value
  // should be clipped to |rect|. This rect lives in content space.
  bool needs_blending;

  // Index into the containing pass' shared quad state array which has state
  // (transforms etc) shared by multiple quads.
  uint32 shared_quad_state_index;

  // Only one of the following will be set, depending on the material.
  CheckerboardQuadState? checkerboard_quad_state;
  DebugBorderQuadState? debug_border_quad_state;
  IoSurfaceContentQuadState? io_surface_quad_state;
  RenderPassQuadState? render_pass_quad_state;
  SolidColorQuadState? solid_color_quad_state;
  SurfaceQuadState? surface_quad_state;
  TextureQuadState? texture_quad_state;
  TileQuadState? tile_quad_state;
  StreamVideoQuadState? stream_video_quad_state;
  YUVVideoQuadState? yuv_video_quad_state;
};

enum SkXfermode {
  kClear_Mode = 0,    //!< [0, 0]
  kSrc_Mode,      //!< [Sa, Sc]
  kDst_Mode,      //!< [Da, Dc]
  kSrcOver_Mode,  //!< [Sa + Da - Sa*Da, Rc = Sc + (1 - Sa)*Dc]
  kDstOver_Mode,  //!< [Sa + Da - Sa*Da, Rc = Dc + (1 - Da)*Sc]
  kSrcIn_Mode,    //!< [Sa * Da, Sc * Da]
  kDstIn_Mode,    //!< [Sa * Da, Sa * Dc]
  kSrcOut_Mode,   //!< [Sa * (1 - Da), Sc * (1 - Da)]
  kDstOut_Mode,   //!< [Da * (1 - Sa), Dc * (1 - Sa)]
  kSrcATop_Mode,  //!< [Da, Sc * Da + (1 - Sa) * Dc]
  kDstATop_Mode,  //!< [Sa, Sa * Dc + Sc * (1 - Da)]
  kXor_Mode,      //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
  kPlus_Mode,     //!< [Sa + Da, Sc + Dc]
  kModulate_Mode, // multiplies all components (= alpha and color)

  // Following blend modes are defined in the CSS Compositing standard:
  // https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blending
  kScreen_Mode,
  kLastCoeffMode = kScreen_Mode,

  kOverlay_Mode,
  kDarken_Mode,
  kLighten_Mode,
  kColorDodge_Mode,
  kColorBurn_Mode,
  kHardLight_Mode,
  kSoftLight_Mode,
  kDifference_Mode,
  kExclusion_Mode,
  kMultiply_Mode,
  kLastSeparableMode = kMultiply_Mode,

  kHue_Mode,
  kSaturation_Mode,
  kColor_Mode,
  kLuminosity_Mode,
  kLastMode = kLuminosity_Mode
};

struct SharedQuadState {
  // mojo.Transforms quad rects into the target content space.
  mojo.Transform quad_to_target_transform;

  // The size of the quads' originating layer in the space of the quad rects.
  mojo.Size quad_layer_bounds;

  // The size of the visible area in the quads' originating layer, in the space
  // of the quad rects.
  mojo.Rect visible_quad_layer_rect;

  // This rect lives in the target content space.
  mojo.Rect clip_rect;

  bool is_clipped;
  float opacity;
  SkXfermode blend_mode;
  int32 sorting_context_id;
};

struct Pass {
  RenderPassId id;
  mojo.Rect output_rect;
  mojo.Rect damage_rect;
  mojo.Transform transform_to_root_target;
  bool has_transparent_background;
  array<Quad> quads;
  array<SharedQuadState> shared_quad_states;
};