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

// Copyright 2021 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 "ui/gfx/geometry/mojom/geometry.mojom";
import "mojo/public/mojom/base/token.mojom";

// NOTE: we use a CropIdBoundsPair instead of a map below due to our need
// to serialize to blink objects, where WTF::HashMap only allows a very
// limited set of objects to be used as a key. The pair includes a crop id
// corresponding to an HTMLElement that has region capture data, and its
// associated bounds translated to the coordinate space of the outputted
// pixels.
struct CropIdBoundsPair {
  // The crop id is represented over mojom as a base::Token, although
  // in practice it is generated as a GUID. Since these are consumed only
  // internally in Chrome, we use base::Token for the representation.
  mojo_base.mojom.Token crop_id;
  gfx.mojom.Rect bounds;
};

// https://w3c.github.io/mediacapture-region/
// RegionCaptureBounds are used for passing in region capture crop ids mapped
// to a gfx::Rect representing the region of the viewport that should be cropped
// to for tab capture. These crop identifiers are GUIDs generated by calling the
// mediaDevices.produceCropId() API on HTML elements.
// The crop ID and bounds are stored internally in Blink and are passed to and
// tracked by the compositor/viz. If a previously-generated crop ID is selected
// via mediaStreamTrack.cropTo(), the frame sink video capturer uses the crop
// IDs associated with the compositor render passes to determine what section of
// the frame should be cropped out when applying copy output requests.
struct RegionCaptureBounds {
  array<CropIdBoundsPair> bounds;
};