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

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

Issue 2894093002: Don't access DisplayItemClient::VisualRect() for cached display items. (Closed)
Patch Set: - Created 3 years, 7 months 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h b/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h
index d5f344e605f4b55ad17dfdc5ccdad84f39636a49..61bd2e45e257b12281350348fed9980a9aea68c7 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h
+++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h
@@ -20,7 +20,7 @@
namespace blink {
class GraphicsContext;
-class IntRect;
+class LayoutSize;
class WebDisplayItemList;
class PLATFORM_EXPORT DisplayItem {
@@ -199,6 +199,7 @@ class PLATFORM_EXPORT DisplayItem {
DisplayItem(const DisplayItemClient& client, Type type, size_t derived_size)
: client_(&client),
+ visual_rect_(client.VisualRect()),
type_(type),
derived_size_(derived_size),
skipped_cache_(false)
@@ -233,6 +234,12 @@ class PLATFORM_EXPORT DisplayItem {
DCHECK(client_);
return *client_;
}
+
+ // This equals to Client().VisualRect() as long as the client is alive and is
+ // not invalidated. Otherwise it saves the previous visual rect of the client.
+ // See DisplayItemClient::VisualRect() about its coordinate space.
+ const LayoutRect& VisualRect() const { return visual_rect_; }
+
Type GetType() const { return type_; }
// Size of this object in memory, used to move it with memcpy.
@@ -246,9 +253,11 @@ class PLATFORM_EXPORT DisplayItem {
void SetSkippedCache() { skipped_cache_ = true; }
bool SkippedCache() const { return skipped_cache_; }
- // TODO(wkorman): Only DrawingDisplayItem needs the visual rect argument.
- // Consider refactoring class hierarchy to make this more explicit.
- virtual void AppendToWebDisplayItemList(const IntRect&,
+ // Appends this display item to the WebDisplayItemList, if applicable.
+ // |visual_rect_offset| is the offset between the space of the GraphicsLayer
+ // which owns the display item and the coordinate space of VisualRect().
+ // TODO(wangxianzhu): Remove the parameter for slimming paint v2.
+ virtual void AppendToWebDisplayItemList(const LayoutSize& visual_rect_offset,
WebDisplayItemList*) const {}
// See comments of enum Type for usage of the following macros.
@@ -351,6 +360,7 @@ class PLATFORM_EXPORT DisplayItem {
// constructed at the source location.
template <typename T, unsigned alignment>
friend class ContiguousContainer;
+ friend class DisplayItemList;
DisplayItem()
: client_(nullptr),
@@ -359,6 +369,8 @@ class PLATFORM_EXPORT DisplayItem {
skipped_cache_(false) {}
const DisplayItemClient* client_;
+ LayoutRect visual_rect_;
+
static_assert(kTypeLast < (1 << 16),
"DisplayItem::Type should fit in 16 bits");
const Type type_ : 16;

Powered by Google App Engine
This is Rietveld 408576698