OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 } else { | 70 } else { |
71 LOG(WARNING) << "Failed to parse switch " << switch_string << ": " << | 71 LOG(WARNING) << "Failed to parse switch " << switch_string << ": " << |
72 string_value; | 72 string_value; |
73 return false; | 73 return false; |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 } // namespace | 78 } // namespace |
79 | 79 |
80 static SkColor StringToSkColor(const std::string& str, SkColor& color) { | |
aelias_OOO_until_Jul13
2013/06/28 22:07:58
Did you mean to change the return value to 'bool'?
wjmaclean
2013/06/29 01:00:38
Gah! Yes, this should be bool!! I forgot SkColor r
| |
81 std::string prefix = str.substr(0,2); | |
82 int offset = (prefix == "0x" || prefix == "0X") ? 2 : 0; | |
83 | |
84 std::vector<uint8> values; | |
85 if (base::HexStringToBytes(str.substr(offset), &values)) { | |
86 if (values.size() != 4) | |
87 return false; | |
88 | |
89 color = SkColorSetARGB(values[0], values[1], values[2], values[3]); | |
aelias_OOO_until_Jul13
2013/06/28 22:07:58
Should be "return true;" after this?
wjmaclean
2013/06/29 01:00:38
Yes, fixed.
| |
90 } | |
91 | |
92 return false; | |
93 } | |
94 | |
80 // static | 95 // static |
81 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( | 96 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( |
82 RenderWidget* widget) { | 97 RenderWidget* widget) { |
83 scoped_ptr<RenderWidgetCompositor> compositor( | 98 scoped_ptr<RenderWidgetCompositor> compositor( |
84 new RenderWidgetCompositor(widget)); | 99 new RenderWidgetCompositor(widget)); |
85 | 100 |
86 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 101 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
87 | 102 |
88 cc::LayerTreeSettings settings; | 103 cc::LayerTreeSettings settings; |
89 | 104 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 settings.strict_layer_property_change_checking = | 279 settings.strict_layer_property_change_checking = |
265 cmd->HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking); | 280 cmd->HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking); |
266 | 281 |
267 settings.use_map_image = cmd->HasSwitch(cc::switches::kUseMapImage); | 282 settings.use_map_image = cmd->HasSwitch(cc::switches::kUseMapImage); |
268 | 283 |
269 #if defined(OS_ANDROID) | 284 #if defined(OS_ANDROID) |
270 // TODO(danakj): Move these to the android code. | 285 // TODO(danakj): Move these to the android code. |
271 settings.can_use_lcd_text = false; | 286 settings.can_use_lcd_text = false; |
272 settings.max_partial_texture_updates = 0; | 287 settings.max_partial_texture_updates = 0; |
273 settings.use_linear_fade_scrollbar_animator = true; | 288 settings.use_linear_fade_scrollbar_animator = true; |
274 settings.solid_color_scrollbars = true; | |
275 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); | |
276 settings.solid_color_scrollbar_thickness_dip = 3; | |
277 settings.highp_threshold_min = 2048; | 289 settings.highp_threshold_min = 2048; |
278 #endif | 290 #endif |
279 | 291 |
292 if (cmd->HasSwitch(cc::switches::kForceSolidColorScrollbars)) | |
293 settings.force_solid_color_scrollbars = true; | |
294 | |
295 if (cmd->HasSwitch(cc::switches::kSolidColorScrollbarThickness)) { | |
296 std::string str = | |
297 cmd->GetSwitchValueASCII(cc::switches::kSolidColorScrollbarThickness); | |
298 int thickness; | |
299 if (base::StringToInt(str, &thickness)) | |
300 settings.solid_color_scrollbar_thickness_dip = thickness; | |
301 } | |
302 | |
303 if (cmd->HasSwitch(cc::switches::kSolidColorScrollbarColor)) { | |
304 std::string str = | |
305 cmd->GetSwitchValueASCII(cc::switches::kSolidColorScrollbarColor); | |
306 | |
307 SkColor scrollbar_color; | |
308 if (StringToSkColor(str, scrollbar_color)) | |
309 settings.solid_color_scrollbar_color = scrollbar_color; | |
310 } | |
311 | |
280 if (!compositor->initialize(settings)) | 312 if (!compositor->initialize(settings)) |
281 return scoped_ptr<RenderWidgetCompositor>(); | 313 return scoped_ptr<RenderWidgetCompositor>(); |
282 | 314 |
283 return compositor.Pass(); | 315 return compositor.Pass(); |
284 } | 316 } |
285 | 317 |
286 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget) | 318 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget) |
287 : suppress_schedule_composite_(false), | 319 : suppress_schedule_composite_(false), |
288 widget_(widget) { | 320 widget_(widget) { |
289 } | 321 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 return RenderThreadImpl::current()->OffscreenContextProviderForMainThread(); | 591 return RenderThreadImpl::current()->OffscreenContextProviderForMainThread(); |
560 } | 592 } |
561 | 593 |
562 scoped_refptr<cc::ContextProvider> | 594 scoped_refptr<cc::ContextProvider> |
563 RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() { | 595 RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() { |
564 return RenderThreadImpl::current()-> | 596 return RenderThreadImpl::current()-> |
565 OffscreenContextProviderForCompositorThread(); | 597 OffscreenContextProviderForCompositorThread(); |
566 } | 598 } |
567 | 599 |
568 } // namespace content | 600 } // namespace content |
OLD | NEW |