Layer.h revision 29abff83bb6e148961c2319add7bd72eb76af3d4
1e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov/* 2e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * Copyright (C) 2007 The Android Open Source Project 3e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * 4e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * Licensed under the Apache License, Version 2.0 (the "License"); 5e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * you may not use this file except in compliance with the License. 6e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * You may obtain a copy of the License at 7e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * 8e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * http://www.apache.org/licenses/LICENSE-2.0 9e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * 10e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * Unless required by applicable law or agreed to in writing, software 11e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * distributed under the License is distributed on an "AS IS" BASIS, 12e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * See the License for the specific language governing permissions and 14e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov * limitations under the License. 15e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov */ 16e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 17e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#ifndef ANDROID_LAYER_H 18e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#define ANDROID_LAYER_H 19e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 2049b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov#include <stdint.h> 2149b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov#include <sys/types.h> 22e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 23e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include <utils/RefBase.h> 24e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include <utils/String8.h> 2549b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov#include <utils/Timers.h> 26e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 27e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include <ui/FrameStats.h> 2826b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov#include <ui/GraphicBuffer.h> 29e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include <ui/PixelFormat.h> 30e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include <ui/Region.h> 31def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas 32def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas#include <gui/ISurfaceComposerClient.h> 33def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas#include <gui/LayerState.h> 34def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas 35def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas#include <list> 36def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas 37def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas#include "Client.h" 38def582a5836579a3fadabfdbe4413cb1652bf098Aurimas Liutikas#include "FrameTracker.h" 39e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include "LayerVector.h" 40e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include "MonitoredProducer.h" 41e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include "SurfaceFlinger.h" 42e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include "Transform.h" 43e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 44e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include <layerproto/LayerProtoHeader.h> 45e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include "DisplayHardware/HWComposer.h" 46e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include "DisplayHardware/HWComposerBufferCache.h" 47e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include "RenderArea.h" 48e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include "RenderEngine/Mesh.h" 49e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include "RenderEngine/Texture.h" 50e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 51e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov#include <math/vec4.h> 52e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 53e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovusing namespace android::surfaceflinger; 54e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 55e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovnamespace android { 56e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 57e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov// --------------------------------------------------------------------------- 58e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 59e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovclass Client; 60e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovclass Colorizer; 61e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovclass DisplayDevice; 62e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovclass GraphicBuffer; 63e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovclass SurfaceFlinger; 64e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovclass LayerDebugInfo; 65e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovclass LayerBE; 66e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 67e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov// --------------------------------------------------------------------------- 68e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 69e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovclass LayerBE { 70e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovpublic: 71e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov LayerBE(); 72e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 73e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // main thread 74e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov int mBufferSlot; 75e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov sp<GraphicBuffer> mBuffer; 76e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov sp<NativeHandle> mSidebandStream; 77e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 78e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // The mesh used to draw the layer in GLES composition mode 79e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov Mesh mMesh; 80e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 81e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // HWC items, accessed from the main thread 82e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov struct HWCInfo { 8326b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov HWCInfo() 8426b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov : hwc(nullptr), 85e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov layer(nullptr), 86e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov forceClientComposition(false), 87e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov compositionType(HWC2::Composition::Invalid), 88e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov clearClientTarget(false) {} 89e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 90e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov HWComposer* hwc; 91e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov HWC2::Layer* layer; 92e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool forceClientComposition; 93e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov HWC2::Composition compositionType; 94e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool clearClientTarget; 95e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov Rect displayFrame; 96fa2e2acf79d791a90410025daad438968550d18cAlan Viverette FloatRect sourceCrop; 97fa2e2acf79d791a90410025daad438968550d18cAlan Viverette HWComposerBufferCache bufferCache; 98fa2e2acf79d791a90410025daad438968550d18cAlan Viverette }; 99fa2e2acf79d791a90410025daad438968550d18cAlan Viverette 100e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // A layer can be attached to multiple displays when operating in mirror mode 101e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // (a.k.a: when several displays are attached with equal layerStack). In this 10226b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // case we need to keep track. In non-mirror mode, a layer will have only one 103e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // HWCInfo. This map key is a display layerStack. 104e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov std::unordered_map<int32_t, HWCInfo> mHwcLayers; 105e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov}; 106e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 107e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovclass Layer : public virtual RefBase { 108e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov static int32_t sSequence; 10926b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov 110e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikovpublic: 11126b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov LayerBE& getBE() { return mBE; } 112e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov LayerBE& getBE() const { return mBE; } 113e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov mutable bool contentDirty; 114e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // regions below are in window-manager space 115fa2e2acf79d791a90410025daad438968550d18cAlan Viverette Region visibleRegion; 116e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov Region coveredRegion; 117e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov Region visibleNonTransparentRegion; 118e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov Region surfaceDamageRegion; 119e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 120e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // Layer serial number. This gives layers an explicit ordering, so we 121e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // have a stable sort order when their layer stack and Z-order are 122e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // the same. 123e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov int32_t sequence; 124e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 125e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov enum { // flags for doTransaction() 126e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov eDontUpdateGeometryState = 0x00000001, 127e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov eVisibleRegion = 0x00000002, 128e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov }; 129e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 130e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov struct Geometry { 131e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov uint32_t w; 132e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov uint32_t h; 133e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov Transform transform; 134e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 135e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov inline bool operator==(const Geometry& rhs) const { 136e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov return (w == rhs.w && h == rhs.h) && (transform.tx() == rhs.transform.tx()) && 137e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov (transform.ty() == rhs.transform.ty()); 138e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov } 139e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov inline bool operator!=(const Geometry& rhs) const { return !operator==(rhs); } 140e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov }; 141e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 142e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov struct State { 143e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov Geometry active; 144e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov Geometry requested; 145e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov int32_t z; 146e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 1470984f98baad154a687823303666d437161ef3bffKirill Grouchnikov // The identifier of the layer stack this layer belongs to. A layer can 148e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // only be associated to a single layer stack. A layer stack is a 149e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // z-ordered group of layers which can be associated to one or more 150e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // displays. Using the same layer stack on different displays is a way 151e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // to achieve mirroring. 152e8e0eae2600001c8b1e9d5a9f0331cf045193746Aurimas Liutikas uint32_t layerStack; 153e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 154e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov uint8_t flags; 15549b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov uint8_t mask; 15649b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov uint8_t reserved[2]; 15749b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov int32_t sequence; // changes when visible regions can change 15849b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov bool modified; 15949b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov 16049b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov // Crop is expressed in layer space coordinate. 16149b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov Rect crop; 16249b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov Rect requestedCrop; 16349b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov 16449b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov // finalCrop is expressed in display space coordinate. 16549b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov Rect finalCrop; 16649b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov Rect requestedFinalCrop; 16749b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov 16849b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov // If set, defers this state update until the identified Layer 169ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikas // receives a frame with the given frameNumber 17049b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov wp<Layer> barrierLayer; 17149b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov uint64_t frameNumber; 17249b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov 17349b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov // the transparentRegion hint is a bit special, it's latched only 17449b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov // when we receive a buffer -- this is because it's "content" 17549b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov // dependent. 17649b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov Region activeTransparentRegion; 17749b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov Region requestedTransparentRegion; 17849b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov android_dataspace dataSpace; 17949b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov 18026b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov uint32_t appId; 18126b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov uint32_t type; 18226b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov 18326b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // If non-null, a Surface this Surface's Z-order is interpreted relative to. 18426b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov wp<Layer> zOrderRelativeOf; 18526b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov 18626b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // A list of surfaces whose Z-order is interpreted relative to ours. 18726b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov SortedVector<wp<Layer>> zOrderRelatives; 18826b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov 18949b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov half4 color; 19049b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov }; 19149b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov 19249b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name, uint32_t w, 19349b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov uint32_t h, uint32_t flags); 19449b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov virtual ~Layer(); 19549b20509b42c7e9abf941fdce55599c57ac689cfKirill Grouchnikov 196e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov void setPrimaryDisplayOnly() { mPrimaryDisplayOnly = true; } 197e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 198e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // ------------------------------------------------------------------------ 199e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // Geometry setting functions. 200e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // 201e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // The following group of functions are used to specify the layers 202e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // bounds, and the mapping of the texture on to those bounds. According 203e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // to various settings changes to them may apply immediately, or be delayed until 204e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // a pending resize is completed by the producer submitting a buffer. For example 205e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // if we were to change the buffer size, and update the matrix ahead of the 206e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // new buffer arriving, then we would be stretching the buffer to a different 207e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // aspect before and after the buffer arriving, which probably isn't what we wanted. 208e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // 209e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // The first set of geometry functions are controlled by the scaling mode, described 210e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // in window.h. The scaling mode may be set by the client, as it submits buffers. 211e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // This value may be overriden through SurfaceControl, with setOverrideScalingMode. 212e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // 213e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // Put simply, if our scaling mode is SCALING_MODE_FREEZE, then 214e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // matrix updates will not be applied while a resize is pending 215e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // and the size and transform will remain in their previous state 216e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // until a new buffer is submitted. If the scaling mode is another value 217e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // then the old-buffer will immediately be scaled to the pending size 218e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // and the new matrix will be immediately applied following this scaling 219e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // transformation. 22026b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov 22126b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // Set the default buffer size for the assosciated Producer, in pixels. This is 22226b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // also the rendered size of the layer prior to any transformations. Parent 22326b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // or local matrix transformations will not affect the size of the buffer, 22426b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // but may affect it's on-screen size or clipping. 22526b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov bool setSize(uint32_t w, uint32_t h); 22626b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // Set a 2x2 transformation matrix on the layer. This transform 22726b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // will be applied after parent transforms, but before any final 22826b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // producer specified transform. 22926b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov bool setMatrix(const layer_state_t::matrix22_t& matrix); 23026b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov 23126b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // This second set of geometry attributes are controlled by 23226b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // setGeometryAppliesWithResize, and their default mode is to be 23326b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // immediate. If setGeometryAppliesWithResize is specified 23426b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // while a resize is pending, then update of these attributes will 23526b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov // be delayed until the resize completes. 236e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 237e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // setPosition operates in parent buffer space (pre parent-transform) or display 238e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // space for top-level layers. 239e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setPosition(float x, float y, bool immediate); 240e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // Buffer space 241e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setCrop(const Rect& crop, bool immediate); 242e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // Parent buffer space/display space 243e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setFinalCrop(const Rect& crop, bool immediate); 244e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 245e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // TODO(b/38182121): Could we eliminate the various latching modes by 246e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // using the layer hierarchy? 247e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov // ----------------------------------------------------------------------- 248e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setLayer(int32_t z); 249e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setRelativeLayer(const sp<IBinder>& relativeToHandle, int32_t relativeZ); 250e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov 251e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setAlpha(float alpha); 252e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setColor(const half3& color); 253e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setTransparentRegionHint(const Region& transparent); 254e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setFlags(uint8_t flags, uint8_t mask); 255e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setLayerStack(uint32_t layerStack); 256e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov bool setDataSpace(android_dataspace dataSpace); 25726b4a0416012ed538a0f4e0dc69ba6bd19d247beKirill Grouchnikov android_dataspace getDataSpace() const; 258e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov uint32_t getLayerStack() const; 259e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov void deferTransactionUntil(const sp<IBinder>& barrierHandle, uint64_t frameNumber); 260e963911344d98d1a79e3e8dcea16ea04371f2af6Kirill Grouchnikov void deferTransactionUntil(const sp<Layer>& barrierLayer, uint64_t frameNumber); 261 bool setOverrideScalingMode(int32_t overrideScalingMode); 262 void setInfo(uint32_t type, uint32_t appId); 263 bool reparentChildren(const sp<IBinder>& layer); 264 bool reparent(const sp<IBinder>& newParentHandle); 265 bool detachChildren(); 266 267 // If we have received a new buffer this frame, we will pass its surface 268 // damage down to hardware composer. Otherwise, we must send a region with 269 // one empty rect. 270 virtual void useSurfaceDamage() = 0; 271 virtual void useEmptyDamage() = 0; 272 273 uint32_t getTransactionFlags(uint32_t flags); 274 uint32_t setTransactionFlags(uint32_t flags); 275 276 bool belongsToDisplay(uint32_t layerStack, bool isPrimaryDisplay) const { 277 return getLayerStack() == layerStack && (!mPrimaryDisplayOnly || isPrimaryDisplay); 278 } 279 280 void computeGeometry(const RenderArea& renderArea, Mesh& mesh, bool useIdentityTransform) const; 281 Rect computeBounds(const Region& activeTransparentRegion) const; 282 Rect computeBounds() const; 283 284 int32_t getSequence() const { return sequence; } 285 286 // ----------------------------------------------------------------------- 287 // Virtuals 288 virtual const char* getTypeId() const = 0; 289 290 /* 291 * isOpaque - true if this surface is opaque 292 * 293 * This takes into account the buffer format (i.e. whether or not the 294 * pixel format includes an alpha channel) and the "opaque" flag set 295 * on the layer. It does not examine the current plane alpha value. 296 */ 297 virtual bool isOpaque(const Layer::State& s) const = 0; 298 299 /* 300 * isSecure - true if this surface is secure, that is if it prevents 301 * screenshots or VNC servers. 302 */ 303 bool isSecure() const; 304 305 /* 306 * isVisible - true if this layer is visible, false otherwise 307 */ 308 virtual bool isVisible() const = 0; 309 310 /* 311 * isHiddenByPolicy - true if this layer has been forced invisible. 312 * just because this is false, doesn't mean isVisible() is true. 313 * For example if this layer has no active buffer, it may not be hidden by 314 * policy, but it still can not be visible. 315 */ 316 bool isHiddenByPolicy() const; 317 318 /* 319 * isFixedSize - true if content has a fixed size 320 */ 321 virtual bool isFixedSize() const = 0; 322 323 bool isPendingRemoval() const { return mPendingRemoval; } 324 325 void writeToProto(LayerProto* layerInfo, 326 LayerVector::StateSet stateSet = LayerVector::StateSet::Drawing); 327 328protected: 329 /* 330 * onDraw - draws the surface. 331 */ 332 virtual void onDraw(const RenderArea& renderArea, const Region& clip, 333 bool useIdentityTransform) const = 0; 334 335public: 336 virtual void setDefaultBufferSize(uint32_t w, uint32_t h) = 0; 337 338 void setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z); 339 void forceClientComposition(int32_t hwcId); 340 bool getForceClientComposition(int32_t hwcId); 341 virtual void setPerFrameData(const sp<const DisplayDevice>& displayDevice) = 0; 342 343 // callIntoHwc exists so we can update our local state and call 344 // acceptDisplayChanges without unnecessarily updating the device's state 345 void setCompositionType(int32_t hwcId, HWC2::Composition type, bool callIntoHwc = true); 346 HWC2::Composition getCompositionType(int32_t hwcId) const; 347 void setClearClientTarget(int32_t hwcId, bool clear); 348 bool getClearClientTarget(int32_t hwcId) const; 349 void updateCursorPosition(const sp<const DisplayDevice>& hw); 350 351 /* 352 * called after page-flip 353 */ 354 virtual void onLayerDisplayed(const sp<Fence>& releaseFence); 355 356 virtual void abandon() = 0; 357 358 virtual bool shouldPresentNow(const DispSync& dispSync) const = 0; 359 virtual void setTransformHint(uint32_t orientation) const = 0; 360 361 /* 362 * called before composition. 363 * returns true if the layer has pending updates. 364 */ 365 virtual bool onPreComposition(nsecs_t refreshStartTime) = 0; 366 367 /* 368 * called after composition. 369 * returns true if the layer latched a new buffer this frame. 370 */ 371 virtual bool onPostComposition(const std::shared_ptr<FenceTime>& glDoneFence, 372 const std::shared_ptr<FenceTime>& presentFence, 373 const CompositorTiming& compositorTiming) = 0; 374 375 // If a buffer was replaced this frame, release the former buffer 376 virtual void releasePendingBuffer(nsecs_t dequeueReadyTime) = 0; 377 378 /* 379 * draw - performs some global clipping optimizations 380 * and calls onDraw(). 381 */ 382 void draw(const RenderArea& renderArea, const Region& clip) const; 383 void draw(const RenderArea& renderArea, bool useIdentityTransform) const; 384 void draw(const RenderArea& renderArea) const; 385 386 /* 387 * doTransaction - process the transaction. This is a good place to figure 388 * out which attributes of the surface have changed. 389 */ 390 uint32_t doTransaction(uint32_t transactionFlags); 391 392 /* 393 * setVisibleRegion - called to set the new visible region. This gives 394 * a chance to update the new visible region or record the fact it changed. 395 */ 396 void setVisibleRegion(const Region& visibleRegion); 397 398 /* 399 * setCoveredRegion - called when the covered region changes. The covered 400 * region corresponds to any area of the surface that is covered 401 * (transparently or not) by another surface. 402 */ 403 void setCoveredRegion(const Region& coveredRegion); 404 405 /* 406 * setVisibleNonTransparentRegion - called when the visible and 407 * non-transparent region changes. 408 */ 409 void setVisibleNonTransparentRegion(const Region& visibleNonTransparentRegion); 410 411 /* 412 * latchBuffer - called each time the screen is redrawn and returns whether 413 * the visible regions need to be recomputed (this is a fairly heavy 414 * operation, so this should be set only if needed). Typically this is used 415 * to figure out if the content or size of a surface has changed. 416 */ 417 virtual Region latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime) = 0; 418 virtual bool isBufferLatched() const = 0; 419 420 bool isPotentialCursor() const { return mPotentialCursor; } 421 /* 422 * called with the state lock from a binder thread when the layer is 423 * removed from the current list to the pending removal list 424 */ 425 void onRemovedFromCurrentState(); 426 427 /* 428 * called with the state lock from the main thread when the layer is 429 * removed from the pending removal list 430 */ 431 void onRemoved(); 432 433 // Updates the transform hint in our SurfaceFlingerConsumer to match 434 // the current orientation of the display device. 435 void updateTransformHint(const sp<const DisplayDevice>& hw) const; 436 437 /* 438 * returns the rectangle that crops the content of the layer and scales it 439 * to the layer's size. 440 */ 441 Rect getContentCrop() const; 442 443 /* 444 * Returns if a frame is queued. 445 */ 446 bool hasQueuedFrame() const { 447 return mQueuedFrames > 0 || mSidebandStreamChanged || mAutoRefresh; 448 } 449 450 int32_t getQueuedFrameCount() const { return mQueuedFrames; } 451 452 // ----------------------------------------------------------------------- 453 454 bool createHwcLayer(HWComposer* hwc, int32_t hwcId); 455 bool destroyHwcLayer(int32_t hwcId); 456 void destroyAllHwcLayers(); 457 458 bool hasHwcLayer(int32_t hwcId) { 459 return getBE().mHwcLayers.count(hwcId) > 0; 460 } 461 462 HWC2::Layer* getHwcLayer(int32_t hwcId) { 463 if (getBE().mHwcLayers.count(hwcId) == 0) { 464 return nullptr; 465 } 466 return getBE().mHwcLayers[hwcId].layer; 467 } 468 469 // ----------------------------------------------------------------------- 470 471 void clearWithOpenGL(const RenderArea& renderArea) const; 472 void setFiltering(bool filtering); 473 bool getFiltering() const; 474 475 476 inline const State& getDrawingState() const { return mDrawingState; } 477 inline const State& getCurrentState() const { return mCurrentState; } 478 inline State& getCurrentState() { return mCurrentState; } 479 480 LayerDebugInfo getLayerDebugInfo() const; 481 482 /* always call base class first */ 483 static void miniDumpHeader(String8& result); 484 void miniDump(String8& result, int32_t hwcId) const; 485 void dumpFrameStats(String8& result) const; 486 void dumpFrameEvents(String8& result); 487 void clearFrameStats(); 488 void logFrameStats(); 489 void getFrameStats(FrameStats* outStats) const; 490 491 virtual std::vector<OccupancyTracker::Segment> getOccupancyHistory(bool forceFlush) = 0; 492 493 void onDisconnect(); 494 void addAndGetFrameTimestamps(const NewFrameEventsEntry* newEntry, 495 FrameEventHistoryDelta* outDelta); 496 497 virtual bool getTransformToDisplayInverse() const = 0; 498 499 Transform getTransform() const; 500 501 // Returns the Alpha of the Surface, accounting for the Alpha 502 // of parent Surfaces in the hierarchy (alpha's will be multiplied 503 // down the hierarchy). 504 half getAlpha() const; 505 half4 getColor() const; 506 507 void traverseInReverseZOrder(LayerVector::StateSet stateSet, 508 const LayerVector::Visitor& visitor); 509 void traverseInZOrder(LayerVector::StateSet stateSet, const LayerVector::Visitor& visitor); 510 511 void traverseChildrenInZOrder(LayerVector::StateSet stateSet, 512 const LayerVector::Visitor& visitor); 513 514 size_t getChildrenCount() const; 515 void addChild(const sp<Layer>& layer); 516 // Returns index if removed, or negative value otherwise 517 // for symmetry with Vector::remove 518 ssize_t removeChild(const sp<Layer>& layer); 519 sp<Layer> getParent() const { return mCurrentParent.promote(); } 520 bool hasParent() const { return getParent() != nullptr; } 521 Rect computeScreenBounds(bool reduceTransparentRegion = true) const; 522 bool setChildLayer(const sp<Layer>& childLayer, int32_t z); 523 bool setChildRelativeLayer(const sp<Layer>& childLayer, 524 const sp<IBinder>& relativeToHandle, int32_t relativeZ); 525 526 // Copy the current list of children to the drawing state. Called by 527 // SurfaceFlinger to complete a transaction. 528 void commitChildList(); 529 int32_t getZ() const; 530 531protected: 532 // constant 533 sp<SurfaceFlinger> mFlinger; 534 /* 535 * Trivial class, used to ensure that mFlinger->onLayerDestroyed(mLayer) 536 * is called. 537 */ 538 class LayerCleaner { 539 sp<SurfaceFlinger> mFlinger; 540 wp<Layer> mLayer; 541 542 protected: 543 ~LayerCleaner() { 544 // destroy client resources 545 mFlinger->onLayerDestroyed(mLayer); 546 } 547 548 public: 549 LayerCleaner(const sp<SurfaceFlinger>& flinger, const sp<Layer>& layer) 550 : mFlinger(flinger), mLayer(layer) {} 551 }; 552 553 virtual void onFirstRef(); 554 555 friend class SurfaceInterceptor; 556 557 void commitTransaction(const State& stateToCommit); 558 559 uint32_t getEffectiveUsage(uint32_t usage) const; 560 561 FloatRect computeCrop(const sp<const DisplayDevice>& hw) const; 562 // Compute the initial crop as specified by parent layers and the 563 // SurfaceControl for this layer. Does not include buffer crop from the 564 // IGraphicBufferProducer client, as that should not affect child clipping. 565 // Returns in screen space. 566 Rect computeInitialCrop(const sp<const DisplayDevice>& hw) const; 567 568 // drawing 569 void clearWithOpenGL(const RenderArea& renderArea, float r, float g, float b, 570 float alpha) const; 571 572 void setParent(const sp<Layer>& layer); 573 574 LayerVector makeTraversalList(LayerVector::StateSet stateSet, bool* outSkipRelativeZUsers); 575 void addZOrderRelative(const wp<Layer>& relative); 576 void removeZOrderRelative(const wp<Layer>& relative); 577 578 class SyncPoint { 579 public: 580 explicit SyncPoint(uint64_t frameNumber) 581 : mFrameNumber(frameNumber), mFrameIsAvailable(false), mTransactionIsApplied(false) {} 582 583 uint64_t getFrameNumber() const { return mFrameNumber; } 584 585 bool frameIsAvailable() const { return mFrameIsAvailable; } 586 587 void setFrameAvailable() { mFrameIsAvailable = true; } 588 589 bool transactionIsApplied() const { return mTransactionIsApplied; } 590 591 void setTransactionApplied() { mTransactionIsApplied = true; } 592 593 private: 594 const uint64_t mFrameNumber; 595 std::atomic<bool> mFrameIsAvailable; 596 std::atomic<bool> mTransactionIsApplied; 597 }; 598 599 // SyncPoints which will be signaled when the correct frame is at the head 600 // of the queue and dropped after the frame has been latched. Protected by 601 // mLocalSyncPointMutex. 602 Mutex mLocalSyncPointMutex; 603 std::list<std::shared_ptr<SyncPoint>> mLocalSyncPoints; 604 605 // SyncPoints which will be signaled and then dropped when the transaction 606 // is applied 607 std::list<std::shared_ptr<SyncPoint>> mRemoteSyncPoints; 608 609 // Returns false if the relevant frame has already been latched 610 bool addSyncPoint(const std::shared_ptr<SyncPoint>& point); 611 612 void pushPendingState(); 613 void popPendingState(State* stateToCommit); 614 bool applyPendingStates(State* stateToCommit); 615 616 void clearSyncPoints(); 617 618 // Returns mCurrentScaling mode (originating from the 619 // Client) or mOverrideScalingMode mode (originating from 620 // the Surface Controller) if set. 621 virtual uint32_t getEffectiveScalingMode() const = 0; 622 623public: 624 /* 625 * The layer handle is just a BBinder object passed to the client 626 * (remote process) -- we don't keep any reference on our side such that 627 * the dtor is called when the remote side let go of its reference. 628 * 629 * LayerCleaner ensures that mFlinger->onLayerDestroyed() is called for 630 * this layer when the handle is destroyed. 631 */ 632 class Handle : public BBinder, public LayerCleaner { 633 public: 634 Handle(const sp<SurfaceFlinger>& flinger, const sp<Layer>& layer) 635 : LayerCleaner(flinger, layer), owner(layer) {} 636 637 wp<Layer> owner; 638 }; 639 640 sp<IBinder> getHandle(); 641 const String8& getName() const; 642 virtual void notifyAvailableFrames() = 0; 643 virtual PixelFormat getPixelFormat() const = 0; 644 bool getPremultipledAlpha() const; 645 646protected: 647 // ----------------------------------------------------------------------- 648 bool usingRelativeZ(LayerVector::StateSet stateSet); 649 650 bool mPremultipliedAlpha; 651 String8 mName; 652 String8 mTransactionName; // A cached version of "TX - " + mName for systraces 653 654 bool mPrimaryDisplayOnly = false; 655 656 // these are protected by an external lock 657 State mCurrentState; 658 State mDrawingState; 659 volatile int32_t mTransactionFlags; 660 661 // Accessed from main thread and binder threads 662 Mutex mPendingStateMutex; 663 Vector<State> mPendingStates; 664 665 // thread-safe 666 volatile int32_t mQueuedFrames; 667 volatile int32_t mSidebandStreamChanged; // used like an atomic boolean 668 669 // Timestamp history for UIAutomation. Thread safe. 670 FrameTracker mFrameTracker; 671 672 // Timestamp history for the consumer to query. 673 // Accessed by both consumer and producer on main and binder threads. 674 Mutex mFrameEventHistoryMutex; 675 ConsumerFrameEventHistory mFrameEventHistory; 676 FenceTimeline mAcquireTimeline; 677 FenceTimeline mReleaseTimeline; 678 679 // main thread 680 int mActiveBufferSlot; 681 sp<GraphicBuffer> mActiveBuffer; 682 sp<NativeHandle> mSidebandStream; 683 Rect mCurrentCrop; 684 uint32_t mCurrentTransform; 685 // We encode unset as -1. 686 int32_t mOverrideScalingMode; 687 bool mCurrentOpacity; 688 std::atomic<uint64_t> mCurrentFrameNumber; 689 bool mFrameLatencyNeeded; 690 // Whether filtering is forced on or not 691 bool mFiltering; 692 // Whether filtering is needed b/c of the drawingstate 693 bool mNeedsFiltering; 694 695 bool mPendingRemoval = false; 696 697 // page-flip thread (currently main thread) 698 bool mProtectedByApp; // application requires protected path to external sink 699 700 // protected by mLock 701 mutable Mutex mLock; 702 703 const wp<Client> mClientRef; 704 705 // This layer can be a cursor on some displays. 706 bool mPotentialCursor; 707 708 // Local copy of the queued contents of the incoming BufferQueue 709 mutable Mutex mQueueItemLock; 710 Condition mQueueItemCondition; 711 Vector<BufferItem> mQueueItems; 712 std::atomic<uint64_t> mLastFrameNumberReceived; 713 bool mAutoRefresh; 714 bool mFreezeGeometryUpdates; 715 716 // Child list about to be committed/used for editing. 717 LayerVector mCurrentChildren; 718 // Child list used for rendering. 719 LayerVector mDrawingChildren; 720 721 wp<Layer> mCurrentParent; 722 wp<Layer> mDrawingParent; 723 724 mutable LayerBE mBE; 725}; 726 727// --------------------------------------------------------------------------- 728 729}; // namespace android 730 731#endif // ANDROID_LAYER_H 732