DeviceRenderNode.kt

/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.compose.ui.platform

import android.graphics.Outline
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.graphics.CanvasHolder
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.node.OwnedLayer

/**
 * RenderNode on Q+ and RenderNode on M-P devices have different APIs. This interface
 * unifies the access so that [RenderNodeLayer] can be used for both.
 */
internal interface DeviceRenderNode {
    val uniqueId: Long
    val left: Int
    val top: Int
    val right: Int
    val bottom: Int
    val width: Int
    val height: Int
    var scaleX: Float
    var scaleY: Float
    var translationX: Float
    var translationY: Float
    var elevation: Float
    var rotationZ: Float
    var rotationX: Float
    var rotationY: Float
    var pivotX: Float
    var pivotY: Float
    var clipToOutline: Boolean
    var clipToBounds: Boolean
    var alpha: Float
    val hasDisplayList: Boolean

    fun setOutline(outline: Outline?)
    fun setPosition(left: Int, top: Int, right: Int, bottom: Int): Boolean
    fun offsetLeftAndRight(offset: Int)
    fun offsetTopAndBottom(offset: Int)
    fun record(
        canvasHolder: CanvasHolder,
        clipPath: Path?,
        observerScope: OwnedLayer,
        drawBlock: (Canvas) -> Unit
    )
    fun getMatrix(matrix: android.graphics.Matrix)
    fun drawInto(canvas: android.graphics.Canvas)
    fun setHasOverlappingRendering(hasOverlappingRendering: Boolean): Boolean
}