| 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/gfx/native_theme_base.h" | 5 #include "ui/gfx/native_theme_base.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "grit/gfx_resources.h" | 10 #include "grit/gfx_resources.h" |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 canvas->drawLine(rect.x() + 1, rect.y(), kRight - 1, rect.y(), paint); | 513 canvas->drawLine(rect.x() + 1, rect.y(), kRight - 1, rect.y(), paint); |
| 514 canvas->drawLine(kRight - 1, rect.y() + 1, kRight - 1, kBottom - 1, paint); | 514 canvas->drawLine(kRight - 1, rect.y() + 1, kRight - 1, kBottom - 1, paint); |
| 515 canvas->drawLine(rect.x() + 1, kBottom - 1, kRight - 1, kBottom - 1, paint); | 515 canvas->drawLine(rect.x() + 1, kBottom - 1, kRight - 1, kBottom - 1, paint); |
| 516 canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), kBottom - 1, paint); | 516 canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), kBottom - 1, paint); |
| 517 } | 517 } |
| 518 | 518 |
| 519 paint.setColor(SK_ColorBLACK); | 519 paint.setColor(SK_ColorBLACK); |
| 520 const int kLightEnd = state == kPressed ? 1 : 0; | 520 const int kLightEnd = state == kPressed ? 1 : 0; |
| 521 const int kDarkEnd = !kLightEnd; | 521 const int kDarkEnd = !kLightEnd; |
| 522 SkPoint gradient_bounds[2]; | 522 SkPoint gradient_bounds[2]; |
| 523 gradient_bounds[kLightEnd].set(SkIntToScalar(rect.x()), | 523 gradient_bounds[kLightEnd].iset(rect.x(), rect.y()); |
| 524 SkIntToScalar(rect.y())); | 524 gradient_bounds[kDarkEnd].iset(rect.x(), kBottom - 1); |
| 525 gradient_bounds[kDarkEnd].set(SkIntToScalar(rect.x()), | |
| 526 SkIntToScalar(kBottom - 1)); | |
| 527 SkColor colors[2]; | 525 SkColor colors[2]; |
| 528 colors[0] = light_color; | 526 colors[0] = light_color; |
| 529 colors[1] = base_color; | 527 colors[1] = base_color; |
| 530 | 528 |
| 531 SkShader* shader = SkGradientShader::CreateLinear( | 529 SkShader* shader = SkGradientShader::CreateLinear( |
| 532 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); | 530 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); |
| 533 paint.setStyle(SkPaint::kFill_Style); | 531 paint.setStyle(SkPaint::kFill_Style); |
| 534 paint.setShader(shader); | 532 paint.setShader(shader); |
| 535 shader->unref(); | 533 shader->unref(); |
| 536 | 534 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 | 795 |
| 798 DrawTiledImage(canvas, *value_image, 0, 0, tile_scale_x, tile_scale, | 796 DrawTiledImage(canvas, *value_image, 0, 0, tile_scale_x, tile_scale, |
| 799 progress_bar.value_rect_x, | 797 progress_bar.value_rect_x, |
| 800 progress_bar.value_rect_y, | 798 progress_bar.value_rect_y, |
| 801 progress_bar.value_rect_width, | 799 progress_bar.value_rect_width, |
| 802 progress_bar.value_rect_height); | 800 progress_bar.value_rect_height); |
| 803 } | 801 } |
| 804 | 802 |
| 805 int dest_left_border_width = static_cast<int>(left_border_image->width() * | 803 int dest_left_border_width = static_cast<int>(left_border_image->width() * |
| 806 tile_scale); | 804 tile_scale); |
| 807 SkRect dest_rect = { | 805 SkRect dest_rect; |
| 808 SkIntToScalar(rect.x()), | 806 dest_rect.iset(rect.x(), rect.y(), rect.x() + dest_left_border_width, |
| 809 SkIntToScalar(rect.y()), | 807 rect.bottom()); |
| 810 SkIntToScalar(rect.x() + dest_left_border_width), | |
| 811 SkIntToScalar(rect.bottom()) | |
| 812 }; | |
| 813 canvas->drawBitmapRect(*left_border_image, NULL, dest_rect); | 808 canvas->drawBitmapRect(*left_border_image, NULL, dest_rect); |
| 814 | 809 |
| 815 int dest_right_border_width = static_cast<int>(right_border_image->width() * | 810 int dest_right_border_width = static_cast<int>(right_border_image->width() * |
| 816 tile_scale); | 811 tile_scale); |
| 817 dest_rect.set(SkIntToScalar(rect.right() - dest_right_border_width), | 812 dest_rect.iset(rect.right() - dest_right_border_width, rect.y(), rect.right(), |
| 818 SkIntToScalar(rect.y()), | 813 rect.bottom()); |
| 819 SkIntToScalar(rect.right()), | |
| 820 SkIntToScalar(rect.bottom())); | |
| 821 canvas->drawBitmapRect(*right_border_image, NULL, dest_rect); | 814 canvas->drawBitmapRect(*right_border_image, NULL, dest_rect); |
| 822 } | 815 } |
| 823 | 816 |
| 824 bool NativeThemeBase::IntersectsClipRectInt( | 817 bool NativeThemeBase::IntersectsClipRectInt(SkCanvas* canvas, |
| 825 SkCanvas* canvas, int x, int y, int w, int h) const { | 818 int x, int y, int w, int h) const { |
| 826 SkRect clip; | 819 SkRect clip; |
| 827 return canvas->getClipBounds(&clip) && | 820 return canvas->getClipBounds(&clip) && |
| 828 clip.intersect(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w), | 821 clip.intersect(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w), |
| 829 SkIntToScalar(y + h)); | 822 SkIntToScalar(y + h)); |
| 830 } | 823 } |
| 831 | 824 |
| 832 void NativeThemeBase::DrawBitmapInt( | 825 void NativeThemeBase::DrawBitmapInt( |
| 833 SkCanvas* canvas, const SkBitmap& bitmap, | 826 SkCanvas* canvas, const SkBitmap& bitmap, |
| 834 int src_x, int src_y, int src_w, int src_h, | 827 int src_x, int src_y, int src_w, int src_h, |
| 835 int dest_x, int dest_y, int dest_w, int dest_h) const { | 828 int dest_x, int dest_y, int dest_w, int dest_h) const { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); | 978 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); |
| 986 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); | 979 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f); |
| 987 | 980 |
| 988 if (hsv1[2] + hsv2[2] > 1.0) | 981 if (hsv1[2] + hsv2[2] > 1.0) |
| 989 diff = -diff; | 982 diff = -diff; |
| 990 | 983 |
| 991 return SaturateAndBrighten(hsv2, -0.2f, diff); | 984 return SaturateAndBrighten(hsv2, -0.2f, diff); |
| 992 } | 985 } |
| 993 | 986 |
| 994 } // namespace gfx | 987 } // namespace gfx |
| OLD | NEW |