blob: 8f4926fe14a308daadba3bedcb75c3a4904d0f72 [file] [log] [blame]
Winson Chung2776b062017-12-05 12:33:52 -08001/*
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
17package com.android.systemui.shared.system;
18
19import android.graphics.Matrix;
20import android.graphics.Rect;
Winson Chung2776b062017-12-05 12:33:52 -080021import android.view.Surface;
Winson Chung2776b062017-12-05 12:33:52 -080022import android.view.SurfaceControl.Transaction;
Robert Carrf2f84f52020-02-11 11:51:29 -080023import android.view.SurfaceControl;
Winson Chung2776b062017-12-05 12:33:52 -080024
25public class TransactionCompat {
26
Jorim Jaggicd560732018-05-29 16:29:24 +020027 final Transaction mTransaction;
Winson Chung2776b062017-12-05 12:33:52 -080028
Jorim Jaggicd560732018-05-29 16:29:24 +020029 final float[] mTmpValues = new float[9];
Winson Chung2776b062017-12-05 12:33:52 -080030
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 Naire86bd982018-11-28 13:23:17 -080055 mTransaction.setBufferSize(surfaceControl.mSurfaceControl, w, h);
Winson Chung2776b062017-12-05 12:33:52 -080056 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 Chungb6eba5e2019-01-04 12:19:40 -080085 public TransactionCompat setCornerRadius(SurfaceControlCompat surfaceControl, float radius) {
86 mTransaction.setCornerRadius(surfaceControl.mSurfaceControl, radius);
87 return this;
88 }
89
Winson Chung2776b062017-12-05 12:33:52 -080090 public TransactionCompat deferTransactionUntil(SurfaceControlCompat surfaceControl,
Robert Carrf2f84f52020-02-11 11:51:29 -080091 SurfaceControl barrier, long frameNumber) {
92 mTransaction.deferTransactionUntil(surfaceControl.mSurfaceControl, barrier,
Winson Chung2776b062017-12-05 12:33:52 -080093 frameNumber);
94 return this;
95 }
96
Jorim Jaggiaa763cd2018-03-22 23:20:36 +010097 public TransactionCompat setEarlyWakeup() {
98 mTransaction.setEarlyWakeup();
99 return this;
100 }
101
Winson Chung2776b062017-12-05 12:33:52 -0800102 public TransactionCompat setColor(SurfaceControlCompat surfaceControl, float[] color) {
103 mTransaction.setColor(surfaceControl.mSurfaceControl, color);
104 return this;
105 }
Robert Carrf2f84f52020-02-11 11:51:29 -0800106}