| 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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 const SkColor* startEndColors; | 569 const SkColor* startEndColors; |
| 570 if (state == kPressed) | 570 if (state == kPressed) |
| 571 startEndColors = kCheckboxGradientPressedColors; | 571 startEndColors = kCheckboxGradientPressedColors; |
| 572 else if (state == kHovered) | 572 else if (state == kHovered) |
| 573 startEndColors = kCheckboxGradientHoveredColors; | 573 startEndColors = kCheckboxGradientHoveredColors; |
| 574 else if (state == kDisabled) | 574 else if (state == kDisabled) |
| 575 startEndColors = kCheckboxGradientDisabledColors; | 575 startEndColors = kCheckboxGradientDisabledColors; |
| 576 else /* kNormal */ | 576 else /* kNormal */ |
| 577 startEndColors = kCheckboxGradientColors; | 577 startEndColors = kCheckboxGradientColors; |
| 578 SkColor colors[3] = {startEndColors[0], startEndColors[0], startEndColors[1]}; | 578 SkColor colors[3] = {startEndColors[0], startEndColors[0], startEndColors[1]}; |
| 579 SkShader* shader = SkGradientShader::CreateLinear( | 579 skia::RefPtr<SkShader> shader = skia::AdoptRef( |
| 580 gradient_bounds, colors, NULL, 3, SkShader::kClamp_TileMode, NULL); | 580 SkGradientShader::CreateLinear( |
| 581 gradient_bounds, colors, NULL, 3, SkShader::kClamp_TileMode, NULL)); |
| 581 SkPaint paint; | 582 SkPaint paint; |
| 582 paint.setAntiAlias(true); | 583 paint.setAntiAlias(true); |
| 583 paint.setShader(shader); | 584 paint.setShader(shader.get()); |
| 584 shader->unref(); | |
| 585 paint.setStyle(SkPaint::kFill_Style); | 585 paint.setStyle(SkPaint::kFill_Style); |
| 586 canvas->drawRoundRect(skrect, borderRadius, borderRadius, paint); | 586 canvas->drawRoundRect(skrect, borderRadius, borderRadius, paint); |
| 587 paint.setShader(NULL); | 587 paint.setShader(NULL); |
| 588 | 588 |
| 589 // Draw the border. | 589 // Draw the border. |
| 590 if (state == kHovered) | 590 if (state == kHovered) |
| 591 paint.setColor(kCheckboxBorderHoveredColor); | 591 paint.setColor(kCheckboxBorderHoveredColor); |
| 592 else if (state == kDisabled) | 592 else if (state == kDisabled) |
| 593 paint.setColor(kCheckboxBorderDisabledColor); | 593 paint.setColor(kCheckboxBorderDisabledColor); |
| 594 else | 594 else |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 paint.setColor(SK_ColorBLACK); | 718 paint.setColor(SK_ColorBLACK); |
| 719 const int kLightEnd = state == kPressed ? 1 : 0; | 719 const int kLightEnd = state == kPressed ? 1 : 0; |
| 720 const int kDarkEnd = !kLightEnd; | 720 const int kDarkEnd = !kLightEnd; |
| 721 SkPoint gradient_bounds[2]; | 721 SkPoint gradient_bounds[2]; |
| 722 gradient_bounds[kLightEnd].iset(rect.x(), rect.y()); | 722 gradient_bounds[kLightEnd].iset(rect.x(), rect.y()); |
| 723 gradient_bounds[kDarkEnd].iset(rect.x(), kBottom - 1); | 723 gradient_bounds[kDarkEnd].iset(rect.x(), kBottom - 1); |
| 724 SkColor colors[2]; | 724 SkColor colors[2]; |
| 725 colors[0] = light_color; | 725 colors[0] = light_color; |
| 726 colors[1] = base_color; | 726 colors[1] = base_color; |
| 727 | 727 |
| 728 SkShader* shader = SkGradientShader::CreateLinear( | 728 skia::RefPtr<SkShader> shader = skia::AdoptRef( |
| 729 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); | 729 SkGradientShader::CreateLinear( |
| 730 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL)); |
| 730 paint.setStyle(SkPaint::kFill_Style); | 731 paint.setStyle(SkPaint::kFill_Style); |
| 731 paint.setAntiAlias(true); | 732 paint.setAntiAlias(true); |
| 732 paint.setShader(shader); | 733 paint.setShader(shader.get()); |
| 733 shader->unref(); | |
| 734 | 734 |
| 735 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint); | 735 canvas->drawRoundRect(skrect, SkIntToScalar(1), SkIntToScalar(1), paint); |
| 736 paint.setShader(NULL); | 736 paint.setShader(NULL); |
| 737 | 737 |
| 738 if (button.has_border) { | 738 if (button.has_border) { |
| 739 int border_alpha = state == kHovered ? 0x80 : 0x55; | 739 int border_alpha = state == kHovered ? 0x80 : 0x55; |
| 740 if (button.is_focused) { | 740 if (button.is_focused) { |
| 741 border_alpha = 0xff; | 741 border_alpha = 0xff; |
| 742 paint.setColor(GetSystemColor(kColorId_FocusedBorderColor)); | 742 paint.setColor(GetSystemColor(kColorId_FocusedBorderColor)); |
| 743 } | 743 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); | 1129 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); |
| 1130 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); | 1130 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); |
| 1131 | 1131 |
| 1132 if (hsv1[2] + hsv2[2] > 1.0) | 1132 if (hsv1[2] + hsv2[2] > 1.0) |
| 1133 diff = -diff; | 1133 diff = -diff; |
| 1134 | 1134 |
| 1135 return SaturateAndBrighten(hsv2, -0.2f, diff); | 1135 return SaturateAndBrighten(hsv2, -0.2f, diff); |
| 1136 } | 1136 } |
| 1137 | 1137 |
| 1138 } // namespace ui | 1138 } // namespace ui |
| OLD | NEW |