#include "Barrier.h"
#include "DisplayDevice.h"
#include "DispSync.h"
+#include "FenceTracker.h"
#include "FrameTracker.h"
#include "MessageQueue.h"
#include "DisplayHardware/HWComposer.h"
#include "Effects/Daltonizer.h"
+#include "FrameRateHelper.h"
+
namespace android {
// ---------------------------------------------------------------------------
class IGraphicBufferAlloc;
class Layer;
class LayerDim;
+class LayerBlur;
class Surface;
class RenderEngine;
class EventControlThread;
private HWComposer::EventHandler
{
public:
+#ifdef QTI_BSP
+ friend class ExSurfaceFlinger;
+#endif
+
static char const* getServiceName() ANDROID_API {
return "SurfaceFlinger";
}
// enable/disable h/w composer event
// TODO: this should be made accessible only to EventThread
+#ifdef USE_HWC2
+ void setVsyncEnabled(int disp, int enabled);
+#else
void eventControl(int disp, int event, int enabled);
+#endif
// called on the main thread by MessageQueue when an internal message
// is received
friend class Client;
friend class DisplayEventConnection;
friend class Layer;
+ friend class LayerDim;
friend class MonitoredProducer;
+ friend class LayerBlur;
// This value is specified in number of frames. Log frame stats at most
// every half hour.
struct DisplayDeviceState {
DisplayDeviceState();
- DisplayDeviceState(DisplayDevice::DisplayType type);
+ DisplayDeviceState(DisplayDevice::DisplayType type, bool isSecure);
bool isValid() const { return type >= 0; }
bool isMainDisplay() const { return type == DisplayDevice::DISPLAY_PRIMARY; }
bool isVirtualDisplay() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }
const sp<IGraphicBufferProducer>& producer,
Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ,
- bool useIdentityTransform, ISurfaceComposer::Rotation rotation);
+ bool useIdentityTransform, ISurfaceComposer::Rotation rotation,
+ bool isCpuConsumer);
virtual status_t getDisplayStats(const sp<IBinder>& display,
DisplayStatInfo* stats);
virtual status_t getDisplayConfigs(const sp<IBinder>& display,
virtual status_t setActiveConfig(const sp<IBinder>& display, int id);
virtual status_t clearAnimationFrameStats();
virtual status_t getAnimationFrameStats(FrameStats* outStats) const;
+ virtual status_t getHdrCapabilities(const sp<IBinder>& display,
+ HdrCapabilities* outCapabilities) const;
/* ------------------------------------------------------------------------
* DeathRecipient interface
virtual void onHotplugReceived(int disp, bool connected);
/* ------------------------------------------------------------------------
+ * Extensions
+ */
+ virtual void updateExtendedMode() { }
+
+ virtual void getIndexLOI(size_t /*dpy*/,
+ const LayerVector& /*currentLayers*/,
+ bool& /*bIgnoreLayers*/,
+ int& /*indexLOI*/) { }
+
+ virtual bool updateLayerVisibleNonTransparentRegion(
+ const int& dpy, const sp<Layer>& layer,
+ bool& bIgnoreLayers, int& indexLOI,
+ uint32_t layerStack, const int& i);
+
+ virtual void delayDPTransactionIfNeeded(
+ const Vector<DisplayState>& /*displays*/) { }
+
+ virtual bool canDrawLayerinScreenShot(
+ const sp<const DisplayDevice>& hw,
+ const sp<Layer>& layer);
+
+ virtual void isfreezeSurfacePresent(
+ bool& freezeSurfacePresent,
+ const sp<const DisplayDevice>& /*hw*/,
+ const int32_t& /*id*/) { freezeSurfacePresent = false; }
+
+ virtual void setOrientationEventControl(
+ bool& /*freezeSurfacePresent*/,
+ const int32_t& /*id*/) { }
+
+ virtual void updateVisibleRegionsDirty() { }
+ virtual void drawWormHoleIfRequired(HWComposer::LayerListIterator &cur,
+ const HWComposer::LayerListIterator &end,
+ const sp<const DisplayDevice>& hw,
+ const Region& region);
+ /* ------------------------------------------------------------------------
* Message handling
*/
void waitForEvent();
uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer);
+ status_t createBlurLayer(const sp<Client>& client, const String8& name,
+ uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
+ sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer);
+
// called in response to the window-manager calling
// ISurfaceComposerClient::destroySurface()
status_t onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle);
const sp<IGraphicBufferProducer>& producer,
Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ,
- bool useIdentityTransform, Transform::orientation_flags rotation);
+ bool useIdentityTransform, Transform::orientation_flags rotation,
+ bool isLocalScreenshot, bool useReadPixels);
/* ------------------------------------------------------------------------
* EGL
// region of all screens presenting this layer stack.
void invalidateLayerStack(uint32_t layerStack, const Region& dirty);
- // allocate a h/w composer display id
+#ifndef USE_HWC2
int32_t allocateHwcDisplayId(DisplayDevice::DisplayType type);
+#endif
/* ------------------------------------------------------------------------
* H/W composer
* Compositing
*/
void invalidateHwcGeometry();
- static void computeVisibleRegions(
+ void computeVisibleRegions(size_t dpy,
const LayerVector& currentLayers, uint32_t layerStack,
Region& dirtyRegion, Region& opaqueRegion);
void preComposition();
- void postComposition();
+ void postComposition(nsecs_t refreshStartTime);
void rebuildLayerStacks();
void setUpHWComposer();
void doComposition();
* VSync
*/
void enableHardwareVsync();
- void disableHardwareVsync(bool makeUnavailable);
void resyncToHardwareVsync(bool makeAvailable);
+ void disableHardwareVsync(bool makeUnavailable);
+public:
+ void resyncWithRateLimit();
+private:
/* ------------------------------------------------------------------------
* Debugging & dumpsys
void logFrameStats();
void dumpStaticScreenStats(String8& result) const;
+ virtual void dumpDrawCycle(bool /* prePrepare */ ) { }
/* ------------------------------------------------------------------------
* Attributes
// don't need synchronization
State mDrawingState;
bool mVisibleRegionsDirty;
+#ifndef USE_HWC2
bool mHwWorkListDirty;
+#else
+ bool mGeometryInvalid;
+#endif
bool mAnimCompositionPending;
+#ifdef USE_HWC2
+ std::vector<sp<Layer>> mLayersWithQueuedFrames;
+#endif
// this may only be written from the main thread with mStateLock held
// it may be read from other threads with mStateLock held
nsecs_t mLastTransactionTime;
bool mBootFinished;
bool mForceFullDamage;
+ FenceTracker mFenceTracker;
// these are thread safe
mutable MessageQueue mEventQueue;
mat4 mColorMatrix;
bool mHasColorMatrix;
+ mat4 mSecondaryColorMatrix;
+ bool mHasSecondaryColorMatrix;
+
// Static screen stats
bool mHasPoweredOff;
static const size_t NUM_BUCKETS = 8; // < 1-7, 7+
nsecs_t mFrameBuckets[NUM_BUCKETS];
nsecs_t mTotalTime;
- nsecs_t mLastSwapTime;
+ std::atomic<nsecs_t> mLastSwapTime;
+
+ FrameRateHelper mFrameRateHelper;
+
+ /*
+ * A number that increases on every new frame composition and screen capture.
+ * LayerBlur can speed up it's drawing by caching texture using this variable
+ * if multiple LayerBlur objects draw in one frame composition.
+ * In case of display mirroring, this variable should be increased on every display.
+ */
+ uint32_t mActiveFrameSequence;
+
};
}; // namespace android