2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_SURFACE_FLINGER_H
18 #define ANDROID_SURFACE_FLINGER_H
22 #include <sys/types.h>
27 * NOTE: Make sure this file doesn't include anything from <gl/ > or <gl2/ >
30 #include <cutils/compiler.h>
32 #include <utils/Atomic.h>
33 #include <utils/Errors.h>
34 #include <utils/KeyedVector.h>
35 #include <utils/RefBase.h>
36 #include <utils/SortedVector.h>
37 #include <utils/threads.h>
39 #include <ui/FenceTime.h>
40 #include <ui/PixelFormat.h>
41 #include <math/mat4.h>
43 #include <gui/FrameTimestamps.h>
44 #include <gui/ISurfaceComposer.h>
45 #include <gui/ISurfaceComposerClient.h>
46 #include <gui/OccupancyTracker.h>
48 #include <hardware/hwcomposer_defs.h>
50 #include <system/graphics.h>
52 #include <private/gui/LayerState.h>
55 #include "DisplayDevice.h"
57 #include "FrameTracker.h"
58 #include "LayerVector.h"
59 #include "MessageQueue.h"
60 #include "SurfaceInterceptor.h"
61 #include "StartPropertySetThread.h"
63 #include "DisplayHardware/HWComposer.h"
64 #include "Effects/Daltonizer.h"
74 // ---------------------------------------------------------------------------
77 class DisplayEventConnection;
83 class EventControlThread;
85 class InjectVSyncSource;
91 // ---------------------------------------------------------------------------
94 eTransactionNeeded = 0x01,
95 eTraversalNeeded = 0x02,
96 eDisplayTransactionNeeded = 0x04,
97 eTransactionMask = 0x07
100 class SurfaceFlinger : public BnSurfaceComposer,
101 private IBinder::DeathRecipient,
102 private HWComposer::EventHandler
106 // This is the phase offset in nanoseconds of the software vsync event
107 // relative to the vsync event reported by HWComposer. The software vsync
108 // event is when SurfaceFlinger and Choreographer-based applications run each
111 // This phase offset allows adjustment of the minimum latency from application
112 // wake-up time (by Choreographer) to the time at which the resulting window
113 // image is displayed. This value may be either positive (after the HW vsync)
114 // or negative (before the HW vsync). Setting it to 0 will result in a lower
115 // latency bound of two vsync periods because the app and SurfaceFlinger
116 // will run just after the HW vsync. Setting it to a positive number will
117 // result in the minimum latency being:
119 // (2 * VSYNC_PERIOD - (vsyncPhaseOffsetNs % VSYNC_PERIOD))
121 // Note that reducing this latency makes it more likely for the applications
122 // to not have their window content image ready in time. When this happens
123 // the latency will end up being an additional vsync period, and animations
124 // will hiccup. Therefore, this latency should be tuned somewhat
125 // conservatively (or at least with awareness of the trade-off being made).
126 static int64_t vsyncPhaseOffsetNs;
127 static int64_t sfVsyncPhaseOffsetNs;
129 // If fences from sync Framework are supported.
130 static bool hasSyncFramework;
132 // Instruct the Render Engine to use EGL_IMG_context_priority is available.
133 static bool useContextPriority;
135 // The offset in nanoseconds to use when DispSync timestamps present fence
137 static int64_t dispSyncPresentTimeOffset;
139 // Some hardware can do RGB->YUV conversion more efficiently in hardware
140 // controlled by HWC than in hardware controlled by the video encoder.
141 // This instruct VirtualDisplaySurface to use HWC for such conversion on
143 static bool useHwcForRgbToYuv;
145 // Maximum dimension supported by HWC for virtual display.
146 // Equal to min(max_height, max_width).
147 static uint64_t maxVirtualDisplaySize;
149 // Controls the number of buffers SurfaceFlinger will allocate for use in
150 // FramebufferSurface
151 static int64_t maxFrameBufferAcquiredBuffers;
153 // Indicate if platform supports color management on its
154 // wide-color display. This is typically found on devices
155 // with wide gamut (e.g. Display-P3) display.
156 // This also allows devices with wide-color displays that don't
157 // want to support color management to disable color management.
158 static bool hasWideColorDisplay;
160 static char const* getServiceName() ANDROID_API {
161 return "SurfaceFlinger";
164 SurfaceFlinger() ANDROID_API;
166 // must be called before clients can connect
167 void init() ANDROID_API;
169 // starts SurfaceFlinger main loop in the current thread
170 void run() ANDROID_API;
173 EVENT_VSYNC = HWC_EVENT_VSYNC
176 // post an asynchronous message to the main thread
177 status_t postMessageAsync(const sp<MessageBase>& msg, nsecs_t reltime = 0, uint32_t flags = 0);
179 // post a synchronous message to the main thread
180 status_t postMessageSync(const sp<MessageBase>& msg, nsecs_t reltime = 0, uint32_t flags = 0);
182 // force full composition on all displays
183 void repaintEverything();
185 // returns the default Display
186 sp<const DisplayDevice> getDefaultDisplayDevice() const {
187 Mutex::Autolock _l(mStateLock);
188 return getDefaultDisplayDeviceLocked();
191 // utility function to delete a texture on the main thread
192 void deleteTextureAsync(uint32_t texture);
194 // enable/disable h/w composer event
195 // TODO: this should be made accessible only to EventThread
197 void setVsyncEnabled(int disp, int enabled);
199 void eventControl(int disp, int event, int enabled);
202 // called on the main thread by MessageQueue when an internal message
204 // TODO: this should be made accessible only to MessageQueue
205 void onMessageReceived(int32_t what);
207 // for debugging only
208 // TODO: this should be made accessible only to HWComposer
209 const Vector< sp<Layer> >& getLayerSortedByZForHwcDisplay(int id);
211 RenderEngine& getRenderEngine() const {
212 return *mRenderEngine;
215 bool authenticateSurfaceTextureLocked(
216 const sp<IGraphicBufferProducer>& bufferProducer) const;
220 friend class DisplayEventConnection;
221 friend class EventThread;
223 friend class MonitoredProducer;
225 // This value is specified in number of frames. Log frame stats at most
227 enum { LOG_FRAME_STATS_PERIOD = 30*60*60 };
229 static const size_t MAX_LAYERS = 4096;
231 // We're reference counted, never destroy SurfaceFlinger directly
232 virtual ~SurfaceFlinger();
234 /* ------------------------------------------------------------------------
235 * Internal data structures
240 explicit State(LayerVector::StateSet set) : stateSet(set) {}
241 State& operator=(const State& other) {
242 // We explicitly don't copy stateSet so that, e.g., mDrawingState
243 // always uses the Drawing StateSet.
244 layersSortedByZ = other.layersSortedByZ;
245 displays = other.displays;
249 const LayerVector::StateSet stateSet = LayerVector::StateSet::Invalid;
250 LayerVector layersSortedByZ;
251 DefaultKeyedVector< wp<IBinder>, DisplayDeviceState> displays;
253 void traverseInZOrder(const LayerVector::Visitor& visitor) const;
254 void traverseInReverseZOrder(const LayerVector::Visitor& visitor) const;
257 /* ------------------------------------------------------------------------
260 virtual status_t onTransact(uint32_t code, const Parcel& data,
261 Parcel* reply, uint32_t flags);
262 virtual status_t dump(int fd, const Vector<String16>& args);
264 /* ------------------------------------------------------------------------
265 * ISurfaceComposer interface
267 virtual sp<ISurfaceComposerClient> createConnection();
268 virtual sp<ISurfaceComposerClient> createScopedConnection(const sp<IGraphicBufferProducer>& gbp);
269 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure);
270 virtual void destroyDisplay(const sp<IBinder>& display);
271 virtual sp<IBinder> getBuiltInDisplay(int32_t id);
272 virtual void setTransactionState(const Vector<ComposerState>& state,
273 const Vector<DisplayState>& displays, uint32_t flags);
274 virtual void bootFinished();
275 virtual bool authenticateSurfaceTexture(
276 const sp<IGraphicBufferProducer>& bufferProducer) const;
277 virtual status_t getSupportedFrameTimestamps(
278 std::vector<FrameEvent>* outSupported) const;
279 virtual sp<IDisplayEventConnection> createDisplayEventConnection(
280 ISurfaceComposer::VsyncSource vsyncSource = eVsyncSourceApp);
281 virtual status_t captureScreen(const sp<IBinder>& display,
282 const sp<IGraphicBufferProducer>& producer,
283 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
284 int32_t minLayerZ, int32_t maxLayerZ,
285 bool useIdentityTransform, ISurfaceComposer::Rotation rotation);
286 virtual status_t getDisplayStats(const sp<IBinder>& display,
287 DisplayStatInfo* stats);
288 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
289 Vector<DisplayInfo>* configs);
290 virtual int getActiveConfig(const sp<IBinder>& display);
291 virtual status_t getDisplayColorModes(const sp<IBinder>& display,
292 Vector<android_color_mode_t>* configs);
293 virtual android_color_mode_t getActiveColorMode(const sp<IBinder>& display);
294 virtual status_t setActiveColorMode(const sp<IBinder>& display, android_color_mode_t colorMode);
295 virtual void setPowerMode(const sp<IBinder>& display, int mode);
296 virtual status_t setActiveConfig(const sp<IBinder>& display, int id);
297 virtual status_t clearAnimationFrameStats();
298 virtual status_t getAnimationFrameStats(FrameStats* outStats) const;
299 virtual status_t getHdrCapabilities(const sp<IBinder>& display,
300 HdrCapabilities* outCapabilities) const;
301 virtual status_t enableVSyncInjections(bool enable);
302 virtual status_t injectVSync(nsecs_t when);
305 /* ------------------------------------------------------------------------
306 * DeathRecipient interface
308 virtual void binderDied(const wp<IBinder>& who);
310 /* ------------------------------------------------------------------------
313 virtual void onFirstRef();
315 /* ------------------------------------------------------------------------
316 * HWComposer::EventHandler interface
318 virtual void onVSyncReceived(HWComposer* composer, int type, nsecs_t timestamp);
319 virtual void onHotplugReceived(HWComposer* composer, int disp, bool connected);
320 virtual void onInvalidateReceived(HWComposer* composer);
322 /* ------------------------------------------------------------------------
326 void signalTransaction();
327 void signalLayerUpdate();
328 void signalRefresh();
330 // called on the main thread in response to initializeDisplays()
331 void onInitializeDisplays();
332 // called on the main thread in response to setActiveConfig()
333 void setActiveConfigInternal(const sp<DisplayDevice>& hw, int mode);
334 // called on the main thread in response to setPowerMode()
335 void setPowerModeInternal(const sp<DisplayDevice>& hw, int mode);
337 // Called on the main thread in response to setActiveColorMode()
338 void setActiveColorModeInternal(const sp<DisplayDevice>& hw, android_color_mode_t colorMode);
340 // Returns whether the transaction actually modified any state
341 bool handleMessageTransaction();
343 // Returns whether a new buffer has been latched (see handlePageFlip())
344 bool handleMessageInvalidate();
346 void handleMessageRefresh();
348 void handleTransaction(uint32_t transactionFlags);
349 void handleTransactionLocked(uint32_t transactionFlags);
351 void updateCursorAsync();
353 /* handlePageFlip - latch a new buffer if available and compute the dirty
354 * region. Returns whether a new buffer has been latched, i.e., whether it
355 * is necessary to perform a refresh during this vsync.
357 bool handlePageFlip();
359 /* ------------------------------------------------------------------------
362 uint32_t getTransactionFlags(uint32_t flags);
363 uint32_t peekTransactionFlags();
364 uint32_t setTransactionFlags(uint32_t flags);
365 void commitTransaction();
366 uint32_t setClientStateLocked(const sp<Client>& client, const layer_state_t& s);
367 uint32_t setDisplayStateLocked(const DisplayState& s);
369 /* ------------------------------------------------------------------------
372 status_t createLayer(const String8& name, const sp<Client>& client,
373 uint32_t w, uint32_t h, PixelFormat format, uint32_t flags,
374 uint32_t windowType, uint32_t ownerUid, sp<IBinder>* handle,
375 sp<IGraphicBufferProducer>* gbp, sp<Layer>* parent);
377 status_t createNormalLayer(const sp<Client>& client, const String8& name,
378 uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format,
379 sp<IBinder>* outHandle, sp<IGraphicBufferProducer>* outGbp,
380 sp<Layer>* outLayer);
382 status_t createDimLayer(const sp<Client>& client, const String8& name,
383 uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
384 sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer);
386 String8 getUniqueLayerName(const String8& name);
388 // called in response to the window-manager calling
389 // ISurfaceComposerClient::destroySurface()
390 status_t onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle);
392 // called when all clients have released all their references to
393 // this layer meaning it is entirely safe to destroy all
394 // resources associated to this layer.
395 status_t onLayerDestroyed(const wp<Layer>& layer);
397 // remove a layer from SurfaceFlinger immediately
398 status_t removeLayer(const sp<Layer>& layer, bool topLevelOnly = false);
400 // add a layer to SurfaceFlinger
401 status_t addClientLayer(const sp<Client>& client,
402 const sp<IBinder>& handle,
403 const sp<IGraphicBufferProducer>& gbc,
404 const sp<Layer>& lbc,
405 const sp<Layer>& parent);
407 /* ------------------------------------------------------------------------
408 * Boot animation, on/off animations and screen capture
411 void startBootAnim();
413 void renderScreenImplLocked(
414 const sp<const DisplayDevice>& hw,
415 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
416 int32_t minLayerZ, int32_t maxLayerZ,
417 bool yswap, bool useIdentityTransform, Transform::orientation_flags rotation);
420 status_t captureScreenImplLocked(const sp<const DisplayDevice>& device,
421 ANativeWindowBuffer* buffer, Rect sourceCrop,
422 uint32_t reqWidth, uint32_t reqHeight, int32_t minLayerZ,
423 int32_t maxLayerZ, bool useIdentityTransform,
424 Transform::orientation_flags rotation, bool isLocalScreenshot,
427 status_t captureScreenImplLocked(
428 const sp<const DisplayDevice>& hw,
429 const sp<IGraphicBufferProducer>& producer,
430 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
431 int32_t minLayerZ, int32_t maxLayerZ,
432 bool useIdentityTransform, Transform::orientation_flags rotation,
433 bool isLocalScreenshot);
436 sp<StartPropertySetThread> mStartPropertySetThread = nullptr;
438 /* ------------------------------------------------------------------------
441 void readPersistentProperties();
443 /* ------------------------------------------------------------------------
446 size_t getMaxTextureSize() const;
447 size_t getMaxViewportDims() const;
449 /* ------------------------------------------------------------------------
450 * Display and layer stack management
452 // called when starting, or restarting after system_server death
453 void initializeDisplays();
455 // Create an IBinder for a builtin display and add it to current state
456 void createBuiltinDisplayLocked(DisplayDevice::DisplayType type);
459 sp<const DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) const {
460 Mutex::Autolock _l(mStateLock);
461 return getDisplayDeviceLocked(dpy);
464 sp<DisplayDevice> getDisplayDevice(const wp<IBinder>& dpy) {
465 Mutex::Autolock _l(mStateLock);
466 return getDisplayDeviceLocked(dpy);
469 // NOTE: can only be called from the main thread or with mStateLock held
470 sp<const DisplayDevice> getDisplayDeviceLocked(const wp<IBinder>& dpy) const {
471 return mDisplays.valueFor(dpy);
474 // NOTE: can only be called from the main thread or with mStateLock held
475 sp<DisplayDevice> getDisplayDeviceLocked(const wp<IBinder>& dpy) {
476 return mDisplays.valueFor(dpy);
479 sp<const DisplayDevice> getDefaultDisplayDeviceLocked() const {
480 return getDisplayDeviceLocked(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]);
483 void createDefaultDisplayDevice();
485 int32_t getDisplayType(const sp<IBinder>& display) {
486 if (!display.get()) return NAME_NOT_FOUND;
487 for (int i = 0; i < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES; ++i) {
488 if (display == mBuiltinDisplays[i]) {
492 return NAME_NOT_FOUND;
495 // mark a region of a layer stack dirty. this updates the dirty
496 // region of all screens presenting this layer stack.
497 void invalidateLayerStack(uint32_t layerStack, const Region& dirty);
500 int32_t allocateHwcDisplayId(DisplayDevice::DisplayType type);
503 /* ------------------------------------------------------------------------
507 HWComposer& getHwComposer() const { return *mHwc; }
509 /* ------------------------------------------------------------------------
512 void invalidateHwcGeometry();
513 void computeVisibleRegions(uint32_t layerStack,
514 Region& dirtyRegion, Region& opaqueRegion);
516 void preComposition(nsecs_t refreshStartTime);
517 void postComposition(nsecs_t refreshStartTime);
518 void updateCompositorTiming(
519 nsecs_t vsyncPhase, nsecs_t vsyncInterval, nsecs_t compositeTime,
520 std::shared_ptr<FenceTime>& presentFenceTime);
521 void setCompositorTimingSnapped(
522 nsecs_t vsyncPhase, nsecs_t vsyncInterval,
523 nsecs_t compositeToPresentLatency);
524 void rebuildLayerStacks();
526 // Given a dataSpace, returns the appropriate color_mode to use
527 // to display that dataSpace.
528 android_color_mode pickColorMode(android_dataspace dataSpace) const;
529 android_dataspace bestTargetDataSpace(android_dataspace a, android_dataspace b) const;
531 mat4 computeSaturationMatrix() const;
533 void setUpHWComposer();
534 void doComposition();
535 void doDebugFlashRegions();
536 void doDisplayComposition(const sp<const DisplayDevice>& displayDevice, const Region& dirtyRegion);
538 // compose surfaces for display hw. this fails if using GL and the surface
539 // has been destroyed and is no longer valid.
540 bool doComposeSurfaces(const sp<const DisplayDevice>& displayDevice, const Region& dirty);
542 void postFramebuffer();
543 void drawWormhole(const sp<const DisplayDevice>& displayDevice, const Region& region) const;
545 /* ------------------------------------------------------------------------
549 /* ------------------------------------------------------------------------
552 void enableHardwareVsync();
553 void resyncToHardwareVsync(bool makeAvailable);
554 void disableHardwareVsync(bool makeUnavailable);
557 void resyncWithRateLimit();
558 void getCompositorTiming(CompositorTiming* compositorTiming);
561 /* ------------------------------------------------------------------------
562 * Debugging & dumpsys
564 void listLayersLocked(const Vector<String16>& args, size_t& index, String8& result) const;
565 void dumpStatsLocked(const Vector<String16>& args, size_t& index, String8& result) const;
566 void clearStatsLocked(const Vector<String16>& args, size_t& index, String8& result);
567 void dumpAllLocked(const Vector<String16>& args, size_t& index, String8& result) const;
568 bool startDdmConnection();
569 void appendSfConfigString(String8& result) const;
570 void checkScreenshot(size_t w, size_t s, size_t h, void const* vaddr,
571 const sp<const DisplayDevice>& hw,
572 int32_t minLayerZ, int32_t maxLayerZ);
574 void logFrameStats();
576 void dumpStaticScreenStats(String8& result) const;
577 // Not const because each Layer needs to query Fences and cache timestamps.
578 void dumpFrameEventsLocked(String8& result);
580 void recordBufferingStats(const char* layerName,
581 std::vector<OccupancyTracker::Segment>&& history);
582 void dumpBufferingStats(String8& result) const;
583 void dumpWideColorInfo(String8& result) const;
585 bool isLayerTripleBufferingDisabled() const {
586 return this->mLayerTripleBufferingDisabled;
590 /* ------------------------------------------------------------------------
594 void clearHwcLayers(const T& layers) {
595 for (size_t i = 0; i < layers.size(); ++i) {
596 layers[i]->clearHwcLayers();
599 void resetHwcLocked();
601 // Check to see if we should handoff to vr flinger.
602 void updateVrFlinger();
605 /* ------------------------------------------------------------------------
609 // access must be protected by mStateLock
610 mutable Mutex mStateLock;
611 State mCurrentState{LayerVector::StateSet::Current};
612 volatile int32_t mTransactionFlags;
613 Condition mTransactionCV;
614 bool mTransactionPending;
615 bool mAnimTransactionPending;
616 SortedVector< sp<Layer> > mLayersPendingRemoval;
617 SortedVector< wp<IBinder> > mGraphicBufferProducerList;
619 // protected by mStateLock (but we could use another lock)
623 // access must be protected by mInvalidateLock
624 volatile int32_t mRepaintEverything;
626 // current, real and vr hardware composers.
629 HWComposer* mRealHwc;
632 // constant members (no synchronization needed for access)
633 RenderEngine* mRenderEngine;
635 bool mGpuToCpuSupported;
636 sp<EventThread> mEventThread;
637 sp<EventThread> mSFEventThread;
638 sp<EventThread> mInjectorEventThread;
639 sp<InjectVSyncSource> mVSyncInjector;
640 sp<EventControlThread> mEventControlThread;
641 EGLContext mEGLContext;
642 EGLDisplay mEGLDisplay;
643 sp<IBinder> mBuiltinDisplays[DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES];
646 std::unique_ptr<dvr::VrFlinger> mVrFlinger;
649 // Can only accessed from the main thread, these members
650 // don't need synchronization
651 State mDrawingState{LayerVector::StateSet::Drawing};
652 bool mVisibleRegionsDirty;
654 bool mHwWorkListDirty;
656 bool mGeometryInvalid;
658 bool mAnimCompositionPending;
660 std::vector<sp<Layer>> mLayersWithQueuedFrames;
661 sp<Fence> mPreviousPresentFence = Fence::NO_FENCE;
662 bool mHadClientComposition = false;
664 FenceTimeline mGlCompositionDoneTimeline;
665 FenceTimeline mDisplayTimeline;
667 // this may only be written from the main thread with mStateLock held
668 // it may be read from other threads with mStateLock held
669 DefaultKeyedVector< wp<IBinder>, sp<DisplayDevice> > mDisplays;
671 // don't use a lock for these, we don't care
674 int mDebugDisableHWC;
675 int mDebugDisableTransformHint;
676 volatile nsecs_t mDebugInSwapBuffers;
677 nsecs_t mLastSwapBufferTime;
678 volatile nsecs_t mDebugInTransaction;
679 nsecs_t mLastTransactionTime;
681 bool mForceFullDamage;
683 bool mPropagateBackpressure = true;
685 SurfaceInterceptor mInterceptor;
686 bool mUseHwcVirtualDisplays = false;
688 // Restrict layers to use two buffers in their bufferqueues.
689 bool mLayerTripleBufferingDisabled = false;
691 // these are thread safe
692 mutable MessageQueue mEventQueue;
693 FrameTracker mAnimFrameTracker;
694 DispSync mPrimaryDispSync;
696 // protected by mDestroyedLayerLock;
697 mutable Mutex mDestroyedLayerLock;
698 Vector<Layer const *> mDestroyedLayers;
700 // protected by mHWVsyncLock
702 bool mPrimaryHWVsyncEnabled;
703 bool mHWVsyncAvailable;
705 // protected by mCompositorTimingLock;
706 mutable std::mutex mCompositorTimingLock;
707 CompositorTiming mCompositorTiming;
709 // Only accessed from the main thread.
710 struct CompositePresentTime {
711 nsecs_t composite { -1 };
712 std::shared_ptr<FenceTime> display { FenceTime::NO_FENCE };
714 std::queue<CompositePresentTime> mCompositePresentTimes;
716 std::atomic<bool> mRefreshPending{false};
718 /* ------------------------------------------------------------------------
719 * Feature prototyping
724 Daltonizer mDaltonizer;
729 mat4 mPreviousColorMatrix;
731 bool mHasColorMatrix;
733 // Static screen stats
735 static const size_t NUM_BUCKETS = 8; // < 1-7, 7+
736 nsecs_t mFrameBuckets[NUM_BUCKETS];
738 std::atomic<nsecs_t> mLastSwapTime;
742 // Double- vs. triple-buffering stats
743 struct BufferingStats {
748 doubleBufferedTime(0),
749 tripleBufferedTime(0) {}
754 // "Two buffer" means that a third buffer was never used, whereas
755 // "double-buffered" means that on average the segment only used two
756 // buffers (though it may have used a third for some part of the
758 nsecs_t twoBufferTime;
759 nsecs_t doubleBufferedTime;
760 nsecs_t tripleBufferedTime;
762 mutable Mutex mBufferingStatsMutex;
763 std::unordered_map<std::string, BufferingStats> mBufferingStats;
765 // Verify that transaction is being called by an approved process:
766 // either AID_GRAPHICS or AID_SYSTEM.
767 status_t CheckTransactCodeCredentials(uint32_t code);
770 std::atomic<bool> mVrFlingerRequestsDisplay;
771 static bool useVrFlinger;
774 float mSaturation = 1.0f;
776 }; // namespace android
778 #endif // ANDROID_SURFACE_FLINGER_H