LCOV - code coverage report
Current view: top level - gfx/layers - Compositor.h (source / functions) Hit Total Coverage
Test: output.info Lines: 15 54 27.8 %
Date: 2017-07-14 16:53:18 Functions: 8 29 27.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2             : * This Source Code Form is subject to the terms of the Mozilla Public
       3             : * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef MOZILLA_GFX_COMPOSITOR_H
       7             : #define MOZILLA_GFX_COMPOSITOR_H
       8             : 
       9             : #include "Units.h"                      // for ScreenPoint
      10             : #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
      11             : #include "mozilla/RefPtr.h"             // for already_AddRefed, RefCounted
      12             : #include "mozilla/gfx/2D.h"             // for DrawTarget
      13             : #include "mozilla/gfx/MatrixFwd.h"      // for Matrix, Matrix4x4
      14             : #include "mozilla/gfx/Point.h"          // for IntSize, Point
      15             : #include "mozilla/gfx/Polygon.h"        // for Polygon
      16             : #include "mozilla/gfx/Rect.h"           // for Rect, IntRect
      17             : #include "mozilla/gfx/Types.h"          // for Float
      18             : #include "mozilla/gfx/Triangle.h"       // for Triangle, TexturedTriangle
      19             : #include "mozilla/layers/CompositorTypes.h"  // for DiagnosticTypes, etc
      20             : #include "mozilla/layers/LayersTypes.h"  // for LayersBackend
      21             : #include "mozilla/layers/TextureSourceProvider.h"
      22             : #include "mozilla/widget/CompositorWidget.h"
      23             : #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
      24             : #include "nsRegion.h"
      25             : #include <vector>
      26             : #include "mozilla/WidgetUtils.h"
      27             : 
      28             : /**
      29             :  * Different elements of a web pages are rendered into separate "layers" before
      30             :  * they are flattened into the final image that is brought to the screen.
      31             :  * See Layers.h for more informations about layers and why we use retained
      32             :  * structures.
      33             :  * Most of the documentation for layers is directly in the source code in the
      34             :  * form of doc comments. An overview can also be found in the the wiki:
      35             :  * https://wiki.mozilla.org/Gecko:Overview#Graphics
      36             :  *
      37             :  *
      38             :  * # Main interfaces and abstractions
      39             :  *
      40             :  *  - Layer, ShadowableLayer and LayerComposite
      41             :  *    (see Layers.h and ipc/ShadowLayers.h)
      42             :  *  - CompositableClient and CompositableHost
      43             :  *    (client/CompositableClient.h composite/CompositableHost.h)
      44             :  *  - TextureClient and TextureHost
      45             :  *    (client/TextureClient.h composite/TextureHost.h)
      46             :  *  - TextureSource
      47             :  *    (composite/TextureHost.h)
      48             :  *  - Forwarders
      49             :  *    (ipc/CompositableForwarder.h ipc/ShadowLayers.h)
      50             :  *  - Compositor
      51             :  *    (this file)
      52             :  *  - IPDL protocols
      53             :  *    (.ipdl files under the gfx/layers/ipc directory)
      54             :  *
      55             :  * The *Client and Shadowable* classes are always used on the content thread.
      56             :  * Forwarders are always used on the content thread.
      57             :  * The *Host and Shadow* classes are always used on the compositor thread.
      58             :  * Compositors, TextureSource, and Effects are always used on the compositor
      59             :  * thread.
      60             :  * Most enums and constants are declared in LayersTypes.h and CompositorTypes.h.
      61             :  *
      62             :  *
      63             :  * # Texture transfer
      64             :  *
      65             :  * Most layer classes own a Compositable plus some extra information like
      66             :  * transforms and clip rects. They are platform independent.
      67             :  * Compositable classes manipulate Texture objects and are reponsible for
      68             :  * things like tiling, buffer rotation or double buffering. Compositables
      69             :  * are also platform-independent. Examples of compositable classes are:
      70             :  *  - ImageClient
      71             :  *  - CanvasClient
      72             :  *  - ContentHost
      73             :  *  - etc.
      74             :  * Texture classes (TextureClient and TextureHost) are thin abstractions over
      75             :  * platform-dependent texture memory. They are maniplulated by compositables
      76             :  * and don't know about buffer rotations and such. The purposes of TextureClient
      77             :  * and TextureHost are to synchronize, serialize and deserialize texture data.
      78             :  * TextureHosts provide access to TextureSources that are views on the
      79             :  * Texture data providing the necessary api for Compositor backend to composite
      80             :  * them.
      81             :  *
      82             :  * Compositable and Texture clients and hosts are created using factory methods.
      83             :  * They should only be created by using their constructor in exceptional
      84             :  * circumstances. The factory methods are located:
      85             :  *    TextureClient       - CompositableClient::CreateTextureClient
      86             :  *    TextureHost         - TextureHost::CreateTextureHost, which calls a
      87             :  *                          platform-specific function, e.g., CreateTextureHostOGL
      88             :  *    CompositableClient  - in the appropriate subclass, e.g.,
      89             :  *                          CanvasClient::CreateCanvasClient
      90             :  *    CompositableHost    - CompositableHost::Create
      91             :  *
      92             :  *
      93             :  * # IPDL
      94             :  *
      95             :  * If off-main-thread compositing (OMTC) is enabled, compositing is performed
      96             :  * in a dedicated thread. In some setups compositing happens in a dedicated
      97             :  * process. Documentation may refer to either the compositor thread or the
      98             :  * compositor process.
      99             :  * See explanations in ShadowLayers.h.
     100             :  *
     101             :  *
     102             :  * # Backend implementations
     103             :  *
     104             :  * Compositor backends like OpenGL or flavours of D3D live in their own directory
     105             :  * under gfx/layers/. To add a new backend, implement at least the following
     106             :  * interfaces:
     107             :  * - Compositor (ex. CompositorOGL)
     108             :  * - TextureHost (ex. SurfaceTextureHost)
     109             :  * Depending on the type of data that needs to be serialized, you may need to
     110             :  * add specific TextureClient implementations.
     111             :  */
     112             : 
     113             : class nsIWidget;
     114             : 
     115             : namespace mozilla {
     116             : namespace gfx {
     117             : class DrawTarget;
     118             : class DataSourceSurface;
     119             : } // namespace gfx
     120             : 
     121             : namespace layers {
     122             : 
     123             : struct Effect;
     124             : struct EffectChain;
     125             : class Image;
     126             : class Layer;
     127             : class TextureSource;
     128             : class DataTextureSource;
     129             : class CompositingRenderTarget;
     130             : class CompositorBridgeParent;
     131             : class LayerManagerComposite;
     132             : class CompositorOGL;
     133             : class CompositorD3D11;
     134             : class BasicCompositor;
     135             : class TextureReadLock;
     136             : struct GPUStats;
     137             : 
     138             : enum SurfaceInitMode
     139             : {
     140             :   INIT_MODE_NONE,
     141             :   INIT_MODE_CLEAR
     142             : };
     143             : 
     144             : /**
     145             :  * Common interface for compositor backends.
     146             :  *
     147             :  * Compositor provides a cross-platform interface to a set of operations for
     148             :  * compositing quads. Compositor knows nothing about the layer tree. It must be
     149             :  * told everything about each composited quad - contents, location, transform,
     150             :  * opacity, etc.
     151             :  *
     152             :  * In theory it should be possible for different widgets to use the same
     153             :  * compositor. In practice, we use one compositor per window.
     154             :  *
     155             :  * # Usage
     156             :  *
     157             :  * For an example of a user of Compositor, see LayerManagerComposite.
     158             :  *
     159             :  * Initialization: create a Compositor object, call Initialize().
     160             :  *
     161             :  * Destruction: destroy any resources associated with the compositor, call
     162             :  * Destroy(), delete the Compositor object.
     163             :  *
     164             :  * Composition:
     165             :  *  call BeginFrame,
     166             :  *  for each quad to be composited:
     167             :  *    call MakeCurrent if necessary (not necessary if no other context has been
     168             :  *      made current),
     169             :  *    take care of any texture upload required to composite the quad, this step
     170             :  *      is backend-dependent,
     171             :  *    construct an EffectChain for the quad,
     172             :  *    call DrawQuad,
     173             :  *  call EndFrame.
     174             :  *
     175             :  * By default, the compositor will render to the screen, to render to a target,
     176             :  * call SetTargetContext or SetRenderTarget, the latter with a target created
     177             :  * by CreateRenderTarget or CreateRenderTargetFromSource.
     178             :  *
     179             :  * The target and viewport methods can be called before any DrawQuad call and
     180             :  * affect any subsequent DrawQuad calls.
     181             :  */
     182             : class Compositor : public TextureSourceProvider
     183             : {
     184             : protected:
     185             :   virtual ~Compositor();
     186             : 
     187             : public:
     188             :   explicit Compositor(widget::CompositorWidget* aWidget,
     189             :                       CompositorBridgeParent* aParent = nullptr);
     190             : 
     191             :   virtual bool Initialize(nsCString* const out_failureReason) = 0;
     192             :   virtual void Destroy() override;
     193          27 :   bool IsDestroyed() const { return mIsDestroyed; }
     194             : 
     195           0 :   virtual void DetachWidget() { mWidget = nullptr; }
     196             : 
     197             :   /**
     198             :    * Request a texture host identifier that may be used for creating textures
     199             :    * across process or thread boundaries that are compatible with this
     200             :    * compositor.
     201             :    */
     202             :   virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() = 0;
     203             : 
     204             :   /**
     205             :    * Properties of the compositor.
     206             :    */
     207             :   virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) = 0;
     208             : 
     209             :   /**
     210             :    * Set the target for rendering. Results will have been written to aTarget by
     211             :    * the time that EndFrame returns.
     212             :    *
     213             :    * If this method is not used, or we pass in nullptr, we target the compositor's
     214             :    * usual swap chain and render to the screen.
     215             :    */
     216           0 :   void SetTargetContext(gfx::DrawTarget* aTarget, const gfx::IntRect& aRect)
     217             :   {
     218           0 :     mTarget = aTarget;
     219           0 :     mTargetBounds = aRect;
     220           0 :   }
     221           0 :   gfx::DrawTarget* GetTargetContext() const
     222             :   {
     223           0 :     return mTarget;
     224             :   }
     225          57 :   void ClearTargetContext()
     226             :   {
     227          57 :     mTarget = nullptr;
     228          57 :   }
     229             : 
     230             :   typedef uint32_t MakeCurrentFlags;
     231             :   static const MakeCurrentFlags ForceMakeCurrent = 0x1;
     232             :   /**
     233             :    * Make this compositor's rendering context the current context for the
     234             :    * underlying graphics API. This may be a global operation, depending on the
     235             :    * API. Our context will remain the current one until someone else changes it.
     236             :    *
     237             :    * Clients of the compositor should call this at the start of the compositing
     238             :    * process, it might be required by texture uploads etc.
     239             :    *
     240             :    * If aFlags == ForceMakeCurrent then we will (re-)set our context on the
     241             :    * underlying API even if it is already the current context.
     242             :    */
     243             :   virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) = 0;
     244             : 
     245             :   /**
     246             :    * Creates a Surface that can be used as a rendering target by this
     247             :    * compositor.
     248             :    */
     249             :   virtual already_AddRefed<CompositingRenderTarget>
     250             :   CreateRenderTarget(const gfx::IntRect& aRect, SurfaceInitMode aInit) = 0;
     251             : 
     252             :   /**
     253             :    * Creates a Surface that can be used as a rendering target by this
     254             :    * compositor, and initializes the surface by copying from aSource.
     255             :    * If aSource is null, then the current screen buffer is used as source.
     256             :    *
     257             :    * aSourcePoint specifies the point in aSource to copy data from.
     258             :    */
     259             :   virtual already_AddRefed<CompositingRenderTarget>
     260             :   CreateRenderTargetFromSource(const gfx::IntRect& aRect,
     261             :                                const CompositingRenderTarget* aSource,
     262             :                                const gfx::IntPoint& aSourcePoint) = 0;
     263             : 
     264             :   /**
     265             :    * Sets the given surface as the target for subsequent calls to DrawQuad.
     266             :    * Passing null as aSurface sets the screen as the target.
     267             :    */
     268             :   virtual void SetRenderTarget(CompositingRenderTarget* aSurface) = 0;
     269             : 
     270             :   /**
     271             :    * Returns the current target for rendering. Will return null if we are
     272             :    * rendering to the screen.
     273             :    */
     274             :   virtual CompositingRenderTarget* GetCurrentRenderTarget() const = 0;
     275             : 
     276             :   /**
     277             :    * Mostly the compositor will pull the size from a widget and this method will
     278             :    * be ignored, but compositor implementations are free to use it if they like.
     279             :    */
     280             :   virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) = 0;
     281             : 
     282             :   /**
     283             :    * Declare an offset to use when rendering layers. This will be ignored when
     284             :    * rendering to a target instead of the screen.
     285             :    */
     286             :   virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) = 0;
     287             : 
     288             :   void DrawGeometry(const gfx::Rect& aRect,
     289             :                     const gfx::IntRect& aClipRect,
     290             :                     const EffectChain &aEffectChain,
     291             :                     gfx::Float aOpacity,
     292             :                     const gfx::Matrix4x4& aTransform,
     293             :                     const gfx::Rect& aVisibleRect,
     294             :                     const Maybe<gfx::Polygon>& aGeometry);
     295             : 
     296          80 :   void DrawGeometry(const gfx::Rect& aRect,
     297             :                     const gfx::IntRect& aClipRect,
     298             :                     const EffectChain &aEffectChain,
     299             :                     gfx::Float aOpacity,
     300             :                     const gfx::Matrix4x4& aTransform,
     301             :                     const Maybe<gfx::Polygon>& aGeometry)
     302             :   {
     303             :     DrawGeometry(aRect, aClipRect, aEffectChain, aOpacity,
     304          80 :                  aTransform, aRect, aGeometry);
     305          80 :   }
     306             : 
     307             :   /**
     308             :    * Tell the compositor to draw a quad. What to do draw and how it is
     309             :    * drawn is specified by aEffectChain. aRect is the quad to draw, in user space.
     310             :    * aTransform transforms from user space to screen space. If texture coords are
     311             :    * required, these will be in the primary effect in the effect chain.
     312             :    * aVisibleRect is used to determine which edges should be antialiased,
     313             :    * without applying the effect to the inner edges of a tiled layer.
     314             :    */
     315             :   virtual void DrawQuad(const gfx::Rect& aRect, const gfx::IntRect& aClipRect,
     316             :                         const EffectChain& aEffectChain,
     317             :                         gfx::Float aOpacity, const gfx::Matrix4x4& aTransform,
     318             :                         const gfx::Rect& aVisibleRect) = 0;
     319             : 
     320             :   /**
     321             :    * Overload of DrawQuad, with aVisibleRect defaulted to the value of aRect.
     322             :    * Use this when you are drawing a single quad that is not part of a tiled
     323             :    * layer.
     324             :    */
     325           0 :   void DrawQuad(const gfx::Rect& aRect, const gfx::IntRect& aClipRect,
     326             :                         const EffectChain& aEffectChain,
     327             :                         gfx::Float aOpacity, const gfx::Matrix4x4& aTransform) {
     328           0 :       DrawQuad(aRect, aClipRect, aEffectChain, aOpacity, aTransform, aRect);
     329           0 :   }
     330             : 
     331           0 :   virtual void DrawTriangle(const gfx::TexturedTriangle& aTriangle,
     332             :                             const gfx::IntRect& aClipRect,
     333             :                             const EffectChain& aEffectChain,
     334             :                             gfx::Float aOpacity,
     335             :                             const gfx::Matrix4x4& aTransform,
     336             :                             const gfx::Rect& aVisibleRect)
     337             :   {
     338           0 :     MOZ_CRASH("Compositor::DrawTriangle is not implemented for the current platform!");
     339             :   }
     340             : 
     341           0 :   virtual bool SupportsLayerGeometry() const
     342             :   {
     343           0 :     return false;
     344             :   }
     345             : 
     346             :   /**
     347             :    * Draw an unfilled solid color rect. Typically used for debugging overlays.
     348             :    */
     349             :   void SlowDrawRect(const gfx::Rect& aRect, const gfx::Color& color,
     350             :                 const gfx::IntRect& aClipRect = gfx::IntRect(),
     351             :                 const gfx::Matrix4x4& aTransform = gfx::Matrix4x4(),
     352             :                 int aStrokeWidth = 1);
     353             : 
     354             :   /**
     355             :    * Draw a solid color filled rect. This is a simple DrawQuad helper.
     356             :    */
     357             :   void FillRect(const gfx::Rect& aRect, const gfx::Color& color,
     358             :                     const gfx::IntRect& aClipRect = gfx::IntRect(),
     359             :                     const gfx::Matrix4x4& aTransform = gfx::Matrix4x4());
     360             : 
     361             :   void SetClearColor(const gfx::Color& aColor) {
     362             :     mClearColor = aColor;
     363             :   }
     364             : 
     365           0 :   void SetDefaultClearColor(const gfx::Color& aColor) {
     366           0 :     mDefaultClearColor = aColor;
     367           0 :   }
     368             : 
     369             :   void SetClearColorToDefault() {
     370             :     mClearColor = mDefaultClearColor;
     371             :   }
     372             : 
     373             :   /*
     374             :    * Clear aRect on current render target.
     375             :    */
     376             :   virtual void ClearRect(const gfx::Rect& aRect) = 0;
     377             : 
     378             :   /**
     379             :    * Start a new frame.
     380             :    *
     381             :    * aInvalidRect is the invalid region of the screen; it can be ignored for
     382             :    * compositors where the performance for compositing the entire window is
     383             :    * sufficient.
     384             :    *
     385             :    * aClipRectIn is the clip rect for the window in window space (optional).
     386             :    * aTransform is the transform from user space to window space.
     387             :    * aRenderBounds bounding rect for rendering, in user space.
     388             :    *
     389             :    * If aClipRectIn is null, this method sets *aClipRectOut to the clip rect
     390             :    * actually used for rendering (if aClipRectIn is non-null, we will use that
     391             :    * for the clip rect).
     392             :    *
     393             :    * If aRenderBoundsOut is non-null, it will be set to the render bounds
     394             :    * actually used by the compositor in window space. If aRenderBoundsOut
     395             :    * is returned empty, composition should be aborted.
     396             :    *
     397             :    * If aOpaque is true, then all of aInvalidRegion will be drawn to with
     398             :    * opaque content.
     399             :    */
     400             :   virtual void BeginFrame(const nsIntRegion& aInvalidRegion,
     401             :                           const gfx::IntRect* aClipRectIn,
     402             :                           const gfx::IntRect& aRenderBounds,
     403             :                           const nsIntRegion& aOpaqueRegion,
     404             :                           gfx::IntRect* aClipRectOut = nullptr,
     405             :                           gfx::IntRect* aRenderBoundsOut = nullptr) = 0;
     406             : 
     407             :   /**
     408             :    * Notification that we've finished issuing draw commands for normal
     409             :    * layers (as opposed to the diagnostic overlay which comes after).
     410             :    */
     411          27 :   virtual void NormalDrawingDone() {}
     412             : 
     413             :   /**
     414             :    * Flush the current frame to the screen and tidy up.
     415             :    *
     416             :    * Derived class overriding this should call Compositor::EndFrame.
     417             :    */
     418             :   virtual void EndFrame();
     419             : 
     420           0 :   virtual void CancelFrame(bool aNeedFlush = true) { ReadUnlockTextures(); }
     421             : 
     422             :   virtual void SetDispAcquireFence(Layer* aLayer);
     423             : 
     424             :   /**
     425             :    * Whether textures created by this compositor can receive partial updates.
     426             :    */
     427             :   virtual bool SupportsPartialTextureUpdate() = 0;
     428             : 
     429           0 :   void SetDiagnosticTypes(DiagnosticTypes aDiagnostics)
     430             :   {
     431           0 :     mDiagnosticTypes = aDiagnostics;
     432           0 :   }
     433             : 
     434          29 :   DiagnosticTypes GetDiagnosticTypes() const
     435             :   {
     436          29 :     return mDiagnosticTypes;
     437             :   }
     438             : 
     439             :   void DrawDiagnostics(DiagnosticFlags aFlags,
     440             :                        const gfx::Rect& visibleRect,
     441             :                        const gfx::IntRect& aClipRect,
     442             :                        const gfx::Matrix4x4& transform,
     443             :                        uint32_t aFlashCounter = DIAGNOSTIC_FLASH_COUNTER_MAX);
     444             : 
     445             :   void DrawDiagnostics(DiagnosticFlags aFlags,
     446             :                        const nsIntRegion& visibleRegion,
     447             :                        const gfx::IntRect& aClipRect,
     448             :                        const gfx::Matrix4x4& transform,
     449             :                        uint32_t aFlashCounter = DIAGNOSTIC_FLASH_COUNTER_MAX);
     450             : 
     451             : #ifdef MOZ_DUMP_PAINTING
     452             :   virtual const char* Name() const = 0;
     453             : #endif // MOZ_DUMP_PAINTING
     454             : 
     455             :   virtual LayersBackend GetBackendType() const = 0;
     456             : 
     457           0 :   virtual CompositorOGL* AsCompositorOGL() { return nullptr; }
     458           0 :   virtual CompositorD3D11* AsCompositorD3D11() { return nullptr; }
     459           0 :   virtual BasicCompositor* AsBasicCompositor() { return nullptr; }
     460             : 
     461           0 :   virtual Compositor* AsCompositor() override {
     462           0 :     return this;
     463             :   }
     464             : 
     465           0 :   TimeStamp GetLastCompositionEndTime() const override {
     466           0 :     return mLastCompositionEndTime;
     467             :   }
     468             : 
     469             :   bool NotifyNotUsedAfterComposition(TextureHost* aTextureHost) override;
     470             : 
     471             :   /**
     472             :    * Notify the compositor that composition is being paused. This allows the
     473             :    * compositor to temporarily release any resources.
     474             :    * Between calling Pause and Resume, compositing may fail.
     475             :    */
     476           0 :   virtual void Pause() {}
     477             :   /**
     478             :    * Notify the compositor that composition is being resumed. The compositor
     479             :    * regain any resources it requires for compositing.
     480             :    * Returns true if succeeded.
     481             :    */
     482           0 :   virtual bool Resume() { return true; }
     483             : 
     484             :   /**
     485             :    * Call before rendering begins to ensure the compositor is ready to
     486             :    * composite. Returns false if rendering should be aborted.
     487             :    */
     488          57 :   virtual bool Ready() { return true; }
     489             : 
     490           0 :   virtual void ForcePresent() { }
     491             : 
     492           0 :   virtual bool IsPendingComposite() { return false; }
     493             : 
     494           0 :   virtual void FinishPendingComposite() {}
     495             : 
     496         108 :   widget::CompositorWidget* GetWidget() const { return mWidget; }
     497             : 
     498             :   /**
     499             :    * Debug-build assertion that can be called to ensure code is running on the
     500             :    * compositor thread.
     501             :    */
     502             :   static void AssertOnCompositorThread();
     503             : 
     504             :   // Return statistics for the most recent frame we computed statistics for.
     505             :   virtual void GetFrameStats(GPUStats* aStats);
     506             : 
     507             :   ScreenRotation GetScreenRotation() const {
     508             :     return mScreenRotation;
     509             :   }
     510          24 :   void SetScreenRotation(ScreenRotation aRotation) {
     511          24 :     mScreenRotation = aRotation;
     512          24 :   }
     513             : 
     514             :   // A stale Compositor has no CompositorBridgeParent; it will not process
     515             :   // frames and should not be used.
     516             :   void SetInvalid();
     517             :   virtual bool IsValid() const override;
     518           0 :   CompositorBridgeParent* GetCompositorBridgeParent() const {
     519           0 :     return mParent;
     520             :   }
     521             : 
     522             : protected:
     523             :   void DrawDiagnosticsInternal(DiagnosticFlags aFlags,
     524             :                                const gfx::Rect& aVisibleRect,
     525             :                                const gfx::IntRect& aClipRect,
     526             :                                const gfx::Matrix4x4& transform,
     527             :                                uint32_t aFlashCounter);
     528             : 
     529             :   bool ShouldDrawDiagnostics(DiagnosticFlags);
     530             : 
     531             :   /**
     532             :    * Given a layer rect, clip, and transform, compute the area of the backdrop that
     533             :    * needs to be copied for mix-blending. The output transform translates from 0..1
     534             :    * space into the backdrop rect space.
     535             :    *
     536             :    * The transformed layer quad is also optionally returned - this is the same as
     537             :    * the result rect, before rounding.
     538             :    */
     539             :   gfx::IntRect ComputeBackdropCopyRect(const gfx::Rect& aRect,
     540             :                                        const gfx::IntRect& aClipRect,
     541             :                                        const gfx::Matrix4x4& aTransform,
     542             :                                        gfx::Matrix4x4* aOutTransform,
     543             :                                        gfx::Rect* aOutLayerQuad = nullptr);
     544             : 
     545             :   gfx::IntRect ComputeBackdropCopyRect(const gfx::Triangle& aTriangle,
     546             :                                        const gfx::IntRect& aClipRect,
     547             :                                        const gfx::Matrix4x4& aTransform,
     548             :                                        gfx::Matrix4x4* aOutTransform,
     549             :                                        gfx::Rect* aOutLayerQuad = nullptr);
     550             : 
     551             :   virtual void DrawTriangles(const nsTArray<gfx::TexturedTriangle>& aTriangles,
     552             :                              const gfx::Rect& aRect,
     553             :                              const gfx::IntRect& aClipRect,
     554             :                              const EffectChain& aEffectChain,
     555             :                              gfx::Float aOpacity,
     556             :                              const gfx::Matrix4x4& aTransform,
     557             :                              const gfx::Rect& aVisibleRect);
     558             : 
     559             :   virtual void DrawPolygon(const gfx::Polygon& aPolygon,
     560             :                            const gfx::Rect& aRect,
     561             :                            const gfx::IntRect& aClipRect,
     562             :                            const EffectChain& aEffectChain,
     563             :                            gfx::Float aOpacity,
     564             :                            const gfx::Matrix4x4& aTransform,
     565             :                            const gfx::Rect& aVisibleRect);
     566             : 
     567             :   /**
     568             :    * Last Composition end time.
     569             :    */
     570             :   TimeStamp mLastCompositionEndTime;
     571             : 
     572             :   DiagnosticTypes mDiagnosticTypes;
     573             :   CompositorBridgeParent* mParent;
     574             : 
     575             :   /**
     576             :    * We keep track of the total number of pixels filled as we composite the
     577             :    * current frame. This value is an approximation and is not accurate,
     578             :    * especially in the presence of transforms.
     579             :    */
     580             :   size_t mPixelsPerFrame;
     581             :   size_t mPixelsFilled;
     582             : 
     583             :   ScreenRotation mScreenRotation;
     584             : 
     585             :   RefPtr<gfx::DrawTarget> mTarget;
     586             :   gfx::IntRect mTargetBounds;
     587             : 
     588             :   widget::CompositorWidget* mWidget;
     589             : 
     590             :   bool mIsDestroyed;
     591             : 
     592             :   gfx::Color mClearColor;
     593             :   gfx::Color mDefaultClearColor;
     594             : 
     595             : private:
     596             :   static LayersBackend sBackend;
     597             : 
     598             : };
     599             : 
     600             : // Returns the number of rects. (Up to 4)
     601             : typedef gfx::Rect decomposedRectArrayT[4];
     602             : size_t DecomposeIntoNoRepeatRects(const gfx::Rect& aRect,
     603             :                                   const gfx::Rect& aTexCoordRect,
     604             :                                   decomposedRectArrayT* aLayerRects,
     605             :                                   decomposedRectArrayT* aTextureRects);
     606             : 
     607             : static inline bool
     608           0 : BlendOpIsMixBlendMode(gfx::CompositionOp aOp)
     609             : {
     610           0 :   switch (aOp) {
     611             :   case gfx::CompositionOp::OP_MULTIPLY:
     612             :   case gfx::CompositionOp::OP_SCREEN:
     613             :   case gfx::CompositionOp::OP_OVERLAY:
     614             :   case gfx::CompositionOp::OP_DARKEN:
     615             :   case gfx::CompositionOp::OP_LIGHTEN:
     616             :   case gfx::CompositionOp::OP_COLOR_DODGE:
     617             :   case gfx::CompositionOp::OP_COLOR_BURN:
     618             :   case gfx::CompositionOp::OP_HARD_LIGHT:
     619             :   case gfx::CompositionOp::OP_SOFT_LIGHT:
     620             :   case gfx::CompositionOp::OP_DIFFERENCE:
     621             :   case gfx::CompositionOp::OP_EXCLUSION:
     622             :   case gfx::CompositionOp::OP_HUE:
     623             :   case gfx::CompositionOp::OP_SATURATION:
     624             :   case gfx::CompositionOp::OP_COLOR:
     625             :   case gfx::CompositionOp::OP_LUMINOSITY:
     626           0 :     return true;
     627             :   default:
     628           0 :     return false;
     629             :   }
     630             : }
     631             : 
     632             : struct TexturedVertex
     633             : {
     634             :   float position[2];
     635             :   float texCoords[2];
     636             : };
     637             : 
     638             : nsTArray<TexturedVertex>
     639             : TexturedTrianglesToVertexArray(const nsTArray<gfx::TexturedTriangle>& aTriangles);
     640             : 
     641             : } // namespace layers
     642             : } // namespace mozilla
     643             : 
     644             : #endif /* MOZILLA_GFX_COMPOSITOR_H */

Generated by: LCOV version 1.13