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/. */
7 #ifndef NSDISPLAYLISTINVALIDATION_H_
8 #define NSDISPLAYLISTINVALIDATION_H_
10 #include "mozilla/Attributes.h"
11 #include "mozilla/layers/WebRenderUserData.h"
12 #include "ImgDrawResult.h"
16 #include "mozilla/gfx/MatrixFwd.h"
19 class nsDisplayBackgroundImage
;
20 class nsCharClipDisplayItem
;
22 class nsDisplayListBuilder
;
23 class nsDisplayTableItem
;
24 class nsDisplayThemedBackground
;
25 class nsDisplayEffectsBase
;
26 class nsDisplayMasksAndClipPaths
;
27 class nsDisplayFilters
;
34 * This stores the geometry of an nsDisplayItem, and the area
35 * that will be affected when painting the item.
37 * It is used to retain information about display items so they
38 * can be compared against new display items in the next paint.
40 class nsDisplayItemGeometry
{
42 nsDisplayItemGeometry(nsDisplayItem
* aItem
, nsDisplayListBuilder
* aBuilder
);
43 virtual ~nsDisplayItemGeometry();
46 * Compute the area required to be invalidated if this
47 * display item is removed.
49 const nsRect
& ComputeInvalidationRegion() { return mBounds
; }
52 * Shifts all retained areas of the nsDisplayItemGeometry by the given offset.
54 * This is used to compensate for scrolling, since the destination buffer
55 * can scroll without requiring a full repaint.
57 * @param aOffset Offset to shift by.
59 virtual void MoveBy(const nsPoint
& aOffset
) { mBounds
.MoveBy(aOffset
); }
62 * Bounds of the display item
68 * A default geometry implementation, used by nsDisplayItem. Retains
69 * and compares the bounds, and border rect.
71 * This should be sufficient for the majority of display items.
73 class nsDisplayItemGenericGeometry
: public nsDisplayItemGeometry
{
75 nsDisplayItemGenericGeometry(nsDisplayItem
* aItem
,
76 nsDisplayListBuilder
* aBuilder
);
78 void MoveBy(const nsPoint
& aOffset
) override
;
83 bool ShouldSyncDecodeImages(nsDisplayListBuilder
* aBuilder
);
85 nsDisplayItemGeometry
* GetPreviousGeometry(nsDisplayItem
*);
87 class nsDisplayItemBoundsGeometry
: public nsDisplayItemGeometry
{
89 nsDisplayItemBoundsGeometry(nsDisplayItem
* aItem
,
90 nsDisplayListBuilder
* aBuilder
);
92 bool mHasRoundedCorners
;
95 class nsDisplayBorderGeometry
: public nsDisplayItemGeometry
{
97 nsDisplayBorderGeometry(nsDisplayItem
* aItem
, nsDisplayListBuilder
* aBuilder
);
100 class nsDisplayBackgroundGeometry
: public nsDisplayItemGeometry
{
102 nsDisplayBackgroundGeometry(nsDisplayBackgroundImage
* aItem
,
103 nsDisplayListBuilder
* aBuilder
);
105 void MoveBy(const nsPoint
& aOffset
) override
;
107 nsRect mPositioningArea
;
111 class nsDisplayThemedBackgroundGeometry
: public nsDisplayItemGeometry
{
113 nsDisplayThemedBackgroundGeometry(nsDisplayThemedBackground
* aItem
,
114 nsDisplayListBuilder
* aBuilder
);
116 void MoveBy(const nsPoint
& aOffset
) override
;
118 nsRect mPositioningArea
;
119 bool mWindowIsActive
;
122 class nsDisplayTreeBodyGeometry
: public nsDisplayItemGenericGeometry
{
124 nsDisplayTreeBodyGeometry(nsDisplayItem
* aItem
,
125 nsDisplayListBuilder
* aBuilder
,
126 bool aWindowIsActive
)
127 : nsDisplayItemGenericGeometry(aItem
, aBuilder
),
128 mWindowIsActive(aWindowIsActive
) {}
130 bool mWindowIsActive
= false;
133 class nsDisplayBoxShadowInnerGeometry
: public nsDisplayItemGeometry
{
135 nsDisplayBoxShadowInnerGeometry(nsDisplayItem
* aItem
,
136 nsDisplayListBuilder
* aBuilder
);
138 void MoveBy(const nsPoint
& aOffset
) override
;
143 class nsDisplaySolidColorGeometry
: public nsDisplayItemBoundsGeometry
{
145 nsDisplaySolidColorGeometry(nsDisplayItem
* aItem
,
146 nsDisplayListBuilder
* aBuilder
, nscolor aColor
)
147 : nsDisplayItemBoundsGeometry(aItem
, aBuilder
), mColor(aColor
) {}
152 class nsDisplaySolidColorRegionGeometry
: public nsDisplayItemBoundsGeometry
{
154 nsDisplaySolidColorRegionGeometry(nsDisplayItem
* aItem
,
155 nsDisplayListBuilder
* aBuilder
,
156 const nsRegion
& aRegion
,
157 mozilla::gfx::sRGBColor aColor
)
158 : nsDisplayItemBoundsGeometry(aItem
, aBuilder
),
162 void MoveBy(const nsPoint
& aOffset
) override
;
165 mozilla::gfx::sRGBColor mColor
;
168 class nsDisplaySVGEffectGeometry
: public nsDisplayItemGeometry
{
170 nsDisplaySVGEffectGeometry(nsDisplayEffectsBase
* aItem
,
171 nsDisplayListBuilder
* aBuilder
);
173 void MoveBy(const nsPoint
& aOffset
) override
;
176 gfxPoint mUserSpaceOffset
;
177 nsPoint mFrameOffsetToReferenceFrame
;
181 class nsDisplayMasksAndClipPathsGeometry
: public nsDisplaySVGEffectGeometry
{
183 nsDisplayMasksAndClipPathsGeometry(nsDisplayMasksAndClipPaths
* aItem
,
184 nsDisplayListBuilder
* aBuilder
);
186 nsTArray
<nsRect
> mDestRects
;
189 class nsDisplayFiltersGeometry
: public nsDisplaySVGEffectGeometry
{
191 nsDisplayFiltersGeometry(nsDisplayFilters
* aItem
,
192 nsDisplayListBuilder
* aBuilder
);
195 class nsDisplayTableItemGeometry
: public nsDisplayItemGenericGeometry
{
197 nsDisplayTableItemGeometry(nsDisplayTableItem
* aItem
,
198 nsDisplayListBuilder
* aBuilder
,
199 const nsPoint
& aFrameOffsetToViewport
);
201 nsPoint mFrameOffsetToViewport
;
204 class nsDisplayOpacityGeometry
: public nsDisplayItemGenericGeometry
{
206 nsDisplayOpacityGeometry(nsDisplayItem
* aItem
, nsDisplayListBuilder
* aBuilder
,
208 : nsDisplayItemGenericGeometry(aItem
, aBuilder
), mOpacity(aOpacity
) {}
213 class nsDisplayTransformGeometry
: public nsDisplayItemGeometry
{
215 nsDisplayTransformGeometry(nsDisplayItem
* aItem
,
216 nsDisplayListBuilder
* aBuilder
,
217 const mozilla::gfx::Matrix4x4Flagged
& aTransform
,
218 int32_t aAppUnitsPerDevPixel
)
219 : nsDisplayItemGeometry(aItem
, aBuilder
),
220 mTransform(aTransform
),
221 mAppUnitsPerDevPixel(aAppUnitsPerDevPixel
) {}
223 void MoveBy(const nsPoint
& aOffset
) override
{
224 nsDisplayItemGeometry::MoveBy(aOffset
);
225 mTransform
.PostTranslate(
226 NSAppUnitsToFloatPixels(aOffset
.x
, mAppUnitsPerDevPixel
),
227 NSAppUnitsToFloatPixels(aOffset
.y
, mAppUnitsPerDevPixel
), 0.0f
);
230 mozilla::gfx::Matrix4x4Flagged mTransform
;
231 int32_t mAppUnitsPerDevPixel
;
234 } // namespace mozilla
236 #endif /*NSDISPLAYLISTINVALIDATION_H_*/