OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/test/fake_content_layer_client.h" | 5 #include "cc/test/fake_content_layer_client.h" |
6 | 6 |
7 #include "cc/resources/clip_display_item.h" | 7 #include "cc/resources/clip_display_item.h" |
8 #include "cc/resources/drawing_display_item.h" | 8 #include "cc/resources/drawing_display_item.h" |
9 #include "cc/resources/transform_display_item.h" | 9 #include "cc/resources/transform_display_item.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 void FakeContentLayerClient::PaintContentsToDisplayList( | 74 void FakeContentLayerClient::PaintContentsToDisplayList( |
75 DisplayItemList* display_list, | 75 DisplayItemList* display_list, |
76 const gfx::Rect& clip, | 76 const gfx::Rect& clip, |
77 PaintingControlSetting painting_control) { | 77 PaintingControlSetting painting_control) { |
78 SkPictureRecorder recorder; | 78 SkPictureRecorder recorder; |
79 skia::RefPtr<SkCanvas> canvas; | 79 skia::RefPtr<SkCanvas> canvas; |
80 skia::RefPtr<SkPicture> picture; | 80 skia::RefPtr<SkPicture> picture; |
81 display_list->AppendItem( | 81 auto* item = display_list->CreateAndAppendItem<ClipDisplayItem>(); |
82 ClipDisplayItem::Create(clip, std::vector<SkRRect>())); | 82 item->SetNew(clip, std::vector<SkRRect>()); |
83 | 83 |
84 for (RectPaintVector::const_iterator it = draw_rects_.begin(); | 84 for (RectPaintVector::const_iterator it = draw_rects_.begin(); |
85 it != draw_rects_.end(); ++it) { | 85 it != draw_rects_.end(); ++it) { |
86 const gfx::RectF& draw_rect = it->first; | 86 const gfx::RectF& draw_rect = it->first; |
87 const SkPaint& paint = it->second; | 87 const SkPaint& paint = it->second; |
88 canvas = | 88 canvas = |
89 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); | 89 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); |
90 canvas->drawRectCoords(draw_rect.x(), draw_rect.y(), draw_rect.width(), | 90 canvas->drawRectCoords(draw_rect.x(), draw_rect.y(), draw_rect.width(), |
91 draw_rect.height(), paint); | 91 draw_rect.height(), paint); |
92 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 92 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
93 display_list->AppendItem(DrawingDisplayItem::Create(picture)); | 93 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); |
| 94 item->SetNew(picture.Pass()); |
94 } | 95 } |
95 | 96 |
96 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); | 97 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); |
97 it != draw_bitmaps_.end(); ++it) { | 98 it != draw_bitmaps_.end(); ++it) { |
98 if (!it->transform.IsIdentity()) { | 99 if (!it->transform.IsIdentity()) { |
99 display_list->AppendItem(TransformDisplayItem::Create(it->transform)); | 100 auto* item = display_list->CreateAndAppendItem<TransformDisplayItem>(); |
| 101 item->SetNew(it->transform); |
100 } | 102 } |
101 canvas = skia::SharePtr( | 103 canvas = skia::SharePtr( |
102 recorder.beginRecording(it->bitmap.width(), it->bitmap.height())); | 104 recorder.beginRecording(it->bitmap.width(), it->bitmap.height())); |
103 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint); | 105 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint); |
104 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 106 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
105 display_list->AppendItem(DrawingDisplayItem::Create(picture)); | 107 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); |
| 108 item->SetNew(picture.Pass()); |
106 if (!it->transform.IsIdentity()) { | 109 if (!it->transform.IsIdentity()) { |
107 display_list->AppendItem(EndTransformDisplayItem::Create()); | 110 display_list->CreateAndAppendItem<EndTransformDisplayItem>(); |
108 } | 111 } |
109 } | 112 } |
110 | 113 |
111 if (fill_with_nonsolid_color_) { | 114 if (fill_with_nonsolid_color_) { |
112 gfx::RectF draw_rect = clip; | 115 gfx::RectF draw_rect = clip; |
113 bool red = true; | 116 bool red = true; |
114 while (!draw_rect.IsEmpty()) { | 117 while (!draw_rect.IsEmpty()) { |
115 SkPaint paint; | 118 SkPaint paint; |
116 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); | 119 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); |
117 canvas = skia::SharePtr( | 120 canvas = skia::SharePtr( |
118 recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); | 121 recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); |
119 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); | 122 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); |
120 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 123 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
121 display_list->AppendItem(DrawingDisplayItem::Create(picture)); | 124 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); |
| 125 item->SetNew(picture.Pass()); |
122 draw_rect.Inset(1, 1); | 126 draw_rect.Inset(1, 1); |
123 } | 127 } |
124 } | 128 } |
125 | 129 |
126 display_list->AppendItem(EndClipDisplayItem::Create()); | 130 display_list->CreateAndAppendItem<EndClipDisplayItem>(); |
127 } | 131 } |
128 | 132 |
129 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 133 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
130 | 134 |
131 } // namespace cc | 135 } // namespace cc |
OLD | NEW |