Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: cc/test/fake_content_layer_client.cc

Issue 1314943008: cc: Remove implicit conversions from Rect to RectF in src/cc/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/drawing_display_item.h" 8 #include "cc/playback/drawing_display_item.h"
9 #include "cc/playback/transform_display_item.h" 9 #include "cc/playback/transform_display_item.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const gfx::Rect& paint_rect, 42 const gfx::Rect& paint_rect,
43 PaintingControlSetting painting_control) { 43 PaintingControlSetting painting_control) {
44 last_canvas_ = canvas; 44 last_canvas_ = canvas;
45 last_painting_control_ = painting_control; 45 last_painting_control_ = painting_control;
46 46
47 canvas->clipRect(gfx::RectToSkRect(paint_rect)); 47 canvas->clipRect(gfx::RectToSkRect(paint_rect));
48 for (RectPaintVector::const_iterator it = draw_rects_.begin(); 48 for (RectPaintVector::const_iterator it = draw_rects_.begin();
49 it != draw_rects_.end(); ++it) { 49 it != draw_rects_.end(); ++it) {
50 const gfx::RectF& draw_rect = it->first; 50 const gfx::RectF& draw_rect = it->first;
51 const SkPaint& paint = it->second; 51 const SkPaint& paint = it->second;
52 canvas->drawRectCoords(draw_rect.x(), 52 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
53 draw_rect.y(),
54 draw_rect.right(),
55 draw_rect.bottom(),
56 paint);
57 } 53 }
58 54
59 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); 55 for (BitmapVector::const_iterator it = draw_bitmaps_.begin();
60 it != draw_bitmaps_.end(); ++it) { 56 it != draw_bitmaps_.end(); ++it) {
61 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint); 57 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint);
62 } 58 }
63 59
64 if (fill_with_nonsolid_color_) { 60 if (fill_with_nonsolid_color_) {
65 gfx::RectF draw_rect = paint_rect; 61 gfx::Rect draw_rect = paint_rect;
66 bool red = true; 62 bool red = true;
67 while (!draw_rect.IsEmpty()) { 63 while (!draw_rect.IsEmpty()) {
68 SkPaint paint; 64 SkPaint paint;
69 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); 65 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE);
70 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); 66 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint);
71 draw_rect.Inset(1, 1); 67 draw_rect.Inset(1, 1);
72 } 68 }
73 } 69 }
74 } 70 }
75 71
76 scoped_refptr<DisplayItemList> 72 scoped_refptr<DisplayItemList>
77 FakeContentLayerClient::PaintContentsToDisplayList( 73 FakeContentLayerClient::PaintContentsToDisplayList(
78 const gfx::Rect& clip, 74 const gfx::Rect& clip,
79 PaintingControlSetting painting_control) { 75 PaintingControlSetting painting_control) {
80 // Cached picture is used because unit tests expect to be able to 76 // Cached picture is used because unit tests expect to be able to
81 // use GatherPixelRefs. 77 // use GatherPixelRefs.
82 const bool use_cached_picture = true; 78 const bool use_cached_picture = true;
83 scoped_refptr<DisplayItemList> display_list = 79 scoped_refptr<DisplayItemList> display_list =
84 DisplayItemList::Create(clip, use_cached_picture); 80 DisplayItemList::Create(clip, use_cached_picture);
85 SkPictureRecorder recorder; 81 SkPictureRecorder recorder;
86 skia::RefPtr<SkCanvas> canvas; 82 skia::RefPtr<SkCanvas> canvas;
87 skia::RefPtr<SkPicture> picture; 83 skia::RefPtr<SkPicture> picture;
88 auto* item = display_list->CreateAndAppendItem<ClipDisplayItem>(); 84 auto* item = display_list->CreateAndAppendItem<ClipDisplayItem>();
89 item->SetNew(clip, std::vector<SkRRect>()); 85 item->SetNew(clip, std::vector<SkRRect>());
90 86
91 for (RectPaintVector::const_iterator it = draw_rects_.begin(); 87 for (RectPaintVector::const_iterator it = draw_rects_.begin();
92 it != draw_rects_.end(); ++it) { 88 it != draw_rects_.end(); ++it) {
93 const gfx::RectF& draw_rect = it->first; 89 const gfx::RectF& draw_rect = it->first;
94 const SkPaint& paint = it->second; 90 const SkPaint& paint = it->second;
95 canvas = 91 canvas =
96 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); 92 skia::SharePtr(recorder.beginRecording(gfx::RectFToSkRect(draw_rect)));
97 canvas->drawRectCoords(draw_rect.x(), draw_rect.y(), draw_rect.width(), 93 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
98 draw_rect.height(), paint);
99 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 94 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
100 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); 95 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>();
101 item->SetNew(picture.Pass()); 96 item->SetNew(picture.Pass());
102 } 97 }
103 98
104 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); 99 for (BitmapVector::const_iterator it = draw_bitmaps_.begin();
105 it != draw_bitmaps_.end(); ++it) { 100 it != draw_bitmaps_.end(); ++it) {
106 if (!it->transform.IsIdentity()) { 101 if (!it->transform.IsIdentity()) {
107 auto* item = display_list->CreateAndAppendItem<TransformDisplayItem>(); 102 auto* item = display_list->CreateAndAppendItem<TransformDisplayItem>();
108 item->SetNew(it->transform); 103 item->SetNew(it->transform);
109 } 104 }
110 canvas = skia::SharePtr( 105 canvas = skia::SharePtr(
111 recorder.beginRecording(it->bitmap.width(), it->bitmap.height())); 106 recorder.beginRecording(it->bitmap.width(), it->bitmap.height()));
112 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint); 107 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint);
113 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 108 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
114 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); 109 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>();
115 item->SetNew(picture.Pass()); 110 item->SetNew(picture.Pass());
116 if (!it->transform.IsIdentity()) { 111 if (!it->transform.IsIdentity()) {
117 display_list->CreateAndAppendItem<EndTransformDisplayItem>(); 112 display_list->CreateAndAppendItem<EndTransformDisplayItem>();
118 } 113 }
119 } 114 }
120 115
121 if (fill_with_nonsolid_color_) { 116 if (fill_with_nonsolid_color_) {
122 gfx::RectF draw_rect = clip; 117 gfx::Rect draw_rect = clip;
123 bool red = true; 118 bool red = true;
124 while (!draw_rect.IsEmpty()) { 119 while (!draw_rect.IsEmpty()) {
125 SkPaint paint; 120 SkPaint paint;
126 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); 121 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE);
127 canvas = skia::SharePtr( 122 canvas =
128 recorder.beginRecording(gfx::RectFToSkRect(draw_rect))); 123 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect)));
129 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint); 124 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint);
130 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); 125 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
131 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(); 126 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>();
132 item->SetNew(picture.Pass()); 127 item->SetNew(picture.Pass());
133 draw_rect.Inset(1, 1); 128 draw_rect.Inset(1, 1);
134 } 129 }
135 } 130 }
136 131
137 display_list->CreateAndAppendItem<EndClipDisplayItem>(); 132 display_list->CreateAndAppendItem<EndClipDisplayItem>();
138 133
139 display_list->Finalize(); 134 display_list->Finalize();
140 return display_list; 135 return display_list;
141 } 136 }
142 137
143 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } 138 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }
144 139
145 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { 140 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const {
146 return reported_memory_usage_; 141 return reported_memory_usage_;
147 } 142 }
148 143
149 } // namespace cc 144 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698