chromium/components/viz/service/display/delegated_ink_point_renderer_skia.h

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_DELEGATED_INK_POINT_RENDERER_SKIA_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_DELEGATED_INK_POINT_RENDERER_SKIA_H_

#include <vector>

#include "components/viz/service/display/delegated_ink_point_renderer_base.h"
#include "components/viz/service/viz_service_export.h"
#include "third_party/skia/include/core/SkPath.h"

class SkCanvas;

namespace viz {

// This class handles drawing the delegated ink trail when the Skia renderer
// is in use by filtering everything out with timestamps before the metadata,
// predicting another point or two, and drawing the points with bezier curves
// between them with Skia commands onto the canvas provided by the Skia
// renderer, the |current_canvas_|.
// TODO(crbug.com/40118757): Specify exactly how many points are predicted.
//
// When an ink trail is getting ready to be drawn, after points and metadata
// have already arrived, the first thing that will be called is
// FinalizePathForDraw(). This is called when determining the portion of the
// frame that needs to be redrawn, so that GetDamageRect() can return the union
// of the bounding box of the previous ink trail that had been drawn (stored in
// |new_trail_damage_rect_| at this time) and the new ink trail.
// FinalizePathForDraw() will filter points, predict new ones, and use the
// result to update |path_| with the new ink trail. It also calls
// SetDamageRect() with the new trail's damage rect, which moves the rect
// currently in |new_trail_damage_rect_| to |old_trail_damage_rect_| and the new
// damage rect goes to |new_trail_damage_rect_|. GetDamageRect() then returns
// the union of the two for drawing.
// Then, after everything else in the frame has been drawn,
// DrawDelegatedInkTrail() will be called to actually draw the |path_| that was
// determined in FinalizePathForDraw().
// After drawing and swapping the buffers has completed, the display will call
// GetDamageRect() in order to update the ink trail damage rect on the surface
// aggregator, which is used to ensure one more frame will be drawn so that a
// trail never sticks around for longer than intended.
//
// For more information on the feature, please see the explainer:
// https://github.com/WICG/ink-enhancement/blob/main/README.md
class VIZ_SERVICE_EXPORT DelegatedInkPointRendererSkia
    : public DelegatedInkPointRendererBase {};

}  // namespace viz

#endif  // COMPONENTS_VIZ_SERVICE_DISPLAY_DELEGATED_INK_POINT_RENDERER_SKIA_H_