OLD | NEW |
---|---|
1 // Copyright (c) 2011 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_android.h" | 5 #include "ui/gfx/native_theme_android.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "grit/gfx_resources.h" | 11 #include "grit/gfx_resources.h" |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 canvas->drawLine(rect.x() + 1, rect.y(), kRight - 1, rect.y(), paint); | 338 canvas->drawLine(rect.x() + 1, rect.y(), kRight - 1, rect.y(), paint); |
339 canvas->drawLine(kRight - 1, rect.y() + 1, kRight - 1, kBottom - 1, paint); | 339 canvas->drawLine(kRight - 1, rect.y() + 1, kRight - 1, kBottom - 1, paint); |
340 canvas->drawLine(rect.x() + 1, kBottom - 1, kRight - 1, kBottom - 1, paint); | 340 canvas->drawLine(rect.x() + 1, kBottom - 1, kRight - 1, kBottom - 1, paint); |
341 canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), kBottom - 1, paint); | 341 canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), kBottom - 1, paint); |
342 } | 342 } |
343 | 343 |
344 paint.setColor(SK_ColorBLACK); | 344 paint.setColor(SK_ColorBLACK); |
345 int kLightEnd = state == PRESSED ? 1 : 0; | 345 int kLightEnd = state == PRESSED ? 1 : 0; |
346 int kDarkEnd = !kLightEnd; | 346 int kDarkEnd = !kLightEnd; |
347 SkPoint gradient_bounds[2]; | 347 SkPoint gradient_bounds[2]; |
348 gradient_bounds[kLightEnd].set(SkIntToScalar(rect.x()), | 348 gradient_bounds[kLightEnd].iset(rect.x(), rect.y()); |
349 SkIntToScalar(rect.y())); | 349 gradient_bounds[kDarkEnd].iset(rect.x(), kBottom - 1); |
350 gradient_bounds[kDarkEnd].set(SkIntToScalar(rect.x()), | |
351 SkIntToScalar(kBottom - 1)); | |
352 SkColor colors[2]; | 350 SkColor colors[2]; |
353 colors[0] = light_color; | 351 colors[0] = light_color; |
354 colors[1] = base_color; | 352 colors[1] = base_color; |
355 | 353 |
356 SkShader* shader = SkGradientShader::CreateLinear( | 354 SkShader* shader = SkGradientShader::CreateLinear( |
357 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); | 355 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); |
358 paint.setStyle(SkPaint::kFill_Style); | 356 paint.setStyle(SkPaint::kFill_Style); |
359 paint.setShader(shader); | 357 paint.setShader(shader); |
360 shader->unref(); | 358 shader->unref(); |
361 | 359 |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 | 605 |
608 DrawTiledImage(canvas, *value_image, 0, 0, tile_scale_x, tile_scale, | 606 DrawTiledImage(canvas, *value_image, 0, 0, tile_scale_x, tile_scale, |
609 progress_bar.value_rect_x, | 607 progress_bar.value_rect_x, |
610 progress_bar.value_rect_y, | 608 progress_bar.value_rect_y, |
611 progress_bar.value_rect_width, | 609 progress_bar.value_rect_width, |
612 progress_bar.value_rect_height); | 610 progress_bar.value_rect_height); |
613 } | 611 } |
614 | 612 |
615 int dest_left_border_width = static_cast<int>(left_border_image->width() * | 613 int dest_left_border_width = static_cast<int>(left_border_image->width() * |
616 tile_scale); | 614 tile_scale); |
617 SkRect dest_rect = { | 615 SkRect dest_rect = { |
Peter Kasting
2012/02/29 20:40:31
Nit: Could probably use iset() here too
tfarina
2012/02/29 22:42:14
Done.
| |
618 SkIntToScalar(rect.x()), | 616 SkIntToScalar(rect.x()), |
619 SkIntToScalar(rect.y()), | 617 SkIntToScalar(rect.y()), |
620 SkIntToScalar(rect.x() + dest_left_border_width), | 618 SkIntToScalar(rect.x() + dest_left_border_width), |
621 SkIntToScalar(rect.bottom()) | 619 SkIntToScalar(rect.bottom()) |
622 }; | 620 }; |
623 canvas->drawBitmapRect(*left_border_image, NULL, dest_rect); | 621 canvas->drawBitmapRect(*left_border_image, NULL, dest_rect); |
624 | 622 |
625 int dest_right_border_width = static_cast<int>(right_border_image->width() * | 623 int dest_right_border_width = static_cast<int>(right_border_image->width() * |
626 tile_scale); | 624 tile_scale); |
627 dest_rect.set(SkIntToScalar(rect.right() - dest_right_border_width), | 625 dest_rect.iset(rect.right() - dest_right_border_width, rect.y(), rect.right(), |
628 SkIntToScalar(rect.y()), | 626 rect.bottom()); |
629 SkIntToScalar(rect.right()), | |
630 SkIntToScalar(rect.bottom())); | |
631 canvas->drawBitmapRect(*right_border_image, NULL, dest_rect); | 627 canvas->drawBitmapRect(*right_border_image, NULL, dest_rect); |
632 } | 628 } |
633 | 629 |
634 bool NativeThemeAndroid::IntersectsClipRectInt(SkCanvas* canvas, | 630 bool NativeThemeAndroid::IntersectsClipRectInt(SkCanvas* canvas, |
635 int x, | 631 int x, |
636 int y, | 632 int y, |
637 int w, | 633 int w, |
638 int h) { | 634 int h) { |
639 SkRect clip; | 635 SkRect clip; |
640 return canvas->getClipBounds(&clip) && | 636 return canvas->getClipBounds(&clip) && |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
784 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5); | 780 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5); |
785 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5); | 781 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5); |
786 | 782 |
787 if (hsv1[2] + hsv2[2] > 1.0) | 783 if (hsv1[2] + hsv2[2] > 1.0) |
788 diff = -diff; | 784 diff = -diff; |
789 | 785 |
790 return SaturateAndBrighten(hsv2, -0.2, diff); | 786 return SaturateAndBrighten(hsv2, -0.2, diff); |
791 } | 787 } |
792 | 788 |
793 } // namespace gfx | 789 } // namespace gfx |
OLD | NEW |