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 bool StringToSkColor(const std::string& str, SkColor& color) { | |
jochen (gone - plz use gerrit)
2013/06/30 08:13:07
nit. move into the anonymous namespace instead of
wjmaclean
2013/07/02 13:50:31
Done.
| |
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]); | |
90 return true; | |
91 } | |
92 | |
93 return false; | |
94 } | |
95 | |
80 // static | 96 // static |
81 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( | 97 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( |
82 RenderWidget* widget) { | 98 RenderWidget* widget) { |
83 scoped_ptr<RenderWidgetCompositor> compositor( | 99 scoped_ptr<RenderWidgetCompositor> compositor( |
84 new RenderWidgetCompositor(widget)); | 100 new RenderWidgetCompositor(widget)); |
85 | 101 |
86 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 102 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
87 | 103 |
88 cc::LayerTreeSettings settings; | 104 cc::LayerTreeSettings settings; |
89 | 105 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 settings.strict_layer_property_change_checking = | 280 settings.strict_layer_property_change_checking = |
265 cmd->HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking); | 281 cmd->HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking); |
266 | 282 |
267 settings.use_map_image = cmd->HasSwitch(cc::switches::kUseMapImage); | 283 settings.use_map_image = cmd->HasSwitch(cc::switches::kUseMapImage); |
268 | 284 |
269 #if defined(OS_ANDROID) | 285 #if defined(OS_ANDROID) |
270 // TODO(danakj): Move these to the android code. | 286 // TODO(danakj): Move these to the android code. |
271 settings.can_use_lcd_text = false; | 287 settings.can_use_lcd_text = false; |
272 settings.max_partial_texture_updates = 0; | 288 settings.max_partial_texture_updates = 0; |
273 settings.use_linear_fade_scrollbar_animator = true; | 289 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; | 290 settings.highp_threshold_min = 2048; |
278 #endif | 291 #endif |
279 | 292 |
293 if (cmd->HasSwitch(cc::switches::kForceSolidColorScrollbars)) | |
294 settings.force_solid_color_scrollbars = true; | |
295 | |
296 if (cmd->HasSwitch(cc::switches::kSolidColorScrollbarThickness)) { | |
297 std::string str = | |
298 cmd->GetSwitchValueASCII(cc::switches::kSolidColorScrollbarThickness); | |
299 int thickness; | |
300 if (base::StringToInt(str, &thickness)) | |
jochen (gone - plz use gerrit)
2013/06/30 08:13:07
what happens if the thickness is negative or zero?
wjmaclean
2013/07/02 13:50:31
Done.
Change so that if the user enters a negativ
| |
301 settings.solid_color_scrollbar_thickness_dip = thickness; | |
302 } | |
303 | |
304 if (cmd->HasSwitch(cc::switches::kSolidColorScrollbarColor)) { | |
305 std::string str = | |
306 cmd->GetSwitchValueASCII(cc::switches::kSolidColorScrollbarColor); | |
307 | |
308 SkColor scrollbar_color; | |
309 if (StringToSkColor(str, scrollbar_color)) | |
310 settings.solid_color_scrollbar_color = scrollbar_color; | |
311 } | |
312 | |
280 if (!compositor->initialize(settings)) | 313 if (!compositor->initialize(settings)) |
281 return scoped_ptr<RenderWidgetCompositor>(); | 314 return scoped_ptr<RenderWidgetCompositor>(); |
282 | 315 |
283 return compositor.Pass(); | 316 return compositor.Pass(); |
284 } | 317 } |
285 | 318 |
286 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget) | 319 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget) |
287 : suppress_schedule_composite_(false), | 320 : suppress_schedule_composite_(false), |
288 widget_(widget) { | 321 widget_(widget) { |
289 } | 322 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 return RenderThreadImpl::current()->OffscreenContextProviderForMainThread(); | 592 return RenderThreadImpl::current()->OffscreenContextProviderForMainThread(); |
560 } | 593 } |
561 | 594 |
562 scoped_refptr<cc::ContextProvider> | 595 scoped_refptr<cc::ContextProvider> |
563 RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() { | 596 RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() { |
564 return RenderThreadImpl::current()-> | 597 return RenderThreadImpl::current()-> |
565 OffscreenContextProviderForCompositorThread(); | 598 OffscreenContextProviderForCompositorThread(); |
566 } | 599 } |
567 | 600 |
568 } // namespace content | 601 } // namespace content |
OLD | NEW |