| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 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 |
|
| 28 |
|
| 29 |
class WindowThumbnail { |
| 30 |
|
| 31 |
private SurfaceControl mSurfaceControl; |
| 32 |
|
| 33 |
private WindowThumbnail() {} |
| 34 |
|
| 35 |
|
| 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 |
|
| 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 |
} |