Winson Chung | 2776b06 | 2017-12-05 12:33:52 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 com.android.systemui.shared.system; |
| 18 | |
| 19 | import android.graphics.Matrix; |
| 20 | import android.graphics.Rect; |
Winson Chung | 2776b06 | 2017-12-05 12:33:52 -0800 | [diff] [blame] | 21 | import android.view.Surface; |
Winson Chung | 2776b06 | 2017-12-05 12:33:52 -0800 | [diff] [blame] | 22 | import android.view.SurfaceControl.Transaction; |
Robert Carr | f2f84f5 | 2020-02-11 11:51:29 -0800 | [diff] [blame] | 23 | import android.view.SurfaceControl; |
Winson Chung | 2776b06 | 2017-12-05 12:33:52 -0800 | [diff] [blame] | 24 | |
| 25 | public class TransactionCompat { |
| 26 | |
Jorim Jaggi | cd56073 | 2018-05-29 16:29:24 +0200 | [diff] [blame] | 27 | final Transaction mTransaction; |
Winson Chung | 2776b06 | 2017-12-05 12:33:52 -0800 | [diff] [blame] | 28 | |
Jorim Jaggi | cd56073 | 2018-05-29 16:29:24 +0200 | [diff] [blame] | 29 | final float[] mTmpValues = new float[9]; |
Winson Chung | 2776b06 | 2017-12-05 12:33:52 -0800 | [diff] [blame] | 30 | |
| 31 | public TransactionCompat() { |
| 32 | mTransaction = new Transaction(); |
| 33 | } |
| 34 | |
| 35 | public void apply() { |
| 36 | mTransaction.apply(); |
| 37 | } |
| 38 | |
| 39 | public TransactionCompat show(SurfaceControlCompat surfaceControl) { |
| 40 | mTransaction.show(surfaceControl.mSurfaceControl); |
| 41 | return this; |
| 42 | } |
| 43 | |
| 44 | public TransactionCompat hide(SurfaceControlCompat surfaceControl) { |
| 45 | mTransaction.hide(surfaceControl.mSurfaceControl); |
| 46 | return this; |
| 47 | } |
| 48 | |
| 49 | public TransactionCompat setPosition(SurfaceControlCompat surfaceControl, float x, float y) { |
| 50 | mTransaction.setPosition(surfaceControl.mSurfaceControl, x, y); |
| 51 | return this; |
| 52 | } |
| 53 | |
| 54 | public TransactionCompat setSize(SurfaceControlCompat surfaceControl, int w, int h) { |
Vishnu Nair | e86bd98 | 2018-11-28 13:23:17 -0800 | [diff] [blame] | 55 | mTransaction.setBufferSize(surfaceControl.mSurfaceControl, w, h); |
Winson Chung | 2776b06 | 2017-12-05 12:33:52 -0800 | [diff] [blame] | 56 | return this; |
| 57 | } |
| 58 | |
| 59 | public TransactionCompat setLayer(SurfaceControlCompat surfaceControl, int z) { |
| 60 | mTransaction.setLayer(surfaceControl.mSurfaceControl, z); |
| 61 | return this; |
| 62 | } |
| 63 | |
| 64 | public TransactionCompat setAlpha(SurfaceControlCompat surfaceControl, float alpha) { |
| 65 | mTransaction.setAlpha(surfaceControl.mSurfaceControl, alpha); |
| 66 | return this; |
| 67 | } |
| 68 | |
| 69 | public TransactionCompat setMatrix(SurfaceControlCompat surfaceControl, float dsdx, float dtdx, |
| 70 | float dtdy, float dsdy) { |
| 71 | mTransaction.setMatrix(surfaceControl.mSurfaceControl, dsdx, dtdx, dtdy, dsdy); |
| 72 | return this; |
| 73 | } |
| 74 | |
| 75 | public TransactionCompat setMatrix(SurfaceControlCompat surfaceControl, Matrix matrix) { |
| 76 | mTransaction.setMatrix(surfaceControl.mSurfaceControl, matrix, mTmpValues); |
| 77 | return this; |
| 78 | } |
| 79 | |
| 80 | public TransactionCompat setWindowCrop(SurfaceControlCompat surfaceControl, Rect crop) { |
| 81 | mTransaction.setWindowCrop(surfaceControl.mSurfaceControl, crop); |
| 82 | return this; |
| 83 | } |
| 84 | |
Winson Chung | b6eba5e | 2019-01-04 12:19:40 -0800 | [diff] [blame] | 85 | public TransactionCompat setCornerRadius(SurfaceControlCompat surfaceControl, float radius) { |
| 86 | mTransaction.setCornerRadius(surfaceControl.mSurfaceControl, radius); |
| 87 | return this; |
| 88 | } |
| 89 | |
Winson Chung | 2776b06 | 2017-12-05 12:33:52 -0800 | [diff] [blame] | 90 | public TransactionCompat deferTransactionUntil(SurfaceControlCompat surfaceControl, |
Robert Carr | f2f84f5 | 2020-02-11 11:51:29 -0800 | [diff] [blame] | 91 | SurfaceControl barrier, long frameNumber) { |
| 92 | mTransaction.deferTransactionUntil(surfaceControl.mSurfaceControl, barrier, |
Winson Chung | 2776b06 | 2017-12-05 12:33:52 -0800 | [diff] [blame] | 93 | frameNumber); |
| 94 | return this; |
| 95 | } |
| 96 | |
Jorim Jaggi | aa763cd | 2018-03-22 23:20:36 +0100 | [diff] [blame] | 97 | public TransactionCompat setEarlyWakeup() { |
| 98 | mTransaction.setEarlyWakeup(); |
| 99 | return this; |
| 100 | } |
| 101 | |
Winson Chung | 2776b06 | 2017-12-05 12:33:52 -0800 | [diff] [blame] | 102 | public TransactionCompat setColor(SurfaceControlCompat surfaceControl, float[] color) { |
| 103 | mTransaction.setColor(surfaceControl.mSurfaceControl, color); |
| 104 | return this; |
| 105 | } |
Robert Carr | f2f84f5 | 2020-02-11 11:51:29 -0800 | [diff] [blame] | 106 | } |