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/playback/clip_display_item.h" | 7 #include "cc/playback/clip_display_item.h" |
8 #include "cc/playback/display_item_list_settings.h" | 8 #include "cc/playback/display_item_list_settings.h" |
9 #include "cc/playback/drawing_display_item.h" | 9 #include "cc/playback/drawing_display_item.h" |
10 #include "cc/playback/transform_display_item.h" | 10 #include "cc/playback/transform_display_item.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 FakeContentLayerClient::~FakeContentLayerClient() { | 36 FakeContentLayerClient::~FakeContentLayerClient() { |
37 } | 37 } |
38 | 38 |
39 gfx::Rect FakeContentLayerClient::PaintableRegion() { | 39 gfx::Rect FakeContentLayerClient::PaintableRegion() { |
40 CHECK(bounds_set_); | 40 CHECK(bounds_set_); |
41 return gfx::Rect(bounds_); | 41 return gfx::Rect(bounds_); |
42 } | 42 } |
43 | 43 |
44 scoped_refptr<DisplayItemList> | 44 scoped_refptr<DisplayItemList> |
45 FakeContentLayerClient::PaintContentsToDisplayList( | 45 FakeContentLayerClient::PaintContentsToDisplayList( |
46 const gfx::Rect& clip, | |
47 PaintingControlSetting painting_control) { | 46 PaintingControlSetting painting_control) { |
48 // Cached picture is used because unit tests expect to be able to | 47 // Cached picture is used because unit tests expect to be able to |
49 // use GatherPixelRefs. | 48 // use GatherPixelRefs. |
50 DisplayItemListSettings settings; | 49 DisplayItemListSettings settings; |
51 settings.use_cached_picture = true; | 50 settings.use_cached_picture = true; |
52 scoped_refptr<DisplayItemList> display_list = | 51 scoped_refptr<DisplayItemList> display_list = |
53 DisplayItemList::Create(clip, settings); | 52 DisplayItemList::Create(PaintableRegion(), settings); |
54 SkPictureRecorder recorder; | 53 SkPictureRecorder recorder; |
55 skia::RefPtr<SkCanvas> canvas; | 54 skia::RefPtr<SkCanvas> canvas; |
56 skia::RefPtr<SkPicture> picture; | 55 skia::RefPtr<SkPicture> picture; |
57 auto* item = display_list->CreateAndAppendItem<ClipDisplayItem>(clip); | 56 auto* item = |
58 item->SetNew(clip, std::vector<SkRRect>()); | 57 display_list->CreateAndAppendItem<ClipDisplayItem>(PaintableRegion()); |
58 item->SetNew(PaintableRegion(), std::vector<SkRRect>()); | |
enne (OOO)
2015/12/01 22:43:16
I think you should either not append a clip item a
enne (OOO)
2015/12/01 22:46:25
Oops, I guess this is in a test. So, probably it
chrishtr
2015/12/01 23:01:20
Removed.
| |
59 | 59 |
60 for (RectPaintVector::const_iterator it = draw_rects_.begin(); | 60 for (RectPaintVector::const_iterator it = draw_rects_.begin(); |
61 it != draw_rects_.end(); ++it) { | 61 it != draw_rects_.end(); ++it) { |
62 const gfx::RectF& draw_rect = it->first; | 62 const gfx::RectF& draw_rect = it->first; |
63 const SkPaint& paint = it->second; | 63 const SkPaint& paint = it->second; |
64 canvas = | 64 canvas = |
65 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); | 65 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); |
66 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); | 66 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); |
67 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 67 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
68 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>( | 68 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>( |
69 ToEnclosingRect(draw_rect)); | 69 ToEnclosingRect(draw_rect)); |
70 item->SetNew(std::move(picture)); | 70 item->SetNew(std::move(picture)); |
71 } | 71 } |
72 | 72 |
73 for (ImageVector::const_iterator it = draw_images_.begin(); | 73 for (ImageVector::const_iterator it = draw_images_.begin(); |
74 it != draw_images_.end(); ++it) { | 74 it != draw_images_.end(); ++it) { |
75 if (!it->transform.IsIdentity()) { | 75 if (!it->transform.IsIdentity()) { |
76 auto* item = | 76 auto* item = display_list->CreateAndAppendItem<TransformDisplayItem>( |
77 display_list->CreateAndAppendItem<TransformDisplayItem>(clip); | 77 PaintableRegion()); |
78 item->SetNew(it->transform); | 78 item->SetNew(it->transform); |
79 } | 79 } |
80 canvas = skia::SharePtr( | 80 canvas = skia::SharePtr( |
81 recorder.beginRecording(it->image->width(), it->image->height())); | 81 recorder.beginRecording(it->image->width(), it->image->height())); |
82 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), | 82 canvas->drawImage(it->image.get(), it->point.x(), it->point.y(), |
83 &it->paint); | 83 &it->paint); |
84 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 84 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
85 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(clip); | 85 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>( |
86 PaintableRegion()); | |
86 item->SetNew(std::move(picture)); | 87 item->SetNew(std::move(picture)); |
87 if (!it->transform.IsIdentity()) { | 88 if (!it->transform.IsIdentity()) { |
88 display_list->CreateAndAppendItem<EndTransformDisplayItem>(clip); | 89 display_list->CreateAndAppendItem<EndTransformDisplayItem>( |
90 PaintableRegion()); | |
89 } | 91 } |
90 } | 92 } |
91 | 93 |
92 if (fill_with_nonsolid_color_) { | 94 if (fill_with_nonsolid_color_) { |
93 gfx::Rect draw_rect = clip; | 95 gfx::Rect draw_rect = PaintableRegion(); |
94 bool red = true; | 96 bool red = true; |
95 while (!draw_rect.IsEmpty()) { | 97 while (!draw_rect.IsEmpty()) { |
96 SkPaint paint; | 98 SkPaint paint; |
97 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); | 99 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); |
98 canvas = | 100 canvas = |
99 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect))); | 101 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect))); |
100 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); | 102 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); |
101 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 103 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
102 auto* item = | 104 auto* item = |
103 display_list->CreateAndAppendItem<DrawingDisplayItem>(draw_rect); | 105 display_list->CreateAndAppendItem<DrawingDisplayItem>(draw_rect); |
104 item->SetNew(std::move(picture)); | 106 item->SetNew(std::move(picture)); |
105 draw_rect.Inset(1, 1); | 107 draw_rect.Inset(1, 1); |
106 } | 108 } |
107 } | 109 } |
108 | 110 |
109 display_list->CreateAndAppendItem<EndClipDisplayItem>(clip); | 111 display_list->CreateAndAppendItem<EndClipDisplayItem>(PaintableRegion()); |
110 | 112 |
111 display_list->Finalize(); | 113 display_list->Finalize(); |
112 return display_list; | 114 return display_list; |
113 } | 115 } |
114 | 116 |
115 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 117 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
116 | 118 |
117 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { | 119 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { |
118 return reported_memory_usage_; | 120 return reported_memory_usage_; |
119 } | 121 } |
120 | 122 |
121 } // namespace cc | 123 } // namespace cc |
OLD | NEW |