MatrixMessage.h (2360B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_layers_MatrixMessage_h 8 #define mozilla_layers_MatrixMessage_h 9 10 #include "mozilla/Maybe.h" 11 #include "mozilla/gfx/Matrix.h" 12 #include "mozilla/layers/LayersTypes.h" 13 #include "Units.h" // for ScreenRect 14 #include "UnitTransforms.h" 15 16 namespace mozilla { 17 namespace layers { 18 class MatrixMessage { 19 public: 20 // Don't use this one directly 21 MatrixMessage() = default; 22 23 MatrixMessage(const Maybe<LayerToScreenMatrix4x4>& aMatrix, 24 const ScreenRect& aTopLevelViewportVisibleRectInBrowserCoords, 25 const LayersId& aLayersId) 26 : mMatrix(ToUnknownMatrix(aMatrix)), 27 mTopLevelViewportVisibleRectInBrowserCoords( 28 aTopLevelViewportVisibleRectInBrowserCoords), 29 mLayersId(aLayersId) {} 30 31 inline Maybe<LayerToScreenMatrix4x4> GetMatrix() const { 32 return LayerToScreenMatrix4x4::FromUnknownMatrix(mMatrix); 33 } 34 35 inline ScreenRect GetTopLevelViewportVisibleRectInBrowserCoords() const { 36 return mTopLevelViewportVisibleRectInBrowserCoords; 37 } 38 39 inline const LayersId& GetLayersId() const { return mLayersId; } 40 41 bool operator==(const MatrixMessage& aOther) const { 42 return aOther.mMatrix == mMatrix && 43 aOther.mTopLevelViewportVisibleRectInBrowserCoords == 44 mTopLevelViewportVisibleRectInBrowserCoords && 45 aOther.mLayersId == mLayersId; 46 } 47 48 bool operator!=(const MatrixMessage& aOther) const { 49 return !(*this == aOther); 50 } 51 // Fields are public for IPC. Don't access directly 52 // elsewhere. 53 // Transform matrix to convert this layer to screen coordinate. 54 Maybe<gfx::Matrix4x4> mMatrix; // Untyped for IPC 55 // The remote iframe document rectangle corresponding to this layer. 56 // The rectangle is the result of clipped out by ancestor async scrolling so 57 // that the rectangle will be empty if it's completely scrolled out of view. 58 ScreenRect mTopLevelViewportVisibleRectInBrowserCoords; 59 LayersId mLayersId; 60 }; 61 }; // namespace layers 62 }; // namespace mozilla 63 64 #endif // mozilla_layers_MatrixMessage_h