[go: nahoru, domu]

blob: dfa9f45fea34715f7f2bf7175686872eeed499a6 [file] [log] [blame]
George Mountb0286ae2020-02-20 15:14:09 -08001/*
2 * Copyright 2020 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
17package androidx.ui.core
18
19import androidx.ui.graphics.Canvas
George Mount8f237572020-04-30 12:08:30 -070020import androidx.ui.unit.IntOffset
21import androidx.ui.unit.IntSize
George Mountb0286ae2020-02-20 15:14:09 -080022
23/**
24 * A layer returned by [Owner.createLayer] to separate drawn content. An `OwnedLayer` has
25 * the implementation to make [DrawLayerModifier]s work.
26 */
27interface OwnedLayer {
28 /**
George Mount2db95b02020-04-13 15:19:34 -070029 * The ID of the layer. This is used by tooling to match a layer to the associated
30 * LayoutNode.
31 */
32 val layerId: Long
33
34 /**
George Mounta2e46b02020-06-15 10:33:15 -070035 * The DrawLayerModifier used in this layer.
36 */
37 var modifier: DrawLayerModifier
38
39 /**
George Mount783ba792020-03-12 23:46:15 -070040 * Reads the [DrawLayerModifier] and dirties the layer so that it will be redrawn.
George Mountb0286ae2020-02-20 15:14:09 -080041 */
42 fun updateLayerProperties()
43
44 /**
45 * Changes the position of the layer contents.
46 */
George Mount8f237572020-04-30 12:08:30 -070047 fun move(position: IntOffset)
George Mountb0286ae2020-02-20 15:14:09 -080048
49 /**
50 * Changes the size of the layer's drawn area.
51 */
George Mount8f237572020-04-30 12:08:30 -070052 fun resize(size: IntSize)
George Mountb0286ae2020-02-20 15:14:09 -080053
54 /**
55 * Causes the layer to be drawn into [canvas]
56 */
57 fun drawLayer(canvas: Canvas)
58
59 /**
George Mount0c2a07a2020-03-11 01:08:27 -070060 * Updates the drawing on the current canvas.
61 */
62 fun updateDisplayList()
63
64 /**
George Mountb0286ae2020-02-20 15:14:09 -080065 * Asks to the layer to redraw itself without forcing all of its parents to redraw.
66 */
67 fun invalidate()
68
69 /**
70 * Indicates that the layer is no longer needed.
71 */
72 fun destroy()
George Mountc3e3c462020-03-12 19:51:47 -070073
74 /**
75 * Returns a matrix that this layer will use to transform the contents.
76 * The caller must not modify the returned Matrix.
77 */
Nikolay Igotti438fdbf2020-06-25 12:05:58 +030078 fun getMatrix(): NativeMatrix
George Mountb0286ae2020-02-20 15:14:09 -080079}