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

Side by Side Diff: ui/base/native_theme/native_theme_android.cc

Issue 10946019: Don't return unsupported scales frrom GetScaleFactorFromScale() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up Created 8 years, 3 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/base/native_theme/native_theme_android.h" 5 #include "ui/base/native_theme/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"
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 int src_y, 662 int src_y,
663 int src_w, 663 int src_w,
664 int src_h, 664 int src_h,
665 int dest_x, 665 int dest_x,
666 int dest_y, 666 int dest_y,
667 int dest_w, 667 int dest_w,
668 int dest_h) const { 668 int dest_h) const {
669 // TODO(pkotwicz): Do something better and don't infer device 669 // TODO(pkotwicz): Do something better and don't infer device
670 // scale factor from canvas scale. 670 // scale factor from canvas scale.
671 SkMatrix m = sk_canvas->getTotalMatrix(); 671 SkMatrix m = sk_canvas->getTotalMatrix();
672 ui::ScaleFactor device_scale_factor = ui::GetScaleFactorFromScale( 672 ui::ScaleFactor device_scale_factor = ui::GetSupportedScaleFactorFromScale(
673 SkScalarAbs(m.getScaleX())); 673 SkScalarAbs(m.getScaleX()));
674 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling( 674 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling(
675 sk_canvas, device_scale_factor)); 675 sk_canvas, device_scale_factor));
676 canvas->DrawImageInt(image, src_x, src_y, src_w, src_h, 676 canvas->DrawImageInt(image, src_x, src_y, src_w, src_h,
677 dest_x, dest_y, dest_w, dest_h, true); 677 dest_x, dest_y, dest_w, dest_h, true);
678 } 678 }
679 679
680 void NativeThemeAndroid::DrawTiledImage(SkCanvas* sk_canvas, 680 void NativeThemeAndroid::DrawTiledImage(SkCanvas* sk_canvas,
681 const gfx::ImageSkia& image, 681 const gfx::ImageSkia& image,
682 int src_x, 682 int src_x,
683 int src_y, 683 int src_y,
684 float tile_scale_x, 684 float tile_scale_x,
685 float tile_scale_y, 685 float tile_scale_y,
686 int dest_x, 686 int dest_x,
687 int dest_y, 687 int dest_y,
688 int w, 688 int w,
689 int h) const { 689 int h) const {
690 // TODO(pkotwicz): Do something better and don't infer device 690 // TODO(pkotwicz): Do something better and don't infer device
691 // scale factor from canvas scale. 691 // scale factor from canvas scale.
692 SkMatrix m = sk_canvas->getTotalMatrix(); 692 SkMatrix m = sk_canvas->getTotalMatrix();
693 ui::ScaleFactor device_scale_factor = ui::GetScaleFactorFromScale( 693 ui::ScaleFactor device_scale_factor = ui::GetSupportedScaleFactorFromScale(
694 SkScalarAbs(m.getScaleX())); 694 SkScalarAbs(m.getScaleX()));
695 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling( 695 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling(
696 sk_canvas, device_scale_factor)); 696 sk_canvas, device_scale_factor));
697 canvas->TileImageInt(image, src_x, src_y, tile_scale_x, 697 canvas->TileImageInt(image, src_x, src_y, tile_scale_x,
698 tile_scale_y, dest_x, dest_y, w, h); 698 tile_scale_y, dest_x, dest_y, w, h);
699 } 699 }
700 700
701 SkColor NativeThemeAndroid::SaturateAndBrighten( 701 SkColor NativeThemeAndroid::SaturateAndBrighten(
702 SkScalar* hsv, 702 SkScalar* hsv,
703 SkScalar saturate_amount, 703 SkScalar saturate_amount,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5); 750 SkScalar min_diff = Clamp((hsv1[1] + hsv2[1]) * 1.2, 0.28, 0.5);
751 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5); 751 SkScalar diff = Clamp(fabs(hsv1[2] - hsv2[2]) / 2, min_diff, 0.5);
752 752
753 if (hsv1[2] + hsv2[2] > 1.0) 753 if (hsv1[2] + hsv2[2] > 1.0)
754 diff = -diff; 754 diff = -diff;
755 755
756 return SaturateAndBrighten(hsv2, -0.2, diff); 756 return SaturateAndBrighten(hsv2, -0.2, diff);
757 } 757 }
758 758
759 } // namespace ui 759 } // namespace ui
OLDNEW
« ui/base/layout.cc ('K') | « ui/base/layout_unittest.cc ('k') | ui/ui_unittests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698