Commit e94d2968 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[CI] Allow all display items to be cacheable

We treated only DrawingDisplayItem as cacheable before SlimmingPaintV175
because other display items were all about paint properties which are
not feasible to be cached (mostly because they are paired and sometimes
don't have unique id).

Now we have removed paired display items, thus the remaining types of
display items are all eligible to be cached.

This prepares for making HitTestDisplayItem not DrawingDisplayItem to
reduce its size, etc.

Change-Id: I28bd5533d3b85a67fc16e90aea059115b51188e7
Reviewed-on: https://chromium-review.googlesource.com/c/1329805Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607497}
parent b00f729f
......@@ -36,13 +36,11 @@ void EllipsisBoxPainter::PaintEllipsis(const PaintInfo& paint_info,
box_origin.MoveBy(paint_offset);
GraphicsContext& context = paint_info.context;
DisplayItem::Type display_item_type =
DisplayItem::PaintPhaseToDrawingType(paint_info.phase);
if (DrawingRecorder::UseCachedDrawingIfPossible(context, ellipsis_box_,
display_item_type))
paint_info.phase))
return;
DrawingRecorder recorder(context, ellipsis_box_, display_item_type);
DrawingRecorder recorder(context, ellipsis_box_, paint_info.phase);
LayoutRect box_rect(box_origin,
LayoutSize(ellipsis_box_.LogicalWidth(),
......
......@@ -240,12 +240,10 @@ void InlineFlowBoxPainter::PaintMask(const PaintInfo& paint_info,
return;
if (DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, inline_flow_box_,
DisplayItem::PaintPhaseToDrawingType(paint_info.phase)))
paint_info.context, inline_flow_box_, paint_info.phase))
return;
DrawingRecorder recorder(
paint_info.context, inline_flow_box_,
DisplayItem::PaintPhaseToDrawingType(paint_info.phase));
DrawingRecorder recorder(paint_info.context, inline_flow_box_,
paint_info.phase);
LayoutRect paint_rect = AdjustedPaintRect(paint_offset);
......
......@@ -147,11 +147,9 @@ void InlineTextBoxPainter::Paint(const PaintInfo& paint_info,
base::Optional<DrawingRecorder> recorder;
if (paint_info.phase != PaintPhase::kTextClip) {
if (DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, inline_text_box_,
DisplayItem::PaintPhaseToDrawingType(paint_info.phase)))
paint_info.context, inline_text_box_, paint_info.phase))
return;
recorder.emplace(paint_info.context, inline_text_box_,
DisplayItem::PaintPhaseToDrawingType(paint_info.phase));
recorder.emplace(paint_info.context, inline_text_box_, paint_info.phase);
}
GraphicsContext& context = paint_info.context;
......
......@@ -325,12 +325,10 @@ void NGBoxFragmentPainter::PaintBlockFlowContents(
if (paint_info.phase == PaintPhase::kMask) {
if (DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, box_fragment_,
DisplayItem::PaintPhaseToDrawingType(paint_info.phase)))
paint_info.context, box_fragment_, paint_info.phase))
return;
DrawingRecorder recorder(
paint_info.context, box_fragment_,
DisplayItem::PaintPhaseToDrawingType(paint_info.phase));
DrawingRecorder recorder(paint_info.context, box_fragment_,
paint_info.phase);
PaintMask(paint_info, paint_offset);
return;
}
......@@ -803,11 +801,9 @@ void NGBoxFragmentPainter::PaintTextChild(const NGPaintFragment& text_fragment,
base::Optional<DrawingRecorder> recorder;
if (paint_info.phase != PaintPhase::kTextClip) {
if (DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, text_fragment,
DisplayItem::PaintPhaseToDrawingType(paint_info.phase)))
paint_info.context, text_fragment, paint_info.phase))
return;
recorder.emplace(paint_info.context, text_fragment,
DisplayItem::PaintPhaseToDrawingType(paint_info.phase));
recorder.emplace(paint_info.context, text_fragment, paint_info.phase);
}
const NGPhysicalTextFragment& physical_text_fragment =
......
......@@ -93,15 +93,13 @@ void SVGInlineTextBoxPainter::Paint(const PaintInfo& paint_info,
if (!TextShouldBePainted(text_layout_object))
return;
DisplayItem::Type display_item_type =
DisplayItem::PaintPhaseToDrawingType(paint_info.phase);
if (!DrawingRecorder::UseCachedDrawingIfPossible(
paint_info.context, svg_inline_text_box_, display_item_type)) {
paint_info.context, svg_inline_text_box_, paint_info.phase)) {
LayoutObject& parent_layout_object = ParentInlineLayoutObject();
const ComputedStyle& style = parent_layout_object.StyleRef();
DrawingRecorder recorder(paint_info.context, svg_inline_text_box_,
display_item_type);
paint_info.phase);
InlineTextBoxPainter text_painter(svg_inline_text_box_);
const DocumentMarkerVector& markers_to_paint =
text_painter.ComputeMarkersToPaint();
......
......@@ -201,8 +201,7 @@ scoped_refptr<cc::PictureLayer> ContentLayerClientImpl::UpdateCcPictureLayer(
json->SetArray("displayItems",
paint_artifact->GetDisplayItemList().SubsequenceAsJSON(
chunk.begin_index, chunk.end_index,
DisplayItemList::kSkipNonDrawings |
DisplayItemList::kShownOnlyDisplayItemTypes));
DisplayItemList::kShownOnlyDisplayItemTypes));
paint_chunk_debug_data_->PushObject(std::move(json));
}
#endif
......
......@@ -140,8 +140,8 @@ but can be other Blink objects which get painted, such as inline boxes and drag
images.
*** note
It is illegal for there to be two drawings with the same ID in a display item
list, except for drawings that are marked uncacheable
It is illegal for there to be two display items with the same ID in a display
item list, except for display items that are marked uncacheable
(see [DisplayItemCacheSkipper](DisplayItemCacheSkipper.h)).
***
......@@ -179,10 +179,10 @@ a `PaintController`.
the *current* paint artifact, and *new* display items and paint chunks, which
are added as content is painted.
Painters should call `PaintController::useCachedDrawingIfPossible()` or
`PaintController::useCachedSubsequenceIfPossible()` and if the function returns
Painters should call `PaintController::UseCachedItemIfPossible()` or
`PaintController::UseCachedSubsequenceIfPossible()` and if the function returns
`true`, existing display items that are still valid in the *current* paint artifact
will be reused and the painter should skip real painting of the drawing or subsequence.
will be reused and the painter should skip real painting of the item or subsequence.
When the new display items have been populated, clients call
`commitNewDisplayItems`, which replaces the previous artifact with the new data,
......
......@@ -153,8 +153,7 @@ class PLATFORM_EXPORT DisplayItem {
type_(type),
derived_size_(derived_size),
fragment_(0),
// TODO(pdr): Should this return true for IsScrollHitTestType too?
is_cacheable_(client.IsCacheable() && IsDrawingType(type)),
is_cacheable_(client.IsCacheable()),
is_tombstone_(false) {
// |derived_size| must fit in |derived_size_|.
// If it doesn't, enlarge |derived_size_| and fix this assert.
......@@ -196,7 +195,7 @@ class PLATFORM_EXPORT DisplayItem {
// Visual rect can change without needing invalidation of the client, e.g.
// when ancestor clip changes. This is called from PaintController::
// UseCachedDrawingIfPossible() to update the visual rect of a cached display
// UseCachedItemIfPossible() to update the visual rect of a cached display
// item.
void UpdateVisualRect() { visual_rect_ = FloatRect(client_->VisualRect()); }
......
......@@ -41,9 +41,6 @@ void DisplayItemList::AppendSubsequenceAsJSON(size_t begin_index,
std::unique_ptr<JSONObject> json = JSONObject::Create();
const auto& item = (*this)[i];
if ((flags & kSkipNonDrawings) && !item.IsDrawing())
continue;
json->SetInteger("index", i);
if (flags & kShownOnlyDisplayItemTypes) {
......
......@@ -74,10 +74,9 @@ class PLATFORM_EXPORT DisplayItemList
#if DCHECK_IS_ON()
enum JsonOptions {
kDefault = 0,
kShowPaintRecords = 1,
kSkipNonDrawings = 1 << 1,
kClientKnownToBeAlive = 1 << 2,
kShownOnlyDisplayItemTypes = 1 << 3
kShowPaintRecords = 1 << 0,
kClientKnownToBeAlive = 1 << 1,
kShownOnlyDisplayItemTypes = 1 << 2
};
typedef unsigned JsonFlags;
......
......@@ -34,7 +34,7 @@ DrawingRecorder::DrawingRecorder(GraphicsContext& context,
if (context.GetPaintController().DisplayItemConstructionIsDisabled())
return;
// Must check DrawingRecorder::useCachedDrawingIfPossible before creating the
// Must check DrawingRecorder::UseCachedDrawingIfPossible before creating the
// DrawingRecorder.
DCHECK(RuntimeEnabledFeatures::PaintUnderInvalidationCheckingEnabled() ||
!UseCachedDrawingIfPossible(context_, client_, type_));
......
......@@ -27,8 +27,7 @@ class PLATFORM_EXPORT DrawingRecorder final {
static bool UseCachedDrawingIfPossible(GraphicsContext& context,
const DisplayItemClient& client,
DisplayItem::Type type) {
return context.GetPaintController().UseCachedDrawingIfPossible(client,
type);
return context.GetPaintController().UseCachedItemIfPossible(client, type);
}
static bool UseCachedDrawingIfPossible(GraphicsContext& context,
......
......@@ -18,8 +18,7 @@ void HitTestDisplayItem::Record(GraphicsContext& context,
if (paint_controller.DisplayItemConstructionIsDisabled())
return;
if (paint_controller.UseCachedDrawingIfPossible(client,
DisplayItem::kHitTest))
if (paint_controller.UseCachedItemIfPossible(client, DisplayItem::kHitTest))
return;
paint_controller.CreateAndAppend<HitTestDisplayItem>(client, hit_test_rect);
......
......@@ -29,11 +29,8 @@ PaintController::~PaintController() {
DCHECK(new_display_item_list_.IsEmpty());
}
bool PaintController::UseCachedDrawingIfPossible(
const DisplayItemClient& client,
DisplayItem::Type type) {
DCHECK(DisplayItem::IsDrawingType(type));
bool PaintController::UseCachedItemIfPossible(const DisplayItemClient& client,
DisplayItem::Type type) {
if (usage_ == kTransient)
return false;
......
......@@ -129,10 +129,10 @@ class PLATFORM_EXPORT PaintController {
ProcessNewItem(display_item);
}
// Tries to find the cached drawing display item corresponding to the given
// Tries to find the cached display item corresponding to the given
// parameters. If found, appends the cached display item to the new display
// list and returns true. Otherwise returns false.
bool UseCachedDrawingIfPossible(const DisplayItemClient&, DisplayItem::Type);
bool UseCachedItemIfPossible(const DisplayItemClient&, DisplayItem::Type);
// Tries to find the cached subsequence corresponding to the given parameters.
// If found, copies the cache subsequence to the new display list and returns
......@@ -255,7 +255,7 @@ class PLATFORM_EXPORT PaintController {
// However, the current algorithm allows the following situations even if
// ClientCacheIsValid() is true for a client during painting:
// 1. The client paints a new display item that is not cached:
// UseCachedDrawingIfPossible() returns false for the display item and the
// UseCachedItemIfPossible() returns false for the display item and the
// newly painted display item will be added into the cache. This situation
// has slight performance hit (see FindOutOfOrderCachedItemForward()) so we
// print a warning in the situation and should keep it rare.
......@@ -367,7 +367,7 @@ class PLATFORM_EXPORT PaintController {
// Stores indices to valid cacheable display items in
// current_paint_artifact_.GetDisplayItemList() that have not been matched by
// requests of cached display items (using UseCachedDrawingIfPossible() and
// requests of cached display items (using UseCachedItemIfPossible() and
// UseCachedSubsequenceIfPossible()) during sequential matching. The indexed
// items will be matched by later out-of-order requests of cached display
// items. This ensures that when out-of-order cached display items are
......@@ -394,7 +394,7 @@ class PLATFORM_EXPORT PaintController {
IndicesByClientMap new_paint_chunk_indices_by_client_;
#endif
// These are set in UseCachedDrawingIfPossible() and
// These are set in UseCachedItemIfPossible() and
// UseCachedSubsequenceIfPossible() when we could use cached drawing or
// subsequence and under-invalidation checking is on, indicating the begin and
// end of the cached drawing or subsequence in the current list. The functions
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment