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 = skia::SharePtr( | 72 canvas = |
73 recorder.beginRecording(draw_rect.width(), draw_rect.height())); | 73 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); |
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( | 77 list->AppendItem(DrawingDisplayItem::Create(picture)); |
78 picture, gfx::PointF(draw_rect.x(), draw_rect.y()))); | |
79 } | 78 } |
80 | 79 |
81 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); | 80 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); |
82 it != draw_bitmaps_.end(); ++it) { | 81 it != draw_bitmaps_.end(); ++it) { |
83 canvas = skia::SharePtr( | 82 canvas = skia::SharePtr( |
84 recorder.beginRecording(it->bitmap.width(), it->bitmap.height())); | 83 recorder.beginRecording(it->bitmap.width(), it->bitmap.height())); |
85 canvas->drawBitmap(it->bitmap, 0.f, 0.f, &it->paint); | 84 canvas->drawBitmap(it->bitmap, 0.f, 0.f, &it->paint); |
86 picture = skia::AdoptRef(recorder.endRecording()); | 85 picture = skia::AdoptRef(recorder.endRecording()); |
87 list->AppendItem(DrawingDisplayItem::Create( | 86 list->AppendItem(DrawingDisplayItem::Create(picture)); |
88 picture, gfx::PointF(it->point.x(), it->point.y()))); | |
89 } | 87 } |
90 | 88 |
91 if (fill_with_nonsolid_color_) { | 89 if (fill_with_nonsolid_color_) { |
92 gfx::RectF draw_rect = clip; | 90 gfx::RectF draw_rect = clip; |
93 bool red = true; | 91 bool red = true; |
94 while (!draw_rect.IsEmpty()) { | 92 while (!draw_rect.IsEmpty()) { |
95 SkPaint paint; | 93 SkPaint paint; |
96 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); | 94 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); |
97 canvas = | 95 canvas = skia::SharePtr( |
98 skia::SharePtr(recorder.beginRecording(clip.width(), clip.height())); | 96 recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); |
99 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); | 97 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); |
100 picture = skia::AdoptRef(recorder.endRecording()); | 98 picture = skia::AdoptRef(recorder.endRecording()); |
101 list->AppendItem(DrawingDisplayItem::Create(picture, gfx::PointF())); | 99 list->AppendItem(DrawingDisplayItem::Create(picture)); |
102 draw_rect.Inset(1, 1); | 100 draw_rect.Inset(1, 1); |
103 } | 101 } |
104 } | 102 } |
105 | 103 |
106 list->AppendItem(EndClipDisplayItem::Create()); | 104 list->AppendItem(EndClipDisplayItem::Create()); |
107 return list; | 105 return list; |
108 } | 106 } |
109 | 107 |
110 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 108 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
111 | 109 |
112 } // namespace cc | 110 } // namespace cc |
OLD | NEW |