OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cursor/cursor_util.h" | 5 #include "ui/base/cursor/cursor_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "skia/ext/image_operations.h" | 8 #include "skia/ext/image_operations.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/geometry/point_conversions.h" | 10 #include "ui/gfx/geometry/point_conversions.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 if (scale < FLT_EPSILON) { | 43 if (scale < FLT_EPSILON) { |
44 NOTREACHED() << "Scale must be larger than 0."; | 44 NOTREACHED() << "Scale must be larger than 0."; |
45 scale = 1.0f; | 45 scale = 1.0f; |
46 } | 46 } |
47 | 47 |
48 if (scale == 1.0f) | 48 if (scale == 1.0f) |
49 return; | 49 return; |
50 | 50 |
51 gfx::Size scaled_size = gfx::ToFlooredSize( | 51 gfx::Size scaled_size = gfx::ScaleToFlooredSize( |
52 gfx::ScaleSize(gfx::Size(bitmap->width(), bitmap->height()), scale)); | 52 gfx::Size(bitmap->width(), bitmap->height()), scale); |
53 | 53 |
54 *bitmap = skia::ImageOperations::Resize( | 54 *bitmap = skia::ImageOperations::Resize( |
55 *bitmap, | 55 *bitmap, |
56 skia::ImageOperations::RESIZE_BETTER, | 56 skia::ImageOperations::RESIZE_BETTER, |
57 scaled_size.width(), | 57 scaled_size.width(), |
58 scaled_size.height()); | 58 scaled_size.height()); |
59 *hotpoint = gfx::ToFlooredPoint(gfx::ScalePoint(*hotpoint, scale)); | 59 *hotpoint = gfx::ToFlooredPoint(gfx::ScalePoint(*hotpoint, scale)); |
60 } | 60 } |
61 | 61 |
62 void GetImageCursorBitmap(int resource_id, | 62 void GetImageCursorBitmap(int resource_id, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 SkBitmap cropped = SkBitmapOperations::CreateTiledBitmap( | 101 SkBitmap cropped = SkBitmapOperations::CreateTiledBitmap( |
102 bitmap, x_offset, 0, frame_width, frame_height); | 102 bitmap, x_offset, 0, frame_width, frame_height); |
103 DCHECK_EQ(frame_width, cropped.width()); | 103 DCHECK_EQ(frame_width, cropped.width()); |
104 DCHECK_EQ(frame_height, cropped.height()); | 104 DCHECK_EQ(frame_height, cropped.height()); |
105 | 105 |
106 (*bitmaps)[frame] = cropped; | 106 (*bitmaps)[frame] = cropped; |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 } // namespace ui | 110 } // namespace ui |
OLD | NEW |