| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef IOS_CHROME_BROWSER_UI_UI_UTIL_H_ | 5 #ifndef IOS_CHROME_BROWSER_UI_UI_UTIL_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_UI_UTIL_H_ | 6 #define IOS_CHROME_BROWSER_UI_UI_UTIL_H_ |
| 7 | 7 |
| 8 #include <CoreGraphics/CoreGraphics.h> | 8 #include <CoreGraphics/CoreGraphics.h> |
| 9 | 9 |
| 10 // UI Util containing functions that do not require Objective-C. | 10 // UI Util containing functions that do not require Objective-C. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // integral values. | 67 // integral values. |
| 68 // | 68 // |
| 69 // The ProjectionMode describes in which way the stretching will apply. | 69 // The ProjectionMode describes in which way the stretching will apply. |
| 70 // | 70 // |
| 71 enum class ProjectionMode { | 71 enum class ProjectionMode { |
| 72 // Just stretches the source into the destination, not preserving aspect ratio | 72 // Just stretches the source into the destination, not preserving aspect ratio |
| 73 // at all. | 73 // at all. |
| 74 // |projectTo| and |revisedTargetSize| will be set to |targetSize| | 74 // |projectTo| and |revisedTargetSize| will be set to |targetSize| |
| 75 kFill, | 75 kFill, |
| 76 | 76 |
| 77 // Scale to the target, maintaining aspect ratio, clipping the excess. Large | 77 // Scale to the target, maintaining aspect ratio, clipping the excess, while |
| 78 // original sizes are shrunk until they fit on one side, small original sizes | 78 // keeping the image centered. |
| 79 // are expanded. | 79 // Large original sizes are shrunk until they fit on one side, small original |
| 80 // sizes are expanded. |
| 80 // |projectTo| will be a subset of |originalSize| | 81 // |projectTo| will be a subset of |originalSize| |
| 81 // |revisedTargetSize| will be set to |targetSize| | 82 // |revisedTargetSize| will be set to |targetSize| |
| 82 kAspectFill, | 83 kAspectFill, |
| 83 | 84 |
| 85 // Same as kAspectFill, except that the bottom part of the image will be |
| 86 // clipped. The image will still be horizontally centered. |
| 87 kAspectFillAlignTop, |
| 88 |
| 84 // Fit the image in the target so it fits completely inside, preserving aspect | 89 // Fit the image in the target so it fits completely inside, preserving aspect |
| 85 // ratio. This will leave bands with with no data in the target. | 90 // ratio. This will leave bands with with no data in the target. |
| 86 // |projectTo| will be set to |originalSize| | 91 // |projectTo| will be set to |originalSize| |
| 87 // |revisedTargetSize| will be a smaller in one direction from |targetSize| | 92 // |revisedTargetSize| will be a smaller in one direction from |targetSize| |
| 88 kAspectFit, | 93 kAspectFit, |
| 89 | 94 |
| 90 // Scale to the target, maintaining aspect ratio and not clipping the excess. | 95 // Scale to the target, maintaining aspect ratio and not clipping the excess. |
| 91 // |projectTo| will be set to |originalSize| | 96 // |projectTo| will be set to |originalSize| |
| 92 // |revisedTargetSize| will be a larger in one direction from |targetSize| | 97 // |revisedTargetSize| will be a larger in one direction from |targetSize| |
| 93 kAspectFillNoClipping, | 98 kAspectFillNoClipping, |
| 94 }; | 99 }; |
| 95 void CalculateProjection(CGSize originalSize, | 100 void CalculateProjection(CGSize originalSize, |
| 96 CGSize targetSize, | 101 CGSize targetSize, |
| 97 ProjectionMode projectionMode, | 102 ProjectionMode projectionMode, |
| 98 CGSize& revisedTargetSize, | 103 CGSize& revisedTargetSize, |
| 99 CGRect& projectTo); | 104 CGRect& projectTo); |
| 100 | 105 |
| 101 #endif // IOS_CHROME_BROWSER_UI_UI_UTIL_H_ | 106 #endif // IOS_CHROME_BROWSER_UI_UI_UTIL_H_ |
| OLD | NEW |