diff options
author | danakj <danakj@chromium.org> | 2015-05-07 11:26:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-07 18:26:37 +0000 |
commit | f15802914bd7a8f5ea8c4d7893e9c79450804714 (patch) | |
tree | a05434d37992aea271d636e15e6c7ae1c0402d28 /cc/test/fake_content_layer_client.cc | |
parent | c464a50a451d6405eb9dcc84889f2da3710c0f4e (diff) | |
download | chromium_src-f15802914bd7a8f5ea8c4d7893e9c79450804714.zip chromium_src-f15802914bd7a8f5ea8c4d7893e9c79450804714.tar.gz chromium_src-f15802914bd7a8f5ea8c4d7893e9c79450804714.tar.bz2 |
cc: Use a ListContainer for DisplayItemList to reduce allocations.
Currently every DisplayItem is malloced/freed individually. Follow the
pattern used for DrawQuads instead, using ListContainer to allocate
log(n) times instead of once for each item. This replaces each
DisplayFooItem::Create(...) with a default constructor and a
DisplayFooItem::SetNew(...) that must be called on newly constructed
items before they are used.
This patch changes the time to do UpdateLayers (after making
gfx::ImageSkiaReps immutable cuz they dominate times for now) for a
single tab loading spinner from .174ms to .167ms on a linux x620,
giving a 4% reduction in frame record time. I used a mean of 3000
samples in each run to reduce noise.
R=ajuma, enne
BUG=466426
Review URL: https://codereview.chromium.org/1123983002
Cr-Commit-Position: refs/heads/master@{#328797}
Diffstat (limited to 'cc/test/fake_content_layer_client.cc')
-rw-r--r-- | cc/test/fake_content_layer_client.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/cc/test/fake_content_layer_client.cc b/cc/test/fake_content_layer_client.cc index c21d87b..dce5e6e 100644 --- a/cc/test/fake_content_layer_client.cc +++ b/cc/test/fake_content_layer_client.cc @@ -78,8 +78,8 @@ void FakeContentLayerClient::PaintContentsToDisplayList( SkPictureRecorder recorder; skia::RefPtr<SkCanvas> canvas; skia::RefPtr<SkPicture> picture; - display_list->AppendItem( - ClipDisplayItem::Create(clip, std::vector<SkRRect>())); + auto* item = display_list->CreateAndAppendItem<ClipDisplayItem>(); + item->SetNew(clip, std::vector<SkRRect>()); for (RectPaintVector::const_iterator it = draw_rects_.begin(); it != draw_rects_.end(); ++it) { @@ -90,21 +90,24 @@ void FakeContentLayerClient::PaintContentsToDisplayList( canvas->drawRectCoords(draw_rect.x(), draw_rect.y(), draw_rect.width(), draw_rect.height(), paint); picture = skia::AdoptRef(recorder.endRecordingAsPicture()); - display_list->AppendItem(DrawingDisplayItem::Create(picture)); + auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); + item->SetNew(picture.Pass()); } for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); it != draw_bitmaps_.end(); ++it) { if (!it->transform.IsIdentity()) { - display_list->AppendItem(TransformDisplayItem::Create(it->transform)); + auto* item = display_list->CreateAndAppendItem<TransformDisplayItem>(); + item->SetNew(it->transform); } canvas = skia::SharePtr( recorder.beginRecording(it->bitmap.width(), it->bitmap.height())); canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint); picture = skia::AdoptRef(recorder.endRecordingAsPicture()); - display_list->AppendItem(DrawingDisplayItem::Create(picture)); + auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); + item->SetNew(picture.Pass()); if (!it->transform.IsIdentity()) { - display_list->AppendItem(EndTransformDisplayItem::Create()); + display_list->CreateAndAppendItem<EndTransformDisplayItem>(); } } @@ -118,12 +121,13 @@ void FakeContentLayerClient::PaintContentsToDisplayList( recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); picture = skia::AdoptRef(recorder.endRecordingAsPicture()); - display_list->AppendItem(DrawingDisplayItem::Create(picture)); + auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); + item->SetNew(picture.Pass()); draw_rect.Inset(1, 1); } } - display_list->AppendItem(EndClipDisplayItem::Create()); + display_list->CreateAndAppendItem<EndClipDisplayItem>(); } bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |