Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: ui/gfx/native_theme_base.cc

Issue 9544001: ui: Let skia do the conversion work for us by using the integer version of set() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simplify FocusableBorder::Paint Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 = {
Peter Kasting 2012/02/29 20:40:31 Nit: Can probably use iset() here too
tfarina 2012/02/29 22:42:14 Done.
808 SkIntToScalar(rect.x()), 806 SkIntToScalar(rect.x()),
809 SkIntToScalar(rect.y()), 807 SkIntToScalar(rect.y()),
810 SkIntToScalar(rect.x() + dest_left_border_width), 808 SkIntToScalar(rect.x() + dest_left_border_width),
811 SkIntToScalar(rect.bottom()) 809 SkIntToScalar(rect.bottom())
812 }; 810 };
813 canvas->drawBitmapRect(*left_border_image, NULL, dest_rect); 811 canvas->drawBitmapRect(*left_border_image, NULL, dest_rect);
814 812
815 int dest_right_border_width = static_cast<int>(right_border_image->width() * 813 int dest_right_border_width = static_cast<int>(right_border_image->width() *
816 tile_scale); 814 tile_scale);
817 dest_rect.set(SkIntToScalar(rect.right() - dest_right_border_width), 815 dest_rect.iset(rect.right() - dest_right_border_width, rect.y(), rect.right(),
818 SkIntToScalar(rect.y()), 816 rect.bottom());
819 SkIntToScalar(rect.right()),
820 SkIntToScalar(rect.bottom()));
821 canvas->drawBitmapRect(*right_border_image, NULL, dest_rect); 817 canvas->drawBitmapRect(*right_border_image, NULL, dest_rect);
822 } 818 }
823 819
824 bool NativeThemeBase::IntersectsClipRectInt( 820 bool NativeThemeBase::IntersectsClipRectInt(SkCanvas* canvas,
825 SkCanvas* canvas, int x, int y, int w, int h) const { 821 int x, int y, int w, int h) const {
826 SkRect clip; 822 SkRect clip;
827 return canvas->getClipBounds(&clip) && 823 return canvas->getClipBounds(&clip) &&
828 clip.intersect(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w), 824 clip.intersect(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w),
829 SkIntToScalar(y + h)); 825 SkIntToScalar(y + h));
830 } 826 }
831 827
832 void NativeThemeBase::DrawBitmapInt( 828 void NativeThemeBase::DrawBitmapInt(
833 SkCanvas* canvas, const SkBitmap& bitmap, 829 SkCanvas* canvas, const SkBitmap& bitmap,
834 int src_x, int src_y, int src_w, int src_h, 830 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 { 831 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
985 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2f, 0.28f, 0.5f); 981 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); 982 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5f);
987 983
988 if (hsv1[2] + hsv2[2] > 1.0) 984 if (hsv1[2] + hsv2[2] > 1.0)
989 diff = -diff; 985 diff = -diff;
990 986
991 return SaturateAndBrighten(hsv2, -0.2f, diff); 987 return SaturateAndBrighten(hsv2, -0.2f, diff);
992 } 988 }
993 989
994 } // namespace gfx 990 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698