no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / layout / painting / nsDisplayListInvalidation.h
blob3e07713301bf05213862cd1ff0ce15312b96adc1
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"
13 #include "nsRect.h"
14 #include "nsColor.h"
15 #include "gfxRect.h"
16 #include "mozilla/gfx/MatrixFwd.h"
18 namespace mozilla {
19 class nsDisplayBackgroundImage;
20 class nsCharClipDisplayItem;
21 class nsDisplayItem;
22 class nsDisplayListBuilder;
23 class nsDisplayTableItem;
24 class nsDisplayThemedBackground;
25 class nsDisplayEffectsBase;
26 class nsDisplayMasksAndClipPaths;
27 class nsDisplayFilters;
29 namespace gfx {
30 struct sRGBColor;
33 /**
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 {
41 public:
42 nsDisplayItemGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder);
43 virtual ~nsDisplayItemGeometry();
45 /**
46 * Compute the area required to be invalidated if this
47 * display item is removed.
49 const nsRect& ComputeInvalidationRegion() { return mBounds; }
51 /**
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); }
61 /**
62 * Bounds of the display item
64 nsRect mBounds;
67 /**
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 {
74 public:
75 nsDisplayItemGenericGeometry(nsDisplayItem* aItem,
76 nsDisplayListBuilder* aBuilder);
78 void MoveBy(const nsPoint& aOffset) override;
80 nsRect mBorderRect;
83 bool ShouldSyncDecodeImages(nsDisplayListBuilder* aBuilder);
85 nsDisplayItemGeometry* GetPreviousGeometry(nsDisplayItem*);
87 class nsDisplayItemBoundsGeometry : public nsDisplayItemGeometry {
88 public:
89 nsDisplayItemBoundsGeometry(nsDisplayItem* aItem,
90 nsDisplayListBuilder* aBuilder);
92 bool mHasRoundedCorners;
95 class nsDisplayBorderGeometry : public nsDisplayItemGeometry {
96 public:
97 nsDisplayBorderGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder);
100 class nsDisplayBackgroundGeometry : public nsDisplayItemGeometry {
101 public:
102 nsDisplayBackgroundGeometry(nsDisplayBackgroundImage* aItem,
103 nsDisplayListBuilder* aBuilder);
105 void MoveBy(const nsPoint& aOffset) override;
107 nsRect mPositioningArea;
108 nsRect mDestRect;
111 class nsDisplayThemedBackgroundGeometry : public nsDisplayItemGeometry {
112 public:
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 {
123 public:
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 {
134 public:
135 nsDisplayBoxShadowInnerGeometry(nsDisplayItem* aItem,
136 nsDisplayListBuilder* aBuilder);
138 void MoveBy(const nsPoint& aOffset) override;
140 nsRect mPaddingRect;
143 class nsDisplaySolidColorGeometry : public nsDisplayItemBoundsGeometry {
144 public:
145 nsDisplaySolidColorGeometry(nsDisplayItem* aItem,
146 nsDisplayListBuilder* aBuilder, nscolor aColor)
147 : nsDisplayItemBoundsGeometry(aItem, aBuilder), mColor(aColor) {}
149 nscolor mColor;
152 class nsDisplaySolidColorRegionGeometry : public nsDisplayItemBoundsGeometry {
153 public:
154 nsDisplaySolidColorRegionGeometry(nsDisplayItem* aItem,
155 nsDisplayListBuilder* aBuilder,
156 const nsRegion& aRegion,
157 mozilla::gfx::sRGBColor aColor)
158 : nsDisplayItemBoundsGeometry(aItem, aBuilder),
159 mRegion(aRegion),
160 mColor(aColor) {}
162 void MoveBy(const nsPoint& aOffset) override;
164 nsRegion mRegion;
165 mozilla::gfx::sRGBColor mColor;
168 class nsDisplaySVGEffectGeometry : public nsDisplayItemGeometry {
169 public:
170 nsDisplaySVGEffectGeometry(nsDisplayEffectsBase* aItem,
171 nsDisplayListBuilder* aBuilder);
173 void MoveBy(const nsPoint& aOffset) override;
175 gfxRect mBBox;
176 gfxPoint mUserSpaceOffset;
177 nsPoint mFrameOffsetToReferenceFrame;
178 bool mHandleOpacity;
181 class nsDisplayMasksAndClipPathsGeometry : public nsDisplaySVGEffectGeometry {
182 public:
183 nsDisplayMasksAndClipPathsGeometry(nsDisplayMasksAndClipPaths* aItem,
184 nsDisplayListBuilder* aBuilder);
186 nsTArray<nsRect> mDestRects;
189 class nsDisplayFiltersGeometry : public nsDisplaySVGEffectGeometry {
190 public:
191 nsDisplayFiltersGeometry(nsDisplayFilters* aItem,
192 nsDisplayListBuilder* aBuilder);
195 class nsDisplayTableItemGeometry : public nsDisplayItemGenericGeometry {
196 public:
197 nsDisplayTableItemGeometry(nsDisplayTableItem* aItem,
198 nsDisplayListBuilder* aBuilder,
199 const nsPoint& aFrameOffsetToViewport);
201 nsPoint mFrameOffsetToViewport;
204 class nsDisplayOpacityGeometry : public nsDisplayItemGenericGeometry {
205 public:
206 nsDisplayOpacityGeometry(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder,
207 float aOpacity)
208 : nsDisplayItemGenericGeometry(aItem, aBuilder), mOpacity(aOpacity) {}
210 float mOpacity;
213 class nsDisplayTransformGeometry : public nsDisplayItemGeometry {
214 public:
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_*/