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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 bool red = true; | 64 bool red = true; |
65 while (!draw_rect.IsEmpty()) { | 65 while (!draw_rect.IsEmpty()) { |
66 SkPaint paint; | 66 SkPaint paint; |
67 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); | 67 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); |
68 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); | 68 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); |
69 draw_rect.Inset(1, 1); | 69 draw_rect.Inset(1, 1); |
70 } | 70 } |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 void FakeContentLayerClient::PaintContentsToDisplayList( | 74 scoped_refptr<DisplayItemList> |
75 DisplayItemList* display_list, | 75 FakeContentLayerClient::PaintContentsToDisplayList( |
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 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); |
82 ClipDisplayItem::Create(clip, std::vector<SkRRect>())); | 82 list->AppendItem(ClipDisplayItem::Create(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 list->AppendItem(DrawingDisplayItem::Create(picture)); |
94 } | 94 } |
95 | 95 |
96 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); | 96 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); |
97 it != draw_bitmaps_.end(); ++it) { | 97 it != draw_bitmaps_.end(); ++it) { |
98 if (!it->transform.IsIdentity()) { | 98 if (!it->transform.IsIdentity()) { |
99 display_list->AppendItem(TransformDisplayItem::Create(it->transform)); | 99 list->AppendItem(TransformDisplayItem::Create(it->transform)); |
100 } | 100 } |
101 canvas = skia::SharePtr( | 101 canvas = skia::SharePtr( |
102 recorder.beginRecording(it->bitmap.width(), it->bitmap.height())); | 102 recorder.beginRecording(it->bitmap.width(), it->bitmap.height())); |
103 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint); | 103 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint); |
104 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 104 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
105 display_list->AppendItem(DrawingDisplayItem::Create(picture)); | 105 list->AppendItem(DrawingDisplayItem::Create(picture)); |
106 if (!it->transform.IsIdentity()) { | 106 if (!it->transform.IsIdentity()) { |
107 display_list->AppendItem(EndTransformDisplayItem::Create()); | 107 list->AppendItem(EndTransformDisplayItem::Create()); |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 if (fill_with_nonsolid_color_) { | 111 if (fill_with_nonsolid_color_) { |
112 gfx::RectF draw_rect = clip; | 112 gfx::RectF draw_rect = clip; |
113 bool red = true; | 113 bool red = true; |
114 while (!draw_rect.IsEmpty()) { | 114 while (!draw_rect.IsEmpty()) { |
115 SkPaint paint; | 115 SkPaint paint; |
116 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); | 116 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); |
117 canvas = skia::SharePtr( | 117 canvas = skia::SharePtr( |
118 recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); | 118 recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); |
119 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); | 119 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); |
120 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 120 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
121 display_list->AppendItem(DrawingDisplayItem::Create(picture)); | 121 list->AppendItem(DrawingDisplayItem::Create(picture)); |
122 draw_rect.Inset(1, 1); | 122 draw_rect.Inset(1, 1); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 display_list->AppendItem(EndClipDisplayItem::Create()); | 126 list->AppendItem(EndClipDisplayItem::Create()); |
| 127 return list; |
127 } | 128 } |
128 | 129 |
129 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 130 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
130 | 131 |
131 } // namespace cc | 132 } // namespace cc |
OLD | NEW |