Xida Chen | e3019ab | 2019-01-02 21:13:48 | [diff] [blame] | 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 | |
| 5 | #ifndef CC_PAINT_PAINT_WORKLET_LAYER_PAINTER_H_ |
| 6 | #define CC_PAINT_PAINT_WORKLET_LAYER_PAINTER_H_ |
| 7 | |
Stephen McGruer | 8bee6b1 | 2019-06-06 15:15:33 | [diff] [blame] | 8 | #include "base/callback.h" |
| 9 | #include "cc/paint/paint_export.h" |
Xida Chen | ea3139f | 2019-01-10 21:46:30 | [diff] [blame] | 10 | #include "cc/paint/paint_record.h" |
Stephen McGruer | 8bee6b1 | 2019-06-06 15:15:33 | [diff] [blame] | 11 | #include "cc/paint/paint_worklet_job.h" |
Xida Chen | e3019ab | 2019-01-02 21:13:48 | [diff] [blame] | 12 | |
| 13 | namespace cc { |
| 14 | |
Stephen McGruer | 8bee6b1 | 2019-06-06 15:15:33 | [diff] [blame] | 15 | // PaintWorkletLayerPainter bridges between the compositor and the PaintWorklet |
| 16 | // thread, providing hooks for the compositor to paint PaintWorklet content that |
| 17 | // Blink has deferred on. |
| 18 | class CC_PAINT_EXPORT PaintWorkletLayerPainter { |
Xida Chen | e3019ab | 2019-01-02 21:13:48 | [diff] [blame] | 19 | public: |
| 20 | virtual ~PaintWorkletLayerPainter() {} |
| 21 | |
Stephen McGruer | 8bee6b1 | 2019-06-06 15:15:33 | [diff] [blame] | 22 | // Asynchronously paints a set of PaintWorklet instances. The results are |
| 23 | // returned via the provided callback, on the same thread that originally |
| 24 | // called this method. |
Stephen McGruer | 8e2d355 | 2019-07-10 14:06:29 | [diff] [blame] | 25 | // |
| 26 | // Only one dispatch is allowed at a time; the calling code should not call |
| 27 | // |DispatchWorklets| again until the passed |DoneCallback| has been called. |
Stephen McGruer | 8bee6b1 | 2019-06-06 15:15:33 | [diff] [blame] | 28 | using DoneCallback = base::OnceCallback<void(PaintWorkletJobMap)>; |
| 29 | virtual void DispatchWorklets(PaintWorkletJobMap, DoneCallback) = 0; |
Stephen McGruer | 8e2d355 | 2019-07-10 14:06:29 | [diff] [blame] | 30 | |
| 31 | // Returns whether or not a dispatched set of PaintWorklet instances is |
| 32 | // currently being painted. |
| 33 | virtual bool HasOngoingDispatch() const = 0; |
Xida Chen | e3019ab | 2019-01-02 21:13:48 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | } // namespace cc |
| 37 | |
| 38 | #endif // CC_PAINT_PAINT_WORKLET_LAYER_PAINTER_H_ |