Debian Codegraph @

libs/WindowManager/Shell/src/com/android/wm/shell/transition/WindowThumbnail.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2021 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.wm.shell.transition;
18
19 import android.graphics.ColorSpace;
20 import android.graphics.GraphicBuffer;
21 import android.graphics.PixelFormat;
22 import android.hardware.HardwareBuffer;
23 import android.view.SurfaceControl;
24 import android.view.SurfaceSession;
25
26 /**
27 * Represents a surface that is displayed over a transition surface.
28 */
29 class WindowThumbnail {
30
31 private SurfaceControl mSurfaceControl;
32
33 private WindowThumbnail() {}
34
35 /** Create a thumbnail surface and attach it over a parent surface. */
36 static WindowThumbnail createAndAttach(SurfaceSession surfaceSession, SurfaceControl parent,
37 HardwareBuffer thumbnailHeader, SurfaceControl.Transaction t) {
38 WindowThumbnail windowThumbnail = new WindowThumbnail();
39 windowThumbnail.mSurfaceControl = new SurfaceControl.Builder(surfaceSession)
40 .setParent(parent)
41 .setName("WindowThumanil : " + parent.toString())
42 .setCallsite("WindowThumanil")
43 .setFormat(PixelFormat.TRANSLUCENT)
44 .build();
45
46 GraphicBuffer graphicBuffer = GraphicBuffer.createFromHardwareBuffer(thumbnailHeader);
47 t.setBuffer(windowThumbnail.mSurfaceControl, graphicBuffer);
48 t.setColorSpace(windowThumbnail.mSurfaceControl, ColorSpace.get(ColorSpace.Named.SRGB));
49 t.setLayer(windowThumbnail.mSurfaceControl, Integer.MAX_VALUE);
50 t.show(windowThumbnail.mSurfaceControl);
51 t.apply();
52
53 return windowThumbnail;
54 }
55
56 SurfaceControl getSurface() {
57 return mSurfaceControl;
58 }
59
60 /** Remove the thumbnail surface and release the surface. */
61 void destroy(SurfaceControl.Transaction t) {
62 if (mSurfaceControl == null) {
63 return;
64 }
65
66 t.remove(mSurfaceControl);
67 t.apply();
68 mSurfaceControl.release();
69 mSurfaceControl = null;
70 }
71 }