Advertisement
gimmeitorilltell

Untitled

Apr 22nd, 2017
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.46 KB | None | 0 0
  1. /*
  2. * Copyright (C) 2007 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. #ifndef ANDROID_SURFACE_FLINGER_H
  18. #define ANDROID_SURFACE_FLINGER_H
  19.  
  20. #include <stdint.h>
  21. #include <sys/types.h>
  22.  
  23. #include <EGL/egl.h>
  24.  
  25. /*
  26. * NOTE: Make sure this file doesn't include anything from <gl/ > or <gl2/ >
  27. */
  28.  
  29. #include <cutils/compiler.h>
  30.  
  31. #include <utils/Atomic.h>
  32. #include <utils/Errors.h>
  33. #include <utils/KeyedVector.h>
  34. #include <utils/RefBase.h>
  35. #include <utils/SortedVector.h>
  36. #include <utils/threads.h>
  37.  
  38. #include <binder/IMemory.h>
  39.  
  40. #include <ui/PixelFormat.h>
  41. #include <ui/mat4.h>
  42.  
  43. #include <gui/ISurfaceComposer.h>
  44. #include <gui/ISurfaceComposerClient.h>
  45. #include <gui/OccupancyTracker.h>
  46.  
  47. #include <hardware/hwcomposer_defs.h>
  48.  
  49. #include <system/graphics.h>
  50.  
  51. #include <private/gui/LayerState.h>
  52.  
  53. #include "Barrier.h"
  54. #include "DisplayDevice.h"
  55. #include "DispSync.h"
  56. #include "FenceTracker.h"
  57. #include "FrameTracker.h"
  58. #include "MessageQueue.h"
  59.  
  60. #include "DisplayHardware/HWComposer.h"
  61. #include "Effects/Daltonizer.h"
  62.  
  63. #include "FrameRateHelper.h"
  64.  
  65. #include <map>
  66. #include <string>
  67.  
  68. namespace android {
  69.  
  70. // ---------------------------------------------------------------------------
  71.  
  72. class Client;
  73. class DisplayEventConnection;
  74. class EventThread;
  75. class IGraphicBufferAlloc;
  76. class Layer;
  77. class LayerDim;
  78. class LayerBlur;
  79. class Surface;
  80. class RenderEngine;
  81. class EventControlThread;
  82.  
  83. // ---------------------------------------------------------------------------
  84.  
  85. enum {
  86. eTransactionNeeded = 0x01,
  87. eTraversalNeeded = 0x02,
  88. eDisplayTransactionNeeded = 0x04,
  89. eTransactionMask = 0x07
  90. };
  91.  
  92. class SurfaceFlinger : public BnSurfaceComposer,
  93. private IBinder::DeathRecipient,
  94. private HWComposer::EventHandler
  95. {
  96. public:
  97. #ifdef QTI_BSP
  98. friend class ExSurfaceFlinger;
  99. #endif
  100.  
  101. static char const* getServiceName() ANDROID_API {
  102. return "SurfaceFlinger";
  103. }
  104.  
  105. SurfaceFlinger() ANDROID_API;
  106.  
  107. // must be called before clients can connect
  108. void init() ANDROID_API;
  109.  
  110. // starts SurfaceFlinger main loop in the current thread
  111. void run() ANDROID_API;
  112.  
  113. enum {
  114. EVENT_VSYNC = HWC_EVENT_VSYNC
  115. };
  116.  
  117. // post an asynchronous message to the main thread
  118. status_t postMessageAsync(const sp<MessageBase>& msg, nsecs_t reltime = 0, uint32_t flags = 0);
  119.  
  120. // post a synchronous message to the main thread
  121. status_t postMessageSync(const sp<MessageBase>& msg, nsecs_t reltime = 0, uint32_t flags = 0);
  122.  
  123. // force full composition on all displays
  124. void repaintEverything();
  125.  
  126. // returns the default Display
  127. sp<const DisplayDevice> getDefaultDisplayDevice() const {
  128. return getDisplayDevice(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]);
  129. }
  130.  
  131. // utility function to delete a texture on the main thread
  132. void deleteTextureAsync(uint32_t texture);
  133.  
  134. // enable/disable h/w composer event
  135. // TODO: this should be made accessible only to EventThread
  136. #ifdef USE_HWC2
  137. void setVsyncEnabled(int disp, int enabled);
  138. #else
  139. void eventControl(int disp, int event, int enabled);
  140. #endif
  141.  
  142. // called on the main thread by MessageQueue when an internal message
  143. // is received
  144. // TODO: this should be made accessible only to MessageQueue
  145. void onMessageReceived(int32_t what);
  146.  
  147. // for debugging only
  148. // TODO: this should be made accessible only to HWComposer
  149. const Vector< sp<Layer> >& getLayerSortedByZForHwcDisplay(int id);
  150.  
  151. RenderEngine& getRenderEngine() const {
  152. return *mRenderEngine;
  153. }
  154.  
  155. private:
  156. friend class Client;
  157. friend class DisplayEventConnection;
  158. friend class Layer;
  159. friend class LayerDim;
  160. friend class MonitoredProducer;
  161. friend class LayerBlur;
  162.  
  163. // This value is specified in number of frames. Log frame stats at most
  164. // every half hour.
  165. enum { LOG_FRAME_STATS_PERIOD = 30*60*60 };
  166.  
  167. static const size_t MAX_LAYERS = 4096;
  168.  
  169. // We're reference counted, never destroy SurfaceFlinger directly
  170. virtual ~SurfaceFlinger();
  171.  
  172. /* ------------------------------------------------------------------------
  173. * Internal data structures
  174. */
  175.  
  176. class LayerVector : public SortedVector< sp<Layer> > {
  177. public:
  178. LayerVector();
  179. LayerVector(const LayerVector& rhs);
  180. virtual int do_compare(const void* lhs, const void* rhs) const;
  181. };
  182.  
  183. struct DisplayDeviceState {
  184. DisplayDeviceState();
  185. DisplayDeviceState(DisplayDevice::DisplayType type, bool isSecure);
  186. bool isValid() const { return type >= 0; }
  187. bool isMainDisplay() const { return type == DisplayDevice::DISPLAY_PRIMARY; }
  188. bool isVirtualDisplay() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }
  189. DisplayDevice::DisplayType type;
  190. sp<IGraphicBufferProducer> surface;
  191. uint32_t layerStack;
  192. Rect viewport;
  193. Rect frame;
  194. uint8_t orientation;
  195. uint32_t width, height;
  196. String8 displayName;
  197. bool isSecure;
  198. };
  199.  
  200. struct State {
  201. LayerVector layersSortedByZ;
  202. DefaultKeyedVector< wp<IBinder>, DisplayDeviceState> displays;
  203. };
  204.  
  205. /* ------------------------------------------------------------------------
  206. * IBinder interface
  207. */
  208. virtual status_t onTransact(uint32_t code, const Parcel& data,
  209. Parcel* reply, uint32_t flags);
  210. virtual status_t dump(int fd, const Vector<String16>& args);
  211.  
  212. /* ------------------------------------------------------------------------
  213. * ISurfaceComposer interface
  214. */
  215. virtual sp<ISurfaceComposerClient> createConnection();
  216. virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
  217. virtual sp<IBinder> createDisplay(const String8& displayName, bool secure);
  218. virtual void destroyDisplay(const sp<IBinder>& display);
  219. virtual sp<IBinder> getBuiltInDisplay(int32_t id);
  220. virtual void setTransactionState(const Vector<ComposerState>& state,
  221. const Vector<DisplayState>& displays, uint32_t flags);
  222. virtual void bootFinished();
  223. virtual bool authenticateSurfaceTexture(
  224. const sp<IGraphicBufferProducer>& bufferProducer) const;
  225. virtual sp<IDisplayEventConnection> createDisplayEventConnection();
  226. virtual status_t captureScreen(const sp<IBinder>& display,
  227. const sp<IGraphicBufferProducer>& producer,
  228. Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
  229. uint32_t minLayerZ, uint32_t maxLayerZ,
  230. bool useIdentityTransform, ISurfaceComposer::Rotation rotation,
  231. bool isCpuConsumer);
  232. virtual status_t getDisplayStats(const sp<IBinder>& display,
  233. DisplayStatInfo* stats);
  234. virtual status_t getDisplayConfigs(const sp<IBinder>& display,
  235. Vector<DisplayInfo>* configs);
  236. virtual int getActiveConfig(const sp<IBinder>& display);
  237. virtual status_t getDisplayColorModes(const sp<IBinder>& display,
  238. Vector<android_color_mode_t>* configs);
  239. virtual android_color_mode_t getActiveColorMode(const sp<IBinder>& display);
  240. virtual status_t setActiveColorMode(const sp<IBinder>& display, android_color_mode_t colorMode);
  241. virtual void setPowerMode(const sp<IBinder>& display, int mode);
  242. virtual status_t setActiveConfig(const sp<IBinder>& display, int id);
  243. virtual status_t clearAnimationFrameStats();
  244. virtual status_t getAnimationFrameStats(FrameStats* outStats) const;
  245. virtual status_t getHdrCapabilities(const sp<IBinder>& display,
  246. HdrCapabilities* outCapabilities) const;
  247.  
  248. /* ------------------------------------------------------------------------
  249. * DeathRecipient interface
  250. */
  251. virtual void binderDied(const wp<IBinder>& who);
  252.  
  253. /* ------------------------------------------------------------------------
  254. * RefBase interface
  255. */
  256. virtual void onFirstRef();
  257.  
  258. /* ------------------------------------------------------------------------
  259. * HWComposer::EventHandler interface
  260. */
  261. virtual void onVSyncReceived(int type, nsecs_t timestamp);
  262. virtual void onHotplugReceived(int disp, bool connected);
  263.  
  264. /* ------------------------------------------------------------------------
  265. * Extensions
  266. */
  267. virtual void updateExtendedMode() { }
  268.  
  269. virtual void getIndexLOI(size_t /*dpy*/,
  270. const LayerVector& /*currentLayers*/,
  271. bool& /*bIgnoreLayers*/,
  272. int& /*indexLOI*/) { }
  273.  
  274. #ifndef USE_HWC2
  275. virtual bool updateLayerVisibleNonTransparentRegion(
  276. const int& dpy, const sp<Layer>& layer,
  277. bool& bIgnoreLayers, int& indexLOI,
  278. uint32_t layerStack, const int& i);
  279.  
  280. virtual void delayDPTransactionIfNeeded(
  281. const Vector<DisplayState>& /*displays*/) { }
  282.  
  283. virtual bool canDrawLayerinScreenShot(
  284. const sp<const DisplayDevice>& hw,
  285. const sp<Layer>& layer);
  286.  
  287. virtual void isfreezeSurfacePresent(
  288. bool& freezeSurfacePresent,
  289. const sp<const DisplayDevice>& /*hw*/,
  290. const int32_t& /*id*/) { freezeSurfacePresent = false; }
  291.  
  292. virtual void setOrientationEventControl(
  293. bool& /*freezeSurfacePresent*/,
  294. const int32_t& /*id*/) { }
  295.  
  296. virtual void updateVisibleRegionsDirty() { }
  297.  
  298. virtual void drawWormHoleIfRequired(HWComposer::LayerListIterator &cur,
  299. const HWComposer::LayerListIterator &end,
  300. const sp<const DisplayDevice>& hw,
  301. const Region& region);
  302. #endif
  303. virtual bool isS3DLayerPresent(const sp<const DisplayDevice>& /*hw*/)
  304. { return false; };
  305. /* ------------------------------------------------------------------------
  306. * Message handling
  307. */
  308. void waitForEvent();
  309. void signalTransaction();
  310. void signalLayerUpdate();
  311. void signalRefresh();
  312.  
  313. // called on the main thread in response to initializeDisplays()
  314. void onInitializeDisplays();
  315. // called on the main thread in response to setActiveConfig()
  316. void setActiveConfigInternal(const sp<DisplayDevice>& hw, int mode);
  317. // called on the main thread in response to setPowerMode()
  318. void setPowerModeInternal(const sp<DisplayDevice>& hw, int mode);
  319.  
  320. // Called on the main thread in response to setActiveColorMode()
  321. void setActiveColorModeInternal(const sp<DisplayDevice>& hw, android_color_mode_t colorMode);
  322.  
  323. // Returns whether the transaction actually modified any state
  324. bool handleMessageTransaction();
  325.  
  326. // Returns whether a new buffer has been latched (see handlePageFlip())
  327. bool handleMessageInvalidate();
  328.  
  329. void handleMessageRefresh();
  330.  
  331. void handleTransaction(uint32_t transactionFlags);
  332. void handleTransactionLocked(uint32_t transactionFlags);
  333.  
  334. void updateCursorAsync();
  335.  
  336. /* handlePageFlip - latch a new buffer if available and compute the dirty
  337. * region. Returns whether a new buffer has been latched, i.e., whether it
  338. * is necessary to perform a refresh during this vsync.
  339. */
  340. bool handlePageFlip();
  341.  
  342. /* ------------------------------------------------------------------------
  343. * Transactions
  344. */
  345. uint32_t getTransactionFlags(uint32_t flags);
  346. uint32_t peekTransactionFlags(uint32_t flags);
  347. uint32_t setTransactionFlags(uint32_t flags);
  348. void commitTransaction();
  349. uint32_t setClientStateLocked(const sp<Client>& client, const layer_state_t& s);
  350. uint32_t setDisplayStateLocked(const DisplayState& s);
  351.  
  352. /* ------------------------------------------------------------------------
  353. * Layer management
  354. */
  355. status_t createLayer(const String8& name, const sp<Client>& client,
  356. uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
  357. sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp);
  358.  
  359. status_t createNormalLayer(const sp<Client>& client, const String8& name,
  360. uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format,
  361. sp<IBinder>* outHandle, sp<IGraphicBufferProducer>* outGbp,
  362. sp<Layer>* outLayer);
  363.  
  364. status_t createDimLayer(const sp<Client>& client, const String8& name,
  365. uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
  366. sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer);
  367.  
  368. status_t createBlurLayer(const sp<Client>& client, const String8& name,
  369. uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
  370. sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer);
  371.  
  372. // called in response to the window-manager calling
  373. // ISurfaceComposerClient::destroySurface()
  374. status_t onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle);
  375.  
  376. // called when all clients have released all their references to
  377. // this layer meaning it is entirely safe to destroy all
  378. // resources associated to this layer.
  379. status_t onLayerDestroyed(const wp<Layer>& layer);
  380.  
  381. // remove a layer from SurfaceFlinger immediately
  382. status_t removeLayer(const wp<Layer>& layer);
  383.  
  384. // add a layer to SurfaceFlinger
  385. status_t addClientLayer(const sp<Client>& client,
  386. const sp<IBinder>& handle,
  387. const sp<IGraphicBufferProducer>& gbc,
  388. const sp<Layer>& lbc);
  389.  
  390. /* ------------------------------------------------------------------------
  391. * Boot animation, on/off animations and screen capture
  392. */
  393.  
  394. void startBootAnim();
  395.  
  396. void renderScreenImplLocked(
  397. const sp<const DisplayDevice>& hw,
  398. Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
  399. uint32_t minLayerZ, uint32_t maxLayerZ,
  400. bool yswap, bool useIdentityTransform, Transform::orientation_flags rotation);
  401.  
  402. status_t captureScreenImplLocked(
  403. const sp<const DisplayDevice>& hw,
  404. const sp<IGraphicBufferProducer>& producer,
  405. Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
  406. uint32_t minLayerZ, uint32_t maxLayerZ,
  407. bool useIdentityTransform, Transform::orientation_flags rotation,
  408. bool isLocalScreenshot, bool useReadPixels);
  409.  
  410. /* ------------------------------------------------------------------------
  411. * EGL
  412. */
  413. size_t getMaxTextureSize() const;
  414. size_t getMaxViewportDims() const;
  415.  
  416. /* ------------------------------------------------------------------------
  417. * Display and layer stack management
  418. */
  419. // called when starting, or restarting after system_server death
  420. void initializeDisplays();
  421.  
  422. // Create an IBinder for a builtin display and add it to current state
  423. void createBuiltinDisplayLocked(DisplayDevice::DisplayType type);
  424.  
  425. // NOTE: can only be called from the main thread or with mStateLock held
  426. sp<const DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) const {
  427. return mDisplays.valueFor(dpy);
  428. }
  429.  
  430. // NOTE: can only be called from the main thread or with mStateLock held
  431. sp<DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) {
  432. return mDisplays.valueFor(dpy);
  433. }
  434.  
  435. int32_t getDisplayType(const sp<IBinder>& display) {
  436. if (!display.get()) return NAME_NOT_FOUND;
  437. for (int i = 0; i < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES; ++i) {
  438. if (display == mBuiltinDisplays[i]) {
  439. return i;
  440. }
  441. }
  442. return NAME_NOT_FOUND;
  443. }
  444.  
  445. // mark a region of a layer stack dirty. this updates the dirty
  446. // region of all screens presenting this layer stack.
  447. void invalidateLayerStack(uint32_t layerStack, const Region& dirty);
  448.  
  449. #ifndef USE_HWC2
  450. int32_t allocateHwcDisplayId(DisplayDevice::DisplayType type);
  451. #endif
  452.  
  453. /* ------------------------------------------------------------------------
  454. * H/W composer
  455. */
  456.  
  457. HWComposer& getHwComposer() const { return *mHwc; }
  458.  
  459. /* ------------------------------------------------------------------------
  460. * Compositing
  461. */
  462. void invalidateHwcGeometry();
  463. void computeVisibleRegions(size_t dpy,
  464. const LayerVector& currentLayers, uint32_t layerStack,
  465. Region& dirtyRegion, Region& opaqueRegion);
  466.  
  467. void preComposition();
  468. void postComposition(nsecs_t refreshStartTime);
  469. void rebuildLayerStacks();
  470. void setUpHWComposer();
  471. void doComposition();
  472. void doDebugFlashRegions();
  473. void doDisplayComposition(const sp<const DisplayDevice>& hw, const Region& dirtyRegion);
  474.  
  475. // compose surfaces for display hw. this fails if using GL and the surface
  476. // has been destroyed and is no longer valid.
  477. bool doComposeSurfaces(const sp<const DisplayDevice>& hw, const Region& dirty);
  478.  
  479. void postFramebuffer();
  480. void drawWormhole(const sp<const DisplayDevice>& hw, const Region& region) const;
  481.  
  482. /* ------------------------------------------------------------------------
  483. * Display management
  484. */
  485.  
  486. /* ------------------------------------------------------------------------
  487. * VSync
  488. */
  489. void enableHardwareVsync();
  490. void resyncToHardwareVsync(bool makeAvailable);
  491. void disableHardwareVsync(bool makeUnavailable);
  492. public:
  493. void resyncWithRateLimit();
  494. private:
  495.  
  496. /* ------------------------------------------------------------------------
  497. * Debugging & dumpsys
  498. */
  499. void listLayersLocked(const Vector<String16>& args, size_t& index, String8& result) const;
  500. void dumpStatsLocked(const Vector<String16>& args, size_t& index, String8& result) const;
  501. void clearStatsLocked(const Vector<String16>& args, size_t& index, String8& result);
  502. void dumpAllLocked(const Vector<String16>& args, size_t& index, String8& result) const;
  503. bool startDdmConnection();
  504. static void appendSfConfigString(String8& result);
  505. void checkScreenshot(size_t w, size_t s, size_t h, void const* vaddr,
  506. const sp<const DisplayDevice>& hw,
  507. uint32_t minLayerZ, uint32_t maxLayerZ);
  508.  
  509. void logFrameStats();
  510.  
  511. void dumpStaticScreenStats(String8& result) const;
  512. virtual void dumpDrawCycle(bool /* prePrepare */ ) { }
  513.  
  514. void recordBufferingStats(const char* layerName,
  515. std::vector<OccupancyTracker::Segment>&& history);
  516. void dumpBufferingStats(String8& result) const;
  517.  
  518. bool getFrameTimestamps(const Layer& layer, uint64_t frameNumber,
  519. FrameTimestamps* outTimestamps);
  520.  
  521. /* ------------------------------------------------------------------------
  522. * Attributes
  523. */
  524.  
  525. // access must be protected by mStateLock
  526. mutable Mutex mStateLock;
  527. State mCurrentState;
  528. volatile int32_t mTransactionFlags;
  529. Condition mTransactionCV;
  530. bool mTransactionPending;
  531. bool mAnimTransactionPending;
  532. Vector< sp<Layer> > mLayersPendingRemoval;
  533. SortedVector< wp<IBinder> > mGraphicBufferProducerList;
  534.  
  535. // protected by mStateLock (but we could use another lock)
  536. bool mLayersRemoved;
  537.  
  538. // access must be protected by mInvalidateLock
  539. volatile int32_t mRepaintEverything;
  540.  
  541. // constant members (no synchronization needed for access)
  542. HWComposer* mHwc;
  543. RenderEngine* mRenderEngine;
  544. nsecs_t mBootTime;
  545. bool mGpuToCpuSupported;
  546. sp<EventThread> mEventThread;
  547. sp<EventThread> mSFEventThread;
  548. sp<EventControlThread> mEventControlThread;
  549. EGLContext mEGLContext;
  550. EGLDisplay mEGLDisplay;
  551. sp<IBinder> mBuiltinDisplays[DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES];
  552.  
  553. // Can only accessed from the main thread, these members
  554. // don't need synchronization
  555. State mDrawingState;
  556. bool mVisibleRegionsDirty;
  557. #ifndef USE_HWC2
  558. bool mHwWorkListDirty;
  559. #else
  560. bool mGeometryInvalid;
  561. #endif
  562. bool mAnimCompositionPending;
  563. #ifdef USE_HWC2
  564. std::vector<sp<Layer>> mLayersWithQueuedFrames;
  565. sp<Fence> mPreviousPresentFence = Fence::NO_FENCE;
  566. bool mHadClientComposition = false;
  567. #endif
  568.  
  569. // this may only be written from the main thread with mStateLock held
  570. // it may be read from other threads with mStateLock held
  571. DefaultKeyedVector< wp<IBinder>, sp<DisplayDevice> > mDisplays;
  572.  
  573. // don't use a lock for these, we don't care
  574. int mDebugRegion;
  575. int mDebugDDMS;
  576. int mDebugDisableHWC;
  577. int mDebugDisableTransformHint;
  578. volatile nsecs_t mDebugInSwapBuffers;
  579. nsecs_t mLastSwapBufferTime;
  580. volatile nsecs_t mDebugInTransaction;
  581. nsecs_t mLastTransactionTime;
  582. bool mBootFinished;
  583. bool mForceFullDamage;
  584. FenceTracker mFenceTracker;
  585. #ifdef USE_HWC2
  586. bool mPropagateBackpressure = true;
  587. #endif
  588. bool mUseHwcVirtualDisplays = true;
  589.  
  590. // these are thread safe
  591. mutable MessageQueue mEventQueue;
  592. FrameTracker mAnimFrameTracker;
  593. DispSync mPrimaryDispSync;
  594.  
  595. // protected by mDestroyedLayerLock;
  596. mutable Mutex mDestroyedLayerLock;
  597. Vector<Layer const *> mDestroyedLayers;
  598.  
  599. // protected by mHWVsyncLock
  600. Mutex mHWVsyncLock;
  601. bool mPrimaryHWVsyncEnabled;
  602. bool mHWVsyncAvailable;
  603.  
  604. /* ------------------------------------------------------------------------
  605. * Feature prototyping
  606. */
  607.  
  608. Daltonizer mDaltonizer;
  609. #ifndef USE_HWC2
  610. bool mDaltonize;
  611. #endif
  612.  
  613. mat4 mPreviousColorMatrix;
  614. mat4 mColorMatrix;
  615. bool mHasColorMatrix;
  616.  
  617. mat4 mSecondaryColorMatrix;
  618. bool mHasSecondaryColorMatrix;
  619.  
  620. // Static screen stats
  621. bool mHasPoweredOff;
  622. static const size_t NUM_BUCKETS = 8; // < 1-7, 7+
  623. nsecs_t mFrameBuckets[NUM_BUCKETS];
  624. nsecs_t mTotalTime;
  625. std::atomic<nsecs_t> mLastSwapTime;
  626.  
  627. FrameRateHelper mFrameRateHelper;
  628.  
  629. /*
  630. * A number that increases on every new frame composition and screen capture.
  631. * LayerBlur can speed up it's drawing by caching texture using this variable
  632. * if multiple LayerBlur objects draw in one frame composition.
  633. * In case of display mirroring, this variable should be increased on every display.
  634. */
  635. uint32_t mActiveFrameSequence;
  636.  
  637. // Double- vs. triple-buffering stats
  638. struct BufferingStats {
  639. BufferingStats()
  640. : numSegments(0),
  641. totalTime(0),
  642. twoBufferTime(0),
  643. doubleBufferedTime(0),
  644. tripleBufferedTime(0) {}
  645.  
  646. size_t numSegments;
  647. nsecs_t totalTime;
  648.  
  649. // "Two buffer" means that a third buffer was never used, whereas
  650. // "double-buffered" means that on average the segment only used two
  651. // buffers (though it may have used a third for some part of the
  652. // segment)
  653. nsecs_t twoBufferTime;
  654. nsecs_t doubleBufferedTime;
  655. nsecs_t tripleBufferedTime;
  656. };
  657. mutable Mutex mBufferingStatsMutex;
  658. std::unordered_map<std::string, BufferingStats> mBufferingStats;
  659. };
  660.  
  661. }; // namespace android
  662.  
  663. #endif // ANDROID_SURFACE_FLINGER_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement