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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "cc/paint/clip_display_item.h" | 9 #include "cc/paint/clip_display_item.h" |
10 #include "cc/paint/drawing_display_item.h" | 10 #include "cc/paint/drawing_display_item.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 PaintRecorder recorder; | 53 PaintRecorder recorder; |
54 | 54 |
55 for (RectPaintVector::const_iterator it = draw_rects_.begin(); | 55 for (RectPaintVector::const_iterator it = draw_rects_.begin(); |
56 it != draw_rects_.end(); ++it) { | 56 it != draw_rects_.end(); ++it) { |
57 const gfx::RectF& draw_rect = it->first; | 57 const gfx::RectF& draw_rect = it->first; |
58 const PaintFlags& flags = it->second; | 58 const PaintFlags& flags = it->second; |
59 PaintCanvas* canvas = | 59 PaintCanvas* canvas = |
60 recorder.beginRecording(gfx::RectFToSkRect(draw_rect)); | 60 recorder.beginRecording(gfx::RectFToSkRect(draw_rect)); |
61 canvas->drawRect(gfx::RectFToSkRect(draw_rect), flags); | 61 canvas->drawRect(gfx::RectFToSkRect(draw_rect), flags); |
62 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 62 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
63 ToEnclosingRect(draw_rect), recorder.finishRecordingAsPicture(), | 63 ToEnclosingRect(draw_rect), recorder.finishRecordingAsPicture()); |
64 gfx::RectFToSkRect(draw_rect)); | |
65 } | 64 } |
66 | 65 |
67 for (ImageVector::const_iterator it = draw_images_.begin(); | 66 for (ImageVector::const_iterator it = draw_images_.begin(); |
68 it != draw_images_.end(); ++it) { | 67 it != draw_images_.end(); ++it) { |
69 if (!it->transform.IsIdentity()) { | 68 if (!it->transform.IsIdentity()) { |
70 display_list->CreateAndAppendPairedBeginItem<TransformDisplayItem>( | 69 display_list->CreateAndAppendPairedBeginItem<TransformDisplayItem>( |
71 it->transform); | 70 it->transform); |
72 } | 71 } |
73 PaintCanvas* canvas = | 72 PaintCanvas* canvas = recorder.beginRecording( |
74 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); | 73 it->image.sk_image()->width(), it->image.sk_image()->height()); |
75 canvas->drawImage(it->image, it->point.x(), it->point.y(), &it->flags); | 74 canvas->drawImage(it->image, it->point.x(), it->point.y(), &it->flags); |
76 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 75 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
77 PaintableRegion(), recorder.finishRecordingAsPicture(), | 76 PaintableRegion(), recorder.finishRecordingAsPicture()); |
78 gfx::RectToSkRect(PaintableRegion())); | |
79 if (!it->transform.IsIdentity()) { | 77 if (!it->transform.IsIdentity()) { |
80 display_list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); | 78 display_list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>(); |
81 } | 79 } |
82 } | 80 } |
83 | 81 |
84 if (fill_with_nonsolid_color_) { | 82 if (fill_with_nonsolid_color_) { |
85 gfx::Rect draw_rect = PaintableRegion(); | 83 gfx::Rect draw_rect = PaintableRegion(); |
86 bool red = true; | 84 bool red = true; |
87 while (!draw_rect.IsEmpty()) { | 85 while (!draw_rect.IsEmpty()) { |
88 PaintFlags flags; | 86 PaintFlags flags; |
89 flags.setColor(red ? SK_ColorRED : SK_ColorBLUE); | 87 flags.setColor(red ? SK_ColorRED : SK_ColorBLUE); |
90 PaintCanvas* canvas = | 88 PaintCanvas* canvas = |
91 recorder.beginRecording(gfx::RectToSkRect(draw_rect)); | 89 recorder.beginRecording(gfx::RectToSkRect(draw_rect)); |
92 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), flags); | 90 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), flags); |
93 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 91 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
94 draw_rect, recorder.finishRecordingAsPicture(), | 92 draw_rect, recorder.finishRecordingAsPicture()); |
95 gfx::RectToSkRect(draw_rect)); | |
96 draw_rect.Inset(1, 1); | 93 draw_rect.Inset(1, 1); |
97 } | 94 } |
98 } | 95 } |
99 | 96 |
100 display_list->Finalize(); | 97 display_list->Finalize(); |
101 return display_list; | 98 return display_list; |
102 } | 99 } |
103 | 100 |
104 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 101 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
105 | 102 |
106 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { | 103 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { |
107 return reported_memory_usage_; | 104 return reported_memory_usage_; |
108 } | 105 } |
109 | 106 |
110 } // namespace cc | 107 } // namespace cc |
OLD | NEW |