George Mount | b0286ae | 2020-02-20 15:14:09 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package androidx.ui.core |
| 18 | |
| 19 | import androidx.ui.graphics.Canvas |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 20 | import androidx.ui.unit.IntOffset |
| 21 | import androidx.ui.unit.IntSize |
George Mount | b0286ae | 2020-02-20 15:14:09 -0800 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * A layer returned by [Owner.createLayer] to separate drawn content. An `OwnedLayer` has |
| 25 | * the implementation to make [DrawLayerModifier]s work. |
| 26 | */ |
| 27 | interface OwnedLayer { |
| 28 | /** |
George Mount | 2db95b0 | 2020-04-13 15:19:34 -0700 | [diff] [blame] | 29 | * 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 Mount | a2e46b0 | 2020-06-15 10:33:15 -0700 | [diff] [blame] | 35 | * The DrawLayerModifier used in this layer. |
| 36 | */ |
| 37 | var modifier: DrawLayerModifier |
| 38 | |
| 39 | /** |
George Mount | 783ba79 | 2020-03-12 23:46:15 -0700 | [diff] [blame] | 40 | * Reads the [DrawLayerModifier] and dirties the layer so that it will be redrawn. |
George Mount | b0286ae | 2020-02-20 15:14:09 -0800 | [diff] [blame] | 41 | */ |
| 42 | fun updateLayerProperties() |
| 43 | |
| 44 | /** |
| 45 | * Changes the position of the layer contents. |
| 46 | */ |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 47 | fun move(position: IntOffset) |
George Mount | b0286ae | 2020-02-20 15:14:09 -0800 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * Changes the size of the layer's drawn area. |
| 51 | */ |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 52 | fun resize(size: IntSize) |
George Mount | b0286ae | 2020-02-20 15:14:09 -0800 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * Causes the layer to be drawn into [canvas] |
| 56 | */ |
| 57 | fun drawLayer(canvas: Canvas) |
| 58 | |
| 59 | /** |
George Mount | 0c2a07a | 2020-03-11 01:08:27 -0700 | [diff] [blame] | 60 | * Updates the drawing on the current canvas. |
| 61 | */ |
| 62 | fun updateDisplayList() |
| 63 | |
| 64 | /** |
George Mount | b0286ae | 2020-02-20 15:14:09 -0800 | [diff] [blame] | 65 | * 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 Mount | c3e3c46 | 2020-03-12 19:51:47 -0700 | [diff] [blame] | 73 | |
| 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 Igotti | 438fdbf | 2020-06-25 12:05:58 +0300 | [diff] [blame] | 78 | fun getMatrix(): NativeMatrix |
George Mount | b0286ae | 2020-02-20 15:14:09 -0800 | [diff] [blame] | 79 | } |