chromium/services/viz/public/mojom/compositing/quads.mojom

// 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.

module viz.mojom;

import "mojo/public/mojom/base/unguessable_token.mojom";
import "services/viz/public/mojom/compositing/compositor_render_pass_id.mojom";
import "services/viz/public/mojom/compositing/resource_id.mojom";
import "services/viz/public/mojom/compositing/view_transition_element_resource_id.mojom";
import "services/viz/public/mojom/compositing/shared_quad_state.mojom";
import "services/viz/public/mojom/compositing/surface_range.mojom";
import "skia/public/mojom/skcolor4f.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/color_space.mojom";
import "ui/gfx/mojom/hdr_metadata.mojom";
import "ui/gfx/mojom/transform.mojom";

enum ProtectedVideoState {
  kClear,
  kSoftwareProtected,
  kHardwareProtected,
};

enum OverlayPriority {
  kLow,
  kRegular,
  kRequired
};

struct RoundedDisplayMasksInfo {
  bool is_horizontally_positioned;
  array<uint8, 2> radii;
};

struct DebugBorderQuadState {
  // Debug border color.
  skia.mojom.SkColor4f color;

  // Debug border width.
  int32 width;
};

struct CompositorRenderPassQuadState {
  CompositorRenderPassId render_pass_id;

  // If nonzero, resource id of mask to use when drawing this pass.
  ResourceId mask_resource_id;
  // Render surface's normalized mask texture rect.
  gfx.mojom.RectF mask_uv_rect;
  gfx.mojom.Size mask_texture_size;

  // 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.
  gfx.mojom.Vector2dF filters_scale;

  // The offset from the bounds of the root layer to the origin of the
  // original primitive. This used to correctly position crop rects, lights,
  // etc.
  gfx.mojom.PointF filters_origin;
  // Render surface's non-normalized texture rect.
  gfx.mojom.RectF tex_coord_rect;

  bool force_anti_aliasing_off;
  float backdrop_filter_quality;
  // Indicates if the quad intersects any damage coming from quads under it
  // rendering to the same target.
  bool intersects_damage_under;
};

struct SolidColorQuadState {
  skia.mojom.SkColor4f color;
  bool force_anti_aliasing_off;
};

struct SurfaceQuadState {
  SurfaceRange surface_range;
  skia.mojom.SkColor4f default_background_color;
  bool stretch_content_to_fill_bounds;
  bool is_reflection;
  bool allow_merge;
};

struct TextureQuadState {
  ResourceId resource_id;
  gfx.mojom.Size resource_size_in_pixels;
  bool premultiplied_alpha;
  gfx.mojom.PointF uv_top_left;
  gfx.mojom.PointF uv_bottom_right;
  skia.mojom.SkColor4f background_color;
  bool y_flipped;
  bool nearest_neighbor;
  bool secure_output_only;
  bool is_stream_video;
  bool is_video_frame;
  bool force_rgbx;
  ProtectedVideoState protected_video_type;
  gfx.mojom.Rect? damage_rect;
  OverlayPriority overlay_priority_hint;
  RoundedDisplayMasksInfo rounded_display_masks_info;
};

struct TileQuadState {
  gfx.mojom.RectF tex_coord_rect;
  gfx.mojom.Size texture_size;
  bool is_premultiplied;
  ResourceId resource_id;
  bool nearest_neighbor;
  bool force_anti_aliasing_off;
};

struct YUVVideoQuadState {
  gfx.mojom.Size coded_size;
  gfx.mojom.Rect video_visible_rect;
  uint8 u_scale;
  uint8 v_scale;
  ResourceId y_plane_resource_id;
  ResourceId u_plane_resource_id;
  ResourceId v_plane_resource_id;
  ResourceId a_plane_resource_id;
  uint32 bits_per_channel;
  gfx.mojom.ColorSpace video_color_space;
  ProtectedVideoState protected_video_type;
  gfx.mojom.HDRMetadata hdr_metadata;
  gfx.mojom.Rect? damage_rect;
};

struct VideoHoleQuadState {
  mojo_base.mojom.UnguessableToken overlay_plane_id;
};

struct SharedElementQuadState {
  ViewTransitionElementResourceId resource_id;
};

union DrawQuadState {
  DebugBorderQuadState debug_border_quad_state;
  CompositorRenderPassQuadState render_pass_quad_state;
  SolidColorQuadState solid_color_quad_state;
  SurfaceQuadState surface_quad_state;
  TextureQuadState texture_quad_state;
  TileQuadState tile_quad_state;
  YUVVideoQuadState yuv_video_quad_state;
  VideoHoleQuadState video_hole_quad_state;
  SharedElementQuadState shared_element_quad_state;
};

struct DrawQuad {
  // This rect, after applying the quad_transform(), gives the geometry that
  // this quad should draw to. This rect lives in content space.
  gfx.mojom.Rect 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.
  gfx.mojom.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;

  // Optionally holds a SharedQuadState (transforms etc) shared by multiple
  // quads.
  SharedQuadState? sqs;

  DrawQuadState draw_quad_state;
};