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

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

Issue 10701063: Cleanup gfx::Canvas now that 10562027 has landed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « ui/base/dragdrop/drag_utils.cc ('k') | ui/base/native_theme/native_theme_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/memory/scoped_ptr.h"
11 #include "grit/ui_resources.h" 12 #include "grit/ui_resources.h"
12 #include "third_party/skia/include/effects/SkGradientShader.h" 13 #include "third_party/skia/include/effects/SkGradientShader.h"
13 #include "ui/base/layout.h" 14 #include "ui/base/layout.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/color_utils.h" 17 #include "ui/gfx/color_utils.h"
17 #include "ui/gfx/rect.h" 18 #include "ui/gfx/rect.h"
18 #include "ui/gfx/size.h" 19 #include "ui/gfx/size.h"
19 20
20 namespace ui { 21 namespace ui {
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 int src_h, 664 int src_h,
664 int dest_x, 665 int dest_x,
665 int dest_y, 666 int dest_y,
666 int dest_w, 667 int dest_w,
667 int dest_h) const { 668 int dest_h) const {
668 // TODO(pkotwicz): Do something better and don't infer device 669 // TODO(pkotwicz): Do something better and don't infer device
669 // scale factor from canvas scale. 670 // scale factor from canvas scale.
670 SkMatrix m = sk_canvas->getTotalMatrix(); 671 SkMatrix m = sk_canvas->getTotalMatrix();
671 ui::ScaleFactor device_scale_factor = ui::GetScaleFactorFromScale( 672 ui::ScaleFactor device_scale_factor = ui::GetScaleFactorFromScale(
672 SkScalarAbs(m.getScaleX())); 673 SkScalarAbs(m.getScaleX()));
673 gfx::Canvas canvas(sk_canvas, device_scale_factor, false); 674 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling(
674 canvas.DrawImageInt(image, src_x, src_y, src_w, src_h, 675 sk_canvas, device_scale_factor));
676 canvas->DrawImageInt(image, src_x, src_y, src_w, src_h,
675 dest_x, dest_y, dest_w, dest_h, true); 677 dest_x, dest_y, dest_w, dest_h, true);
676 } 678 }
677 679
678 void NativeThemeAndroid::DrawTiledImage(SkCanvas* sk_canvas, 680 void NativeThemeAndroid::DrawTiledImage(SkCanvas* sk_canvas,
679 const gfx::ImageSkia& image, 681 const gfx::ImageSkia& image,
680 int src_x, 682 int src_x,
681 int src_y, 683 int src_y,
682 float tile_scale_x, 684 float tile_scale_x,
683 float tile_scale_y, 685 float tile_scale_y,
684 int dest_x, 686 int dest_x,
685 int dest_y, 687 int dest_y,
686 int w, 688 int w,
687 int h) const { 689 int h) const {
688 // TODO(pkotwicz): Do something better and don't infer device 690 // TODO(pkotwicz): Do something better and don't infer device
689 // scale factor from canvas scale. 691 // scale factor from canvas scale.
690 SkMatrix m = sk_canvas->getTotalMatrix(); 692 SkMatrix m = sk_canvas->getTotalMatrix();
691 ui::ScaleFactor device_scale_factor = ui::GetScaleFactorFromScale( 693 ui::ScaleFactor device_scale_factor = ui::GetScaleFactorFromScale(
692 SkScalarAbs(m.getScaleX())); 694 SkScalarAbs(m.getScaleX()));
693 gfx::Canvas canvas(sk_canvas, device_scale_factor, false); 695 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling(
694 canvas.TileImageInt(image, src_x, src_y, tile_scale_x, 696 sk_canvas, device_scale_factor));
697 canvas->TileImageInt(image, src_x, src_y, tile_scale_x,
695 tile_scale_y, dest_x, dest_y, w, h); 698 tile_scale_y, dest_x, dest_y, w, h);
696 } 699 }
697 700
698 SkColor NativeThemeAndroid::SaturateAndBrighten( 701 SkColor NativeThemeAndroid::SaturateAndBrighten(
699 SkScalar* hsv, 702 SkScalar* hsv,
700 SkScalar saturate_amount, 703 SkScalar saturate_amount,
701 SkScalar brighten_amount) const { 704 SkScalar brighten_amount) const {
702 SkScalar color[3]; 705 SkScalar color[3];
703 color[0] = hsv[0]; 706 color[0] = hsv[0];
704 color[1] = Clamp(hsv[1] + saturate_amount, 0.0, 1.0); 707 color[1] = Clamp(hsv[1] + saturate_amount, 0.0, 1.0);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 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);
748 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);
749 752
750 if (hsv1[2] + hsv2[2] > 1.0) 753 if (hsv1[2] + hsv2[2] > 1.0)
751 diff = -diff; 754 diff = -diff;
752 755
753 return SaturateAndBrighten(hsv2, -0.2, diff); 756 return SaturateAndBrighten(hsv2, -0.2, diff);
754 } 757 }
755 758
756 } // namespace ui 759 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/dragdrop/drag_utils.cc ('k') | ui/base/native_theme/native_theme_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698