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 "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
10 #include "third_party/skia/include/core/SkPictureRecorder.h" | 10 #include "third_party/skia/include/core/SkPictureRecorder.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 SkPictureRecorder recorder; | 62 SkPictureRecorder recorder; |
63 skia::RefPtr<SkCanvas> canvas; | 63 skia::RefPtr<SkCanvas> canvas; |
64 skia::RefPtr<SkPicture> picture; | 64 skia::RefPtr<SkPicture> picture; |
65 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); | 65 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); |
66 list->AppendItem(ClipDisplayItem::Create(clip, std::vector<SkRRect>())); | 66 list->AppendItem(ClipDisplayItem::Create(clip, std::vector<SkRRect>())); |
67 | 67 |
68 for (RectPaintVector::const_iterator it = draw_rects_.begin(); | 68 for (RectPaintVector::const_iterator it = draw_rects_.begin(); |
69 it != draw_rects_.end(); ++it) { | 69 it != draw_rects_.end(); ++it) { |
70 const gfx::RectF& draw_rect = it->first; | 70 const gfx::RectF& draw_rect = it->first; |
71 const SkPaint& paint = it->second; | 71 const SkPaint& paint = it->second; |
72 canvas = | 72 canvas = skia::SharePtr( |
73 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); | 73 recorder.beginRecording(draw_rect.width(), draw_rect.height())); |
74 canvas->drawRectCoords(0.f, 0.f, draw_rect.width(), draw_rect.height(), | 74 canvas->drawRectCoords(0.f, 0.f, draw_rect.width(), draw_rect.height(), |
75 paint); | 75 paint); |
76 picture = skia::AdoptRef(recorder.endRecording()); | 76 picture = skia::AdoptRef(recorder.endRecording()); |
77 list->AppendItem(DrawingDisplayItem::Create(picture)); | 77 list->AppendItem(DrawingDisplayItem::Create( |
| 78 picture, gfx::PointF(draw_rect.x(), draw_rect.y()))); |
78 } | 79 } |
79 | 80 |
80 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); | 81 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); |
81 it != draw_bitmaps_.end(); ++it) { | 82 it != draw_bitmaps_.end(); ++it) { |
82 canvas = skia::SharePtr( | 83 canvas = skia::SharePtr( |
83 recorder.beginRecording(it->bitmap.width(), it->bitmap.height())); | 84 recorder.beginRecording(it->bitmap.width(), it->bitmap.height())); |
84 canvas->drawBitmap(it->bitmap, 0.f, 0.f, &it->paint); | 85 canvas->drawBitmap(it->bitmap, 0.f, 0.f, &it->paint); |
85 picture = skia::AdoptRef(recorder.endRecording()); | 86 picture = skia::AdoptRef(recorder.endRecording()); |
86 list->AppendItem(DrawingDisplayItem::Create(picture)); | 87 list->AppendItem(DrawingDisplayItem::Create( |
| 88 picture, gfx::PointF(it->point.x(), it->point.y()))); |
87 } | 89 } |
88 | 90 |
89 if (fill_with_nonsolid_color_) { | 91 if (fill_with_nonsolid_color_) { |
90 gfx::RectF draw_rect = clip; | 92 gfx::RectF draw_rect = clip; |
91 bool red = true; | 93 bool red = true; |
92 while (!draw_rect.IsEmpty()) { | 94 while (!draw_rect.IsEmpty()) { |
93 SkPaint paint; | 95 SkPaint paint; |
94 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); | 96 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); |
95 canvas = skia::SharePtr( | 97 canvas = |
96 recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); | 98 skia::SharePtr(recorder.beginRecording(clip.width(), clip.height())); |
97 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); | 99 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); |
98 picture = skia::AdoptRef(recorder.endRecording()); | 100 picture = skia::AdoptRef(recorder.endRecording()); |
99 list->AppendItem(DrawingDisplayItem::Create(picture)); | 101 list->AppendItem(DrawingDisplayItem::Create(picture, gfx::PointF())); |
100 draw_rect.Inset(1, 1); | 102 draw_rect.Inset(1, 1); |
101 } | 103 } |
102 } | 104 } |
103 | 105 |
104 list->AppendItem(EndClipDisplayItem::Create()); | 106 list->AppendItem(EndClipDisplayItem::Create()); |
105 return list; | 107 return list; |
106 } | 108 } |
107 | 109 |
108 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 110 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
109 | 111 |
110 } // namespace cc | 112 } // namespace cc |
OLD | NEW |