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