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

Unified Diff: ui/compositor/clip_transform_recorder.cc

Issue 1123983002: cc: Use a ListContainer for DisplayItemList to reduce allocations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: displaylistcontainer: fixdcheck Created 5 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
« no previous file with comments | « ui/compositor/clip_transform_recorder.h ('k') | ui/compositor/compositing_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/clip_transform_recorder.cc
diff --git a/ui/compositor/clip_transform_recorder.cc b/ui/compositor/clip_transform_recorder.cc
index 6b8109d803a80a8fcff196948fc4286368fb765b..5e0107d914487759c08d826a7d789c60c1ddc56b 100644
--- a/ui/compositor/clip_transform_recorder.cc
+++ b/ui/compositor/clip_transform_recorder.cc
@@ -23,15 +23,26 @@ ClipTransformRecorder::ClipTransformRecorder(const PaintContext& context)
ClipTransformRecorder::~ClipTransformRecorder() {
if (context_.canvas_)
context_.canvas_->Restore();
- for (auto it = closers_.rbegin(); it != closers_.rend(); ++it)
- context_.list_->AppendItem(make_scoped_ptr(*it));
+ for (Closer c : closers_) {
+ switch (c) {
+ case CLIP_RECT:
+ context_.list_->CreateAndAppendItem<cc::EndClipDisplayItem>();
+ break;
+ case CLIP_PATH:
+ context_.list_->CreateAndAppendItem<cc::EndClipPathDisplayItem>();
+ break;
+ case TRANSFORM:
+ context_.list_->CreateAndAppendItem<cc::EndTransformDisplayItem>();
+ break;
+ }
+ }
}
void ClipTransformRecorder::ClipRect(const gfx::Rect& clip_rect) {
if (context_.list_) {
- context_.list_->AppendItem(
- cc::ClipDisplayItem::Create(clip_rect, std::vector<SkRRect>()));
- closers_.push_back(cc::EndClipDisplayItem::Create().release());
+ auto* item = context_.list_->CreateAndAppendItem<cc::ClipDisplayItem>();
+ item->SetNew(clip_rect, std::vector<SkRRect>());
+ closers_.push_back(CLIP_RECT);
} else {
context_.canvas_->ClipRect(clip_rect);
}
@@ -40,9 +51,9 @@ void ClipTransformRecorder::ClipRect(const gfx::Rect& clip_rect) {
void ClipTransformRecorder::ClipPath(const gfx::Path& clip_path) {
bool anti_alias = false;
if (context_.list_) {
- context_.list_->AppendItem(cc::ClipPathDisplayItem::Create(
- clip_path, SkRegion::kIntersect_Op, anti_alias));
- closers_.push_back(cc::EndClipPathDisplayItem::Create().release());
+ auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>();
+ item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias);
+ closers_.push_back(CLIP_PATH);
} else {
context_.canvas_->ClipPath(clip_path, anti_alias);
}
@@ -52,9 +63,9 @@ void ClipTransformRecorder::ClipPathWithAntiAliasing(
const gfx::Path& clip_path) {
bool anti_alias = true;
if (context_.list_) {
- context_.list_->AppendItem(cc::ClipPathDisplayItem::Create(
- clip_path, SkRegion::kIntersect_Op, anti_alias));
- closers_.push_back(cc::EndClipPathDisplayItem::Create().release());
+ auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>();
+ item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias);
+ closers_.push_back(CLIP_PATH);
} else {
context_.canvas_->ClipPath(clip_path, anti_alias);
}
@@ -62,8 +73,10 @@ void ClipTransformRecorder::ClipPathWithAntiAliasing(
void ClipTransformRecorder::Transform(const gfx::Transform& transform) {
if (context_.list_) {
- context_.list_->AppendItem(cc::TransformDisplayItem::Create(transform));
- closers_.push_back(cc::EndTransformDisplayItem::Create().release());
+ auto* item =
+ context_.list_->CreateAndAppendItem<cc::TransformDisplayItem>();
+ item->SetNew(transform);
+ closers_.push_back(TRANSFORM);
} else {
context_.canvas_->Transform(transform);
}
« no previous file with comments | « ui/compositor/clip_transform_recorder.h ('k') | ui/compositor/compositing_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698