Layer.h revision 6f65f3e7caab86a76419e7c1d1c787634a0852d8
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_LAYER_H 18#define ANDROID_LAYER_H 19 20#include <stdint.h> 21#include <sys/types.h> 22 23#include <EGL/egl.h> 24#include <EGL/eglext.h> 25 26#include <utils/RefBase.h> 27#include <utils/String8.h> 28#include <utils/Timers.h> 29 30#include <ui/FrameStats.h> 31#include <ui/GraphicBuffer.h> 32#include <ui/PixelFormat.h> 33#include <ui/Region.h> 34 35#include <gui/ISurfaceComposerClient.h> 36#include <gui/LayerState.h> 37 38#include <list> 39 40#include "Client.h" 41#include "FrameTracker.h" 42#include "LayerVector.h" 43#include "MonitoredProducer.h" 44#include "SurfaceFlinger.h" 45#include "Transform.h" 46 47#include <layerproto/LayerProtoHeader.h> 48#include "DisplayHardware/HWComposer.h" 49#include "DisplayHardware/HWComposerBufferCache.h" 50#include "RenderArea.h" 51#include "RenderEngine/Mesh.h" 52#include "RenderEngine/Texture.h" 53 54#include <math/vec4.h> 55 56using namespace android::surfaceflinger; 57 58namespace android { 59 60// --------------------------------------------------------------------------- 61 62class Client; 63class Colorizer; 64class DisplayDevice; 65class GraphicBuffer; 66class SurfaceFlinger; 67class LayerDebugInfo; 68class LayerBE; 69 70// --------------------------------------------------------------------------- 71 72class LayerBE { 73public: 74 LayerBE(); 75 76 sp<NativeHandle> mSidebandStream; 77 78 // The mesh used to draw the layer in GLES composition mode 79 Mesh mMesh; 80 81 // HWC items, accessed from the main thread 82 struct HWCInfo { 83 HWCInfo() 84 : hwc(nullptr), 85 layer(nullptr), 86 forceClientComposition(false), 87 compositionType(HWC2::Composition::Invalid), 88 clearClientTarget(false) {} 89 90 HWComposer* hwc; 91 HWC2::Layer* layer; 92 bool forceClientComposition; 93 HWC2::Composition compositionType; 94 bool clearClientTarget; 95 Rect displayFrame; 96 FloatRect sourceCrop; 97 HWComposerBufferCache bufferCache; 98 }; 99 100 // A layer can be attached to multiple displays when operating in mirror mode 101 // (a.k.a: when several displays are attached with equal layerStack). In this 102 // case we need to keep track. In non-mirror mode, a layer will have only one 103 // HWCInfo. This map key is a display layerStack. 104 std::unordered_map<int32_t, HWCInfo> mHwcLayers; 105}; 106 107class Layer : public virtual RefBase { 108 static int32_t sSequence; 109 110public: 111 LayerBE& getBE() { return mBE; } 112 LayerBE& getBE() const { return mBE; } 113 mutable bool contentDirty; 114 // regions below are in window-manager space 115 Region visibleRegion; 116 Region coveredRegion; 117 Region visibleNonTransparentRegion; 118 Region surfaceDamageRegion; 119 120 // Layer serial number. This gives layers an explicit ordering, so we 121 // have a stable sort order when their layer stack and Z-order are 122 // the same. 123 int32_t sequence; 124 125 enum { // flags for doTransaction() 126 eDontUpdateGeometryState = 0x00000001, 127 eVisibleRegion = 0x00000002, 128 }; 129 130 struct Geometry { 131 uint32_t w; 132 uint32_t h; 133 Transform transform; 134 135 inline bool operator==(const Geometry& rhs) const { 136 return (w == rhs.w && h == rhs.h) && (transform.tx() == rhs.transform.tx()) && 137 (transform.ty() == rhs.transform.ty()); 138 } 139 inline bool operator!=(const Geometry& rhs) const { return !operator==(rhs); } 140 }; 141 142 struct State { 143 Geometry active; 144 Geometry requested; 145 int32_t z; 146 147 // The identifier of the layer stack this layer belongs to. A layer can 148 // only be associated to a single layer stack. A layer stack is a 149 // z-ordered group of layers which can be associated to one or more 150 // displays. Using the same layer stack on different displays is a way 151 // to achieve mirroring. 152 uint32_t layerStack; 153 154 uint8_t flags; 155 uint8_t mask; 156 uint8_t reserved[2]; 157 int32_t sequence; // changes when visible regions can change 158 bool modified; 159 160 // Crop is expressed in layer space coordinate. 161 Rect crop; 162 Rect requestedCrop; 163 164 // finalCrop is expressed in display space coordinate. 165 Rect finalCrop; 166 Rect requestedFinalCrop; 167 168 // If set, defers this state update until the identified Layer 169 // receives a frame with the given frameNumber 170 wp<Layer> barrierLayer; 171 uint64_t frameNumber; 172 173 // the transparentRegion hint is a bit special, it's latched only 174 // when we receive a buffer -- this is because it's "content" 175 // dependent. 176 Region activeTransparentRegion; 177 Region requestedTransparentRegion; 178 android_dataspace dataSpace; 179 180 uint32_t appId; 181 uint32_t type; 182 183 // If non-null, a Surface this Surface's Z-order is interpreted relative to. 184 wp<Layer> zOrderRelativeOf; 185 186 // A list of surfaces whose Z-order is interpreted relative to ours. 187 SortedVector<wp<Layer>> zOrderRelatives; 188 189 half4 color; 190 }; 191 192 Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name, uint32_t w, 193 uint32_t h, uint32_t flags); 194 virtual ~Layer(); 195 196 void setPrimaryDisplayOnly() { mPrimaryDisplayOnly = true; } 197 198 // ------------------------------------------------------------------------ 199 // Geometry setting functions. 200 // 201 // The following group of functions are used to specify the layers 202 // bounds, and the mapping of the texture on to those bounds. According 203 // to various settings changes to them may apply immediately, or be delayed until 204 // a pending resize is completed by the producer submitting a buffer. For example 205 // if we were to change the buffer size, and update the matrix ahead of the 206 // new buffer arriving, then we would be stretching the buffer to a different 207 // aspect before and after the buffer arriving, which probably isn't what we wanted. 208 // 209 // The first set of geometry functions are controlled by the scaling mode, described 210 // in window.h. The scaling mode may be set by the client, as it submits buffers. 211 // This value may be overriden through SurfaceControl, with setOverrideScalingMode. 212 // 213 // Put simply, if our scaling mode is SCALING_MODE_FREEZE, then 214 // matrix updates will not be applied while a resize is pending 215 // and the size and transform will remain in their previous state 216 // until a new buffer is submitted. If the scaling mode is another value 217 // then the old-buffer will immediately be scaled to the pending size 218 // and the new matrix will be immediately applied following this scaling 219 // transformation. 220 221 // Set the default buffer size for the assosciated Producer, in pixels. This is 222 // also the rendered size of the layer prior to any transformations. Parent 223 // or local matrix transformations will not affect the size of the buffer, 224 // but may affect it's on-screen size or clipping. 225 bool setSize(uint32_t w, uint32_t h); 226 // Set a 2x2 transformation matrix on the layer. This transform 227 // will be applied after parent transforms, but before any final 228 // producer specified transform. 229 bool setMatrix(const layer_state_t::matrix22_t& matrix); 230 231 // This second set of geometry attributes are controlled by 232 // setGeometryAppliesWithResize, and their default mode is to be 233 // immediate. If setGeometryAppliesWithResize is specified 234 // while a resize is pending, then update of these attributes will 235 // be delayed until the resize completes. 236 237 // setPosition operates in parent buffer space (pre parent-transform) or display 238 // space for top-level layers. 239 bool setPosition(float x, float y, bool immediate); 240 // Buffer space 241 bool setCrop(const Rect& crop, bool immediate); 242 // Parent buffer space/display space 243 bool setFinalCrop(const Rect& crop, bool immediate); 244 245 // TODO(b/38182121): Could we eliminate the various latching modes by 246 // using the layer hierarchy? 247 // ----------------------------------------------------------------------- 248 bool setLayer(int32_t z); 249 bool setRelativeLayer(const sp<IBinder>& relativeToHandle, int32_t relativeZ); 250 251 bool setAlpha(float alpha); 252 bool setColor(const half3& color); 253 bool setTransparentRegionHint(const Region& transparent); 254 bool setFlags(uint8_t flags, uint8_t mask); 255 bool setLayerStack(uint32_t layerStack); 256 bool setDataSpace(android_dataspace dataSpace); 257 android_dataspace getDataSpace() const; 258 uint32_t getLayerStack() const; 259 void deferTransactionUntil(const sp<IBinder>& barrierHandle, uint64_t frameNumber); 260 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 // only for debugging 476 inline const sp<GraphicBuffer>& getActiveBuffer() const { return mActiveBuffer; } 477 478 inline const State& getDrawingState() const { return mDrawingState; } 479 inline const State& getCurrentState() const { return mCurrentState; } 480 inline State& getCurrentState() { return mCurrentState; } 481 482 LayerDebugInfo getLayerDebugInfo() const; 483 484 /* always call base class first */ 485 static void miniDumpHeader(String8& result); 486 void miniDump(String8& result, int32_t hwcId) const; 487 void dumpFrameStats(String8& result) const; 488 void dumpFrameEvents(String8& result); 489 void clearFrameStats(); 490 void logFrameStats(); 491 void getFrameStats(FrameStats* outStats) const; 492 493 virtual std::vector<OccupancyTracker::Segment> getOccupancyHistory(bool forceFlush) = 0; 494 495 void onDisconnect(); 496 void addAndGetFrameTimestamps(const NewFrameEventsEntry* newEntry, 497 FrameEventHistoryDelta* outDelta); 498 499 virtual bool getTransformToDisplayInverse() const = 0; 500 501 Transform getTransform() const; 502 503 // Returns the Alpha of the Surface, accounting for the Alpha 504 // of parent Surfaces in the hierarchy (alpha's will be multiplied 505 // down the hierarchy). 506 half getAlpha() const; 507 half4 getColor() const; 508 509 void traverseInReverseZOrder(LayerVector::StateSet stateSet, 510 const LayerVector::Visitor& visitor); 511 void traverseInZOrder(LayerVector::StateSet stateSet, const LayerVector::Visitor& visitor); 512 513 void traverseChildrenInZOrder(LayerVector::StateSet stateSet, 514 const LayerVector::Visitor& visitor); 515 516 size_t getChildrenCount() const; 517 void addChild(const sp<Layer>& layer); 518 // Returns index if removed, or negative value otherwise 519 // for symmetry with Vector::remove 520 ssize_t removeChild(const sp<Layer>& layer); 521 sp<Layer> getParent() const { return mCurrentParent.promote(); } 522 bool hasParent() const { return getParent() != nullptr; } 523 Rect computeScreenBounds(bool reduceTransparentRegion = true) const; 524 bool setChildLayer(const sp<Layer>& childLayer, int32_t z); 525 bool setChildRelativeLayer(const sp<Layer>& childLayer, 526 const sp<IBinder>& relativeToHandle, int32_t relativeZ); 527 528 // Copy the current list of children to the drawing state. Called by 529 // SurfaceFlinger to complete a transaction. 530 void commitChildList(); 531 int32_t getZ() const; 532 533protected: 534 // constant 535 sp<SurfaceFlinger> mFlinger; 536 /* 537 * Trivial class, used to ensure that mFlinger->onLayerDestroyed(mLayer) 538 * is called. 539 */ 540 class LayerCleaner { 541 sp<SurfaceFlinger> mFlinger; 542 wp<Layer> mLayer; 543 544 protected: 545 ~LayerCleaner() { 546 // destroy client resources 547 mFlinger->onLayerDestroyed(mLayer); 548 } 549 550 public: 551 LayerCleaner(const sp<SurfaceFlinger>& flinger, const sp<Layer>& layer) 552 : mFlinger(flinger), mLayer(layer) {} 553 }; 554 555 virtual void onFirstRef(); 556 557 friend class SurfaceInterceptor; 558 559 void commitTransaction(const State& stateToCommit); 560 561 uint32_t getEffectiveUsage(uint32_t usage) const; 562 563 FloatRect computeCrop(const sp<const DisplayDevice>& hw) const; 564 // Compute the initial crop as specified by parent layers and the 565 // SurfaceControl for this layer. Does not include buffer crop from the 566 // IGraphicBufferProducer client, as that should not affect child clipping. 567 // Returns in screen space. 568 Rect computeInitialCrop(const sp<const DisplayDevice>& hw) const; 569 570 // drawing 571 void clearWithOpenGL(const RenderArea& renderArea, float r, float g, float b, 572 float alpha) const; 573 574 void setParent(const sp<Layer>& layer); 575 576 LayerVector makeTraversalList(LayerVector::StateSet stateSet); 577 void addZOrderRelative(const wp<Layer>& relative); 578 void removeZOrderRelative(const wp<Layer>& relative); 579 580 class SyncPoint { 581 public: 582 explicit SyncPoint(uint64_t frameNumber) 583 : mFrameNumber(frameNumber), mFrameIsAvailable(false), mTransactionIsApplied(false) {} 584 585 uint64_t getFrameNumber() const { return mFrameNumber; } 586 587 bool frameIsAvailable() const { return mFrameIsAvailable; } 588 589 void setFrameAvailable() { mFrameIsAvailable = true; } 590 591 bool transactionIsApplied() const { return mTransactionIsApplied; } 592 593 void setTransactionApplied() { mTransactionIsApplied = true; } 594 595 private: 596 const uint64_t mFrameNumber; 597 std::atomic<bool> mFrameIsAvailable; 598 std::atomic<bool> mTransactionIsApplied; 599 }; 600 601 // SyncPoints which will be signaled when the correct frame is at the head 602 // of the queue and dropped after the frame has been latched. Protected by 603 // mLocalSyncPointMutex. 604 Mutex mLocalSyncPointMutex; 605 std::list<std::shared_ptr<SyncPoint>> mLocalSyncPoints; 606 607 // SyncPoints which will be signaled and then dropped when the transaction 608 // is applied 609 std::list<std::shared_ptr<SyncPoint>> mRemoteSyncPoints; 610 611 // Returns false if the relevant frame has already been latched 612 bool addSyncPoint(const std::shared_ptr<SyncPoint>& point); 613 614 void pushPendingState(); 615 void popPendingState(State* stateToCommit); 616 bool applyPendingStates(State* stateToCommit); 617 618 void clearSyncPoints(); 619 620 // Returns mCurrentScaling mode (originating from the 621 // Client) or mOverrideScalingMode mode (originating from 622 // the Surface Controller) if set. 623 virtual uint32_t getEffectiveScalingMode() const = 0; 624 625public: 626 /* 627 * The layer handle is just a BBinder object passed to the client 628 * (remote process) -- we don't keep any reference on our side such that 629 * the dtor is called when the remote side let go of its reference. 630 * 631 * LayerCleaner ensures that mFlinger->onLayerDestroyed() is called for 632 * this layer when the handle is destroyed. 633 */ 634 class Handle : public BBinder, public LayerCleaner { 635 public: 636 Handle(const sp<SurfaceFlinger>& flinger, const sp<Layer>& layer) 637 : LayerCleaner(flinger, layer), owner(layer) {} 638 639 wp<Layer> owner; 640 }; 641 642 sp<IBinder> getHandle(); 643 const String8& getName() const; 644 virtual void notifyAvailableFrames() = 0; 645 virtual PixelFormat getPixelFormat() const = 0; 646 bool getPremultipledAlpha() const; 647 648protected: 649 // ----------------------------------------------------------------------- 650 651 bool mPremultipliedAlpha; 652 String8 mName; 653 String8 mTransactionName; // A cached version of "TX - " + mName for systraces 654 655 bool mPrimaryDisplayOnly = false; 656 657 // these are protected by an external lock 658 State mCurrentState; 659 State mDrawingState; 660 volatile int32_t mTransactionFlags; 661 662 // Accessed from main thread and binder threads 663 Mutex mPendingStateMutex; 664 Vector<State> mPendingStates; 665 666 // thread-safe 667 volatile int32_t mQueuedFrames; 668 volatile int32_t mSidebandStreamChanged; // used like an atomic boolean 669 670 // Timestamp history for UIAutomation. Thread safe. 671 FrameTracker mFrameTracker; 672 673 // Timestamp history for the consumer to query. 674 // Accessed by both consumer and producer on main and binder threads. 675 Mutex mFrameEventHistoryMutex; 676 ConsumerFrameEventHistory mFrameEventHistory; 677 FenceTimeline mAcquireTimeline; 678 FenceTimeline mReleaseTimeline; 679 680 // main thread 681 int mActiveBufferSlot; 682 sp<GraphicBuffer> mActiveBuffer; 683 sp<NativeHandle> mSidebandStream; 684 Rect mCurrentCrop; 685 uint32_t mCurrentTransform; 686 // We encode unset as -1. 687 int32_t mOverrideScalingMode; 688 bool mCurrentOpacity; 689 std::atomic<uint64_t> mCurrentFrameNumber; 690 bool mFrameLatencyNeeded; 691 // Whether filtering is forced on or not 692 bool mFiltering; 693 // Whether filtering is needed b/c of the drawingstate 694 bool mNeedsFiltering; 695 696 bool mPendingRemoval = false; 697 698 // page-flip thread (currently main thread) 699 bool mProtectedByApp; // application requires protected path to external sink 700 701 // protected by mLock 702 mutable Mutex mLock; 703 704 const wp<Client> mClientRef; 705 706 // This layer can be a cursor on some displays. 707 bool mPotentialCursor; 708 709 // Local copy of the queued contents of the incoming BufferQueue 710 mutable Mutex mQueueItemLock; 711 Condition mQueueItemCondition; 712 Vector<BufferItem> mQueueItems; 713 std::atomic<uint64_t> mLastFrameNumberReceived; 714 bool mAutoRefresh; 715 bool mFreezeGeometryUpdates; 716 717 // Child list about to be committed/used for editing. 718 LayerVector mCurrentChildren; 719 // Child list used for rendering. 720 LayerVector mDrawingChildren; 721 722 wp<Layer> mCurrentParent; 723 wp<Layer> mDrawingParent; 724 725 mutable LayerBE mBE; 726}; 727 728// --------------------------------------------------------------------------- 729 730}; // namespace android 731 732#endif // ANDROID_LAYER_H 733