paint_worklet_layer_painter.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef CC_PAINT_PAINT_WORKLET_LAYER_PAINTER_H_
  5. #define CC_PAINT_PAINT_WORKLET_LAYER_PAINTER_H_
  6. #include "base/callback.h"
  7. #include "cc/paint/paint_export.h"
  8. #include "cc/paint/paint_record.h"
  9. #include "cc/paint/paint_worklet_job.h"
  10. namespace cc {
  11. // PaintWorkletLayerPainter bridges between the compositor and the PaintWorklet
  12. // thread, providing hooks for the compositor to paint PaintWorklet content that
  13. // Blink has deferred on.
  14. class CC_PAINT_EXPORT PaintWorkletLayerPainter {
  15. public:
  16. virtual ~PaintWorkletLayerPainter() {}
  17. // Asynchronously paints a set of PaintWorklet instances. The results are
  18. // returned via the provided callback, on the same thread that originally
  19. // called this method.
  20. //
  21. // Only one dispatch is allowed at a time; the calling code should not call
  22. // |DispatchWorklets| again until the passed |DoneCallback| has been called.
  23. using DoneCallback = base::OnceCallback<void(PaintWorkletJobMap)>;
  24. virtual void DispatchWorklets(PaintWorkletJobMap, DoneCallback) = 0;
  25. // Returns whether or not a dispatched set of PaintWorklet instances is
  26. // currently being painted.
  27. virtual bool HasOngoingDispatch() const = 0;
  28. };
  29. } // namespace cc
  30. #endif // CC_PAINT_PAINT_WORKLET_LAYER_PAINTER_H_