| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 double_value >= min_value && double_value <= max_value) { | 67 double_value >= min_value && double_value <= max_value) { |
| 68 *result = static_cast<float>(double_value); | 68 *result = static_cast<float>(double_value); |
| 69 return true; | 69 return true; |
| 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 bool StringToSkColor(const std::string& str, SkColor& color) { |
| 78 std::string prefix = str.substr(0,2); |
| 79 int offset = (prefix == "0x" || prefix == "0X") ? 2 : 0; |
| 80 |
| 81 std::vector<uint8> values; |
| 82 if (base::HexStringToBytes(str.substr(offset), &values)) { |
| 83 if (values.size() != 4) |
| 84 return false; |
| 85 |
| 86 color = SkColorSetARGB(values[0], values[1], values[2], values[3]); |
| 87 return true; |
| 88 } |
| 89 |
| 90 return false; |
| 91 } |
| 92 |
| 77 | 93 |
| 78 } // namespace | 94 } // namespace |
| 79 | 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(); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 settings.strict_layer_property_change_checking = | 278 settings.strict_layer_property_change_checking = |
| 263 cmd->HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking); | 279 cmd->HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking); |
| 264 | 280 |
| 265 settings.use_map_image = cmd->HasSwitch(cc::switches::kUseMapImage); | 281 settings.use_map_image = cmd->HasSwitch(cc::switches::kUseMapImage); |
| 266 | 282 |
| 267 #if defined(OS_ANDROID) | 283 #if defined(OS_ANDROID) |
| 268 // TODO(danakj): Move these to the android code. | 284 // TODO(danakj): Move these to the android code. |
| 269 settings.can_use_lcd_text = false; | 285 settings.can_use_lcd_text = false; |
| 270 settings.max_partial_texture_updates = 0; | 286 settings.max_partial_texture_updates = 0; |
| 271 settings.use_linear_fade_scrollbar_animator = true; | 287 settings.use_linear_fade_scrollbar_animator = true; |
| 272 settings.solid_color_scrollbars = true; | |
| 273 settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); | |
| 274 settings.solid_color_scrollbar_thickness_dip = 3; | |
| 275 settings.highp_threshold_min = 2048; | 288 settings.highp_threshold_min = 2048; |
| 276 #endif | 289 #endif |
| 277 | 290 |
| 291 if (cmd->HasSwitch(cc::switches::kForceSolidColorScrollbars)) |
| 292 settings.force_solid_color_scrollbars = true; |
| 293 |
| 294 if (cmd->HasSwitch(cc::switches::kSolidColorScrollbarThickness)) { |
| 295 std::string str = |
| 296 cmd->GetSwitchValueASCII(cc::switches::kSolidColorScrollbarThickness); |
| 297 int thickness; |
| 298 if (base::StringToInt(str, &thickness)) |
| 299 settings.solid_color_scrollbar_thickness_dip = std::max(0, thickness); |
| 300 } |
| 301 |
| 302 if (cmd->HasSwitch(cc::switches::kSolidColorScrollbarColor)) { |
| 303 std::string str = |
| 304 cmd->GetSwitchValueASCII(cc::switches::kSolidColorScrollbarColor); |
| 305 |
| 306 SkColor scrollbar_color; |
| 307 if (StringToSkColor(str, scrollbar_color)) |
| 308 settings.solid_color_scrollbar_color = scrollbar_color; |
| 309 } |
| 310 |
| 278 if (!compositor->initialize(settings)) | 311 if (!compositor->initialize(settings)) |
| 279 return scoped_ptr<RenderWidgetCompositor>(); | 312 return scoped_ptr<RenderWidgetCompositor>(); |
| 280 | 313 |
| 281 return compositor.Pass(); | 314 return compositor.Pass(); |
| 282 } | 315 } |
| 283 | 316 |
| 284 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget) | 317 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget) |
| 285 : suppress_schedule_composite_(false), | 318 : suppress_schedule_composite_(false), |
| 286 widget_(widget) { | 319 widget_(widget) { |
| 287 } | 320 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 return RenderThreadImpl::current()->OffscreenContextProviderForMainThread(); | 590 return RenderThreadImpl::current()->OffscreenContextProviderForMainThread(); |
| 558 } | 591 } |
| 559 | 592 |
| 560 scoped_refptr<cc::ContextProvider> | 593 scoped_refptr<cc::ContextProvider> |
| 561 RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() { | 594 RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() { |
| 562 return RenderThreadImpl::current()-> | 595 return RenderThreadImpl::current()-> |
| 563 OffscreenContextProviderForCompositorThread(); | 596 OffscreenContextProviderForCompositorThread(); |
| 564 } | 597 } |
| 565 | 598 |
| 566 } // namespace content | 599 } // namespace content |
| OLD | NEW |