1 /*
2  * Copyright 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.compose.ui.node
18 
19 import androidx.compose.ui.Modifier
20 import androidx.compose.ui.graphics.drawscope.ContentDrawScope
21 
22 /**
23  * A [Modifier.Node] that draws into the space of the layout.
24  *
25  * This is the [androidx.compose.ui.Modifier.Node] equivalent of
26  * [androidx.compose.ui.draw.DrawModifier]
27  *
28  * @sample androidx.compose.ui.samples.DrawModifierNodeSample
29  */
30 interface DrawModifierNode : DelegatableNode {
ContentDrawScopenull31     fun ContentDrawScope.draw()
32 
33     fun onMeasureResultChanged() {}
34 }
35 
36 /**
37  * Invalidates this modifier's draw layer, ensuring that a draw pass will be run on the next frame.
38  */
invalidateDrawnull39 fun DrawModifierNode.invalidateDraw() {
40     if (node.isAttached) {
41         requireCoordinator(Nodes.Any).invalidateLayer()
42     }
43 }
44