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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "ui/compositor/clip_transform_recorder.h" 5 #include "ui/compositor/clip_transform_recorder.h"
6 6
7 #include "cc/resources/clip_display_item.h" 7 #include "cc/resources/clip_display_item.h"
8 #include "cc/resources/clip_path_display_item.h" 8 #include "cc/resources/clip_path_display_item.h"
9 #include "cc/resources/display_item_list.h" 9 #include "cc/resources/display_item_list.h"
10 #include "cc/resources/transform_display_item.h" 10 #include "cc/resources/transform_display_item.h"
11 #include "ui/compositor/paint_context.h" 11 #include "ui/compositor/paint_context.h"
12 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/path.h" 13 #include "ui/gfx/path.h"
14 14
15 namespace ui { 15 namespace ui {
16 16
17 ClipTransformRecorder::ClipTransformRecorder(const PaintContext& context) 17 ClipTransformRecorder::ClipTransformRecorder(const PaintContext& context)
18 : context_(context) { 18 : context_(context) {
19 if (context_.canvas_) 19 if (context_.canvas_)
20 context_.canvas_->Save(); 20 context_.canvas_->Save();
21 } 21 }
22 22
23 ClipTransformRecorder::~ClipTransformRecorder() { 23 ClipTransformRecorder::~ClipTransformRecorder() {
24 if (context_.canvas_) 24 if (context_.canvas_)
25 context_.canvas_->Restore(); 25 context_.canvas_->Restore();
26 for (auto it = closers_.rbegin(); it != closers_.rend(); ++it) 26 for (Closer c : closers_) {
27 context_.list_->AppendItem(make_scoped_ptr(*it)); 27 switch (c) {
28 case CLIP_RECT:
29 context_.list_->CreateAndAppendItem<cc::EndClipDisplayItem>();
30 break;
31 case CLIP_PATH:
32 context_.list_->CreateAndAppendItem<cc::EndClipPathDisplayItem>();
33 break;
34 case TRANSFORM:
35 context_.list_->CreateAndAppendItem<cc::EndTransformDisplayItem>();
36 break;
37 }
38 }
28 } 39 }
29 40
30 void ClipTransformRecorder::ClipRect(const gfx::Rect& clip_rect) { 41 void ClipTransformRecorder::ClipRect(const gfx::Rect& clip_rect) {
31 if (context_.list_) { 42 if (context_.list_) {
32 context_.list_->AppendItem( 43 auto* item = context_.list_->CreateAndAppendItem<cc::ClipDisplayItem>();
33 cc::ClipDisplayItem::Create(clip_rect, std::vector<SkRRect>())); 44 item->SetNew(clip_rect, std::vector<SkRRect>());
34 closers_.push_back(cc::EndClipDisplayItem::Create().release()); 45 closers_.push_back(CLIP_RECT);
35 } else { 46 } else {
36 context_.canvas_->ClipRect(clip_rect); 47 context_.canvas_->ClipRect(clip_rect);
37 } 48 }
38 } 49 }
39 50
40 void ClipTransformRecorder::ClipPath(const gfx::Path& clip_path) { 51 void ClipTransformRecorder::ClipPath(const gfx::Path& clip_path) {
41 bool anti_alias = false; 52 bool anti_alias = false;
42 if (context_.list_) { 53 if (context_.list_) {
43 context_.list_->AppendItem(cc::ClipPathDisplayItem::Create( 54 auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>();
44 clip_path, SkRegion::kIntersect_Op, anti_alias)); 55 item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias);
45 closers_.push_back(cc::EndClipPathDisplayItem::Create().release()); 56 closers_.push_back(CLIP_PATH);
46 } else { 57 } else {
47 context_.canvas_->ClipPath(clip_path, anti_alias); 58 context_.canvas_->ClipPath(clip_path, anti_alias);
48 } 59 }
49 } 60 }
50 61
51 void ClipTransformRecorder::ClipPathWithAntiAliasing( 62 void ClipTransformRecorder::ClipPathWithAntiAliasing(
52 const gfx::Path& clip_path) { 63 const gfx::Path& clip_path) {
53 bool anti_alias = true; 64 bool anti_alias = true;
54 if (context_.list_) { 65 if (context_.list_) {
55 context_.list_->AppendItem(cc::ClipPathDisplayItem::Create( 66 auto* item = context_.list_->CreateAndAppendItem<cc::ClipPathDisplayItem>();
56 clip_path, SkRegion::kIntersect_Op, anti_alias)); 67 item->SetNew(clip_path, SkRegion::kIntersect_Op, anti_alias);
57 closers_.push_back(cc::EndClipPathDisplayItem::Create().release()); 68 closers_.push_back(CLIP_PATH);
58 } else { 69 } else {
59 context_.canvas_->ClipPath(clip_path, anti_alias); 70 context_.canvas_->ClipPath(clip_path, anti_alias);
60 } 71 }
61 } 72 }
62 73
63 void ClipTransformRecorder::Transform(const gfx::Transform& transform) { 74 void ClipTransformRecorder::Transform(const gfx::Transform& transform) {
64 if (context_.list_) { 75 if (context_.list_) {
65 context_.list_->AppendItem(cc::TransformDisplayItem::Create(transform)); 76 auto* item =
66 closers_.push_back(cc::EndTransformDisplayItem::Create().release()); 77 context_.list_->CreateAndAppendItem<cc::TransformDisplayItem>();
78 item->SetNew(transform);
79 closers_.push_back(TRANSFORM);
67 } else { 80 } else {
68 context_.canvas_->Transform(transform); 81 context_.canvas_->Transform(transform);
69 } 82 }
70 } 83 }
71 84
72 } // namespace ui 85 } // namespace ui
OLDNEW
« 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