Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h

Issue 1425593007: Separate display item clients for negative and normal/positive z-order children (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Struct DisplayItemClient Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DisplayItem_h 5 #ifndef DisplayItem_h
6 #define DisplayItem_h 6 #define DisplayItem_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/graphics/ContiguousContainer.h" 9 #include "platform/graphics/ContiguousContainer.h"
10 #include "platform/graphics/paint/DisplayItemClient.h" 10 #include "platform/graphics/paint/DisplayItemClient.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 EndCompositing, 161 EndCompositing,
162 BeginTransform, 162 BeginTransform,
163 EndTransform, 163 EndTransform,
164 BeginClipPath, 164 BeginClipPath,
165 EndClipPath, 165 EndClipPath,
166 BeginFixedPosition, 166 BeginFixedPosition,
167 EndFixedPosition, 167 EndFixedPosition,
168 BeginFixedPositionContainer, 168 BeginFixedPositionContainer,
169 EndFixedPositionContainer, 169 EndFixedPositionContainer,
170 170
171 SubsequenceFirst, 171 Subsequence,
172 SubsequenceNegativeZOrder = SubsequenceFirst, 172 EndSubsequence,
173 SubsequenceNormalFlowAndPositiveZOrder, 173 CachedSubsequence,
174 SubsequenceLast = SubsequenceNormalFlowAndPositiveZOrder,
175 EndSubsequenceFirst,
176 EndSubsequenceLast = EndSubsequenceFirst + SubsequenceLast - Subsequence First,
177 CachedSubsequenceFirst,
178 CachedSubsequenceLast = CachedSubsequenceFirst + SubsequenceLast - Subse quenceFirst,
179 174
180 CachedDisplayItemList, 175 CachedDisplayItemList,
181 176
182 UninitializedType, 177 UninitializedType,
183 TypeLast = UninitializedType 178 TypeLast = UninitializedType
184 }; 179 };
185 180
186 static_assert(TableCollapsedBorderBase >= TableCollapsedBorderUnalignedBase, "TableCollapsedBorder types overlap with other types"); 181 static_assert(TableCollapsedBorderBase >= TableCollapsedBorderUnalignedBase, "TableCollapsedBorder types overlap with other types");
187 static_assert((TableCollapsedBorderBase & 0xf) == 0, "The lowest 4 bits of T ableCollapsedBorderBase should be zero"); 182 static_assert((TableCollapsedBorderBase & 0xf) == 0, "The lowest 4 bits of T ableCollapsedBorderBase should be zero");
188 // Bits or'ed onto TableCollapsedBorderBase to generate a real table collaps ed border type. 183 // Bits or'ed onto TableCollapsedBorderBase to generate a real table collaps ed border type.
189 enum TableCollapsedBorderSides { 184 enum TableCollapsedBorderSides {
190 TableCollapsedBorderTop = 1 << 0, 185 TableCollapsedBorderTop = 1 << 0,
191 TableCollapsedBorderRight = 1 << 1, 186 TableCollapsedBorderRight = 1 << 1,
192 TableCollapsedBorderBottom = 1 << 2, 187 TableCollapsedBorderBottom = 1 << 2,
193 TableCollapsedBorderLeft = 1 << 3, 188 TableCollapsedBorderLeft = 1 << 3,
194 }; 189 };
195 190
196 DisplayItem(const DisplayItemClientWrapper& client, Type type, size_t derive dSize) 191 DisplayItem(const DisplayItemClientWrapper& client, Type type, size_t derive dSize)
197 : m_client(client.displayItemClient()) 192 : m_clientObject(client.displayItemClient().object)
198 , m_scope(0) 193 , m_scope(0)
194 , m_subClientId(client.displayItemClient().subClientId)
199 , m_type(type) 195 , m_type(type)
200 , m_derivedSize(derivedSize) 196 , m_derivedSize(derivedSize)
201 , m_skippedCache(false) 197 , m_skippedCache(false)
202 #ifndef NDEBUG 198 #ifndef NDEBUG
203 , m_clientDebugString(client.debugName()) 199 , m_clientDebugString(client.debugName())
204 #endif 200 #endif
205 { 201 {
206 // derivedSize must fit in m_derivedSize. 202 // derivedSize must fit in m_derivedSize.
207 // If it doesn't, enlarge m_derivedSize and fix this assert. 203 // If it doesn't, enlarge m_derivedSize and fix this assert.
208 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize < (1 << 8)); 204 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize < (1 << 8));
209 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize >= sizeof(*this)); 205 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize >= sizeof(*this));
210 } 206 }
211 207
212 virtual ~DisplayItem() { } 208 virtual ~DisplayItem() { }
213 209
214 // Ids are for matching new DisplayItems with existing DisplayItems. 210 // Ids are for matching new DisplayItems with existing DisplayItems.
215 struct Id { 211 struct Id {
216 Id(const DisplayItemClient client, const Type type, const unsigned scope ) 212 Id(const DisplayItemClient client, const Type type, const unsigned scope )
217 : client(client) 213 : client(client)
218 , type(type) 214 , type(type)
219 , scope(scope) { } 215 , scope(scope) { }
220 216
221 bool matches(const DisplayItem& item) const 217 bool matches(const DisplayItem& item) const
222 { 218 {
223 // We should always convert to non-cached types before matching. 219 // We should always convert to non-cached types before matching.
224 ASSERT(!isCachedType(item.m_type)); 220 ASSERT(!isCachedType(item.m_type));
225 ASSERT(!isCachedType(type)); 221 ASSERT(!isCachedType(type));
226 return client == item.m_client 222 return client == item.client()
227 && type == item.m_type 223 && type == item.m_type
228 && scope == item.m_scope; 224 && scope == item.m_scope;
229 } 225 }
230 226
231 const DisplayItemClient client; 227 const DisplayItemClient client;
232 const Type type; 228 const Type type;
233 const unsigned scope; 229 const unsigned scope;
234 }; 230 };
235 231
236 // Convert cached type to non-cached type (e.g., Type::CachedSVGImage -> Typ e::SVGImage). 232 // Convert cached type to non-cached type (e.g., Type::CachedSVGImage -> Typ e::SVGImage).
237 static Type nonCachedType(Type type) 233 static Type nonCachedType(Type type)
238 { 234 {
239 if (isCachedDrawingType(type)) 235 if (isCachedDrawingType(type))
240 return cachedDrawingTypeToDrawingType(type); 236 return cachedDrawingTypeToDrawingType(type);
241 if (isCachedSubsequenceType(type)) 237 if (type == CachedSubsequence)
242 return cachedSubsequenceTypeToSubsequenceType(type); 238 return Subsequence;
243 return type; 239 return type;
244 } 240 }
245 241
246 // Return the Id with cached type converted to non-cached type. 242 // Return the Id with cached type converted to non-cached type.
247 Id nonCachedId() const 243 Id nonCachedId() const
248 { 244 {
249 return Id(m_client, nonCachedType(m_type), m_scope); 245 return Id(client(), nonCachedType(m_type), m_scope);
250 } 246 }
251 247
252 virtual void replay(GraphicsContext&) const { } 248 virtual void replay(GraphicsContext&) const { }
253 249
254 DisplayItemClient client() const { return m_client; } 250 DisplayItemClient client() const { return DisplayItemClient(m_clientObject, m_subClientId); }
255 Type type() const { return m_type; } 251 Type type() const { return m_type; }
256 252
257 void setScope(unsigned scope) { m_scope = scope; } 253 void setScope(unsigned scope) { m_scope = scope; }
258 unsigned scope() { return m_scope; } 254 unsigned scope() { return m_scope; }
259 255
260 // Size of this object in memory, used to move it with memcpy. 256 // Size of this object in memory, used to move it with memcpy.
261 // This is not sizeof(*this), because it needs to account for the size of 257 // This is not sizeof(*this), because it needs to account for the size of
262 // the derived class (i.e. runtime type). Derived classes are expected to 258 // the derived class (i.e. runtime type). Derived classes are expected to
263 // supply this to the DisplayItem constructor. 259 // supply this to the DisplayItem constructor.
264 size_t derivedSize() const { return m_derivedSize; } 260 size_t derivedSize() const { return m_derivedSize; }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipColumnBounds) 308 DEFINE_PAINT_PHASE_CONVERSION_METHOD(ClipColumnBounds)
313 309
314 DEFINE_PAIRED_CATEGORY_METHODS(FloatClip, floatClip) 310 DEFINE_PAIRED_CATEGORY_METHODS(FloatClip, floatClip)
315 DEFINE_PAINT_PHASE_CONVERSION_METHOD(FloatClip) 311 DEFINE_PAINT_PHASE_CONVERSION_METHOD(FloatClip)
316 312
317 DEFINE_PAIRED_CATEGORY_METHODS(Scroll, scroll) 313 DEFINE_PAIRED_CATEGORY_METHODS(Scroll, scroll)
318 DEFINE_PAINT_PHASE_CONVERSION_METHOD(Scroll) 314 DEFINE_PAINT_PHASE_CONVERSION_METHOD(Scroll)
319 315
320 DEFINE_PAIRED_CATEGORY_METHODS(Transform3D, transform3D) 316 DEFINE_PAIRED_CATEGORY_METHODS(Transform3D, transform3D)
321 317
322 DEFINE_PAIRED_CATEGORY_METHODS(Subsequence, subsequence) 318 static bool isCachedType(Type type) { return isCachedDrawingType(type) || ty pe == CachedSubsequence || type == CachedDisplayItemList; }
323 DEFINE_CATEGORY_METHODS(CachedSubsequence)
324 DEFINE_CONVERSION_METHODS(Subsequence, subsequence, CachedSubsequence, cache dSubsequence)
325
326 static bool isCachedType(Type type) { return isCachedDrawingType(type) || is CachedSubsequenceType(type) || type == CachedDisplayItemList; }
327 bool isCached() const { return isCachedType(m_type); } 319 bool isCached() const { return isCachedType(m_type); }
328 static bool isCacheableType(Type type) { return isDrawingType(type) || isSub sequenceType(type); } 320 static bool isCacheableType(Type type) { return isDrawingType(type) || type == Subsequence; }
329 bool isCacheable() const { return !skippedCache() && isCacheableType(m_type) ; } 321 bool isCacheable() const { return !skippedCache() && isCacheableType(m_type) ; }
330 322
331 virtual bool isBegin() const { return false; } 323 virtual bool isBegin() const { return false; }
332 virtual bool isEnd() const { return false; } 324 virtual bool isEnd() const { return false; }
333 325
334 #if ENABLE(ASSERT) 326 #if ENABLE(ASSERT)
335 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return false; } 327 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return false; }
336 virtual bool equals(const DisplayItem& other) const 328 virtual bool equals(const DisplayItem& other) const
337 { 329 {
338 return m_client == other.m_client 330 return client() == other.client()
339 && m_scope == other.m_scope 331 && m_scope == other.m_scope
340 && m_type == other.m_type 332 && m_type == other.m_type
341 && m_derivedSize == other.m_derivedSize 333 && m_derivedSize == other.m_derivedSize
342 && m_skippedCache == other.m_skippedCache; 334 && m_skippedCache == other.m_skippedCache;
343 } 335 }
344 #endif 336 #endif
345 337
346 virtual bool drawsContent() const { return false; } 338 virtual bool drawsContent() const { return false; }
347 339
348 bool isValid() const { return m_client; } 340 bool isValid() const { return m_clientObject; }
349 341
350 #ifndef NDEBUG 342 #ifndef NDEBUG
351 static WTF::String typeAsDebugString(DisplayItem::Type); 343 static WTF::String typeAsDebugString(DisplayItem::Type);
352 const WTF::String& clientDebugString() const { return m_clientDebugString; } 344 const WTF::String& clientDebugString() const { return m_clientDebugString; }
353 void setClientDebugString(const WTF::String& s) { m_clientDebugString = s; } 345 void setClientDebugString(const WTF::String& s) { m_clientDebugString = s; }
354 WTF::String asDebugString() const; 346 WTF::String asDebugString() const;
355 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; 347 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const;
356 #endif 348 #endif
357 349
358 private: 350 private:
359 // The default DisplayItem constructor is only used by 351 // The default DisplayItem constructor is only used by
360 // ContiguousContainer::appendByMoving where an invalid DisplaItem is 352 // ContiguousContainer::appendByMoving where an invalid DisplaItem is
361 // constructed at the source location. 353 // constructed at the source location.
362 template <typename T, unsigned alignment> friend class ContiguousContainer; 354 template <typename T, unsigned alignment> friend class ContiguousContainer;
363 355
364 DisplayItem() 356 DisplayItem()
365 : m_client(nullptr) 357 : m_clientObject(nullptr)
366 , m_scope(0) 358 , m_scope(0)
359 , m_subClientId(0)
367 , m_type(UninitializedType) 360 , m_type(UninitializedType)
368 , m_derivedSize(sizeof(*this)) 361 , m_derivedSize(sizeof(*this))
369 , m_skippedCache(false) 362 , m_skippedCache(false)
370 { } 363 { }
371 364
372 const DisplayItemClient m_client; 365 const DisplayItemClientObject m_clientObject;
373 unsigned m_scope; 366 unsigned m_scope;
367
368 static_assert(kMaxSubDisplayItemClientId == (1 << 6) - 1, "subClientId shoul d fit in 6 bits");
369 const unsigned m_subClientId : 6;
370
374 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits "); 371 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits ");
375 const Type m_type : 16; 372 const Type m_type : 16;
373
376 const unsigned m_derivedSize : 8; // size of the actual derived class 374 const unsigned m_derivedSize : 8; // size of the actual derived class
377 unsigned m_skippedCache : 1; 375 unsigned m_skippedCache : 1;
378 376
379 #ifndef NDEBUG 377 #ifndef NDEBUG
380 WTF::String m_clientDebugString; 378 WTF::String m_clientDebugString;
381 #endif 379 #endif
382 }; 380 };
383 381
384 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { 382 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem {
385 protected: 383 protected:
(...skipping 11 matching lines...) Expand all
397 bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; 395 bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0;
398 #endif 396 #endif
399 397
400 private: 398 private:
401 bool isEnd() const final { return true; } 399 bool isEnd() const final { return true; }
402 }; 400 };
403 401
404 } // namespace blink 402 } // namespace blink
405 403
406 #endif // DisplayItem_h 404 #endif // DisplayItem_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698