OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/native_theme/native_theme_base.h" | 5 #include "ui/native_theme/native_theme_base.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 | 691 |
692 paint.setColor(SK_ColorBLACK); | 692 paint.setColor(SK_ColorBLACK); |
693 SkPoint gradient_bounds[2] = { | 693 SkPoint gradient_bounds[2] = { |
694 gfx::PointToSkPoint(rect.origin()), | 694 gfx::PointToSkPoint(rect.origin()), |
695 gfx::PointToSkPoint(rect.bottom_left() - gfx::Vector2d(0, 1)) | 695 gfx::PointToSkPoint(rect.bottom_left() - gfx::Vector2d(0, 1)) |
696 }; | 696 }; |
697 if (state == kPressed) | 697 if (state == kPressed) |
698 std::swap(gradient_bounds[0], gradient_bounds[1]); | 698 std::swap(gradient_bounds[0], gradient_bounds[1]); |
699 SkColor colors[2] = { light_color, base_color }; | 699 SkColor colors[2] = { light_color, base_color }; |
700 | 700 |
701 skia::RefPtr<SkShader> shader = skia::AdoptRef( | |
702 SkGradientShader::CreateLinear( | |
703 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode)); | |
704 paint.setStyle(SkPaint::kFill_Style); | 701 paint.setStyle(SkPaint::kFill_Style); |
705 paint.setAntiAlias(true); | 702 paint.setAntiAlias(true); |
706 paint.setShader(shader.get()); | 703 paint.setShader( |
| 704 SkGradientShader::MakeLinear( |
| 705 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode)); |
707 | 706 |
708 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint); | 707 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint); |
709 paint.setShader(NULL); | 708 paint.setShader(NULL); |
710 | 709 |
711 if (button.has_border) { | 710 if (button.has_border) { |
712 int border_alpha = state == kHovered ? 0x80 : 0x55; | 711 int border_alpha = state == kHovered ? 0x80 : 0x55; |
713 if (button.is_focused) { | 712 if (button.is_focused) { |
714 border_alpha = 0xff; | 713 border_alpha = 0xff; |
715 paint.setColor(GetSystemColor(kColorId_FocusedBorderColor)); | 714 paint.setColor(GetSystemColor(kColorId_FocusedBorderColor)); |
716 } | 715 } |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); | 1032 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); |
1034 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); | 1033 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); |
1035 | 1034 |
1036 if (hsv1[2] + hsv2[2] > 1.0) | 1035 if (hsv1[2] + hsv2[2] > 1.0) |
1037 diff = -diff; | 1036 diff = -diff; |
1038 | 1037 |
1039 return SaturateAndBrighten(hsv2, -0.2f, diff); | 1038 return SaturateAndBrighten(hsv2, -0.2f, diff); |
1040 } | 1039 } |
1041 | 1040 |
1042 } // namespace ui | 1041 } // namespace ui |
OLD | NEW |