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 #include "ios/chrome/browser/ui/background_generator.h" | 5 #include "ios/chrome/browser/ui/background_generator.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
12 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
13 #import "base/mac/scoped_nsobject.h" | |
14 #import "ios/chrome/browser/ui/ui_util.h" | 13 #import "ios/chrome/browser/ui/ui_util.h" |
15 | 14 |
| 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 16 #error "This file requires ARC support." |
| 17 #endif |
| 18 |
16 // This is a utility function that may be used as a standalone helper function | 19 // This is a utility function that may be used as a standalone helper function |
17 // to generate a radial gradient UIImage. | 20 // to generate a radial gradient UIImage. |
18 UIImage* GetRadialGradient(CGRect backgroundRect, | 21 UIImage* GetRadialGradient(CGRect backgroundRect, |
19 CGPoint centerPoint, | 22 CGPoint centerPoint, |
20 CGFloat radius, | 23 CGFloat radius, |
21 CGFloat centerColor, | 24 CGFloat centerColor, |
22 CGFloat outsideColor, | 25 CGFloat outsideColor, |
23 UIImage* tileImage, | 26 UIImage* tileImage, |
24 UIImage* logoImage) { | 27 UIImage* logoImage) { |
25 UIGraphicsBeginImageContextWithOptions(backgroundRect.size, YES, 0); | 28 UIGraphicsBeginImageContextWithOptions(backgroundRect.size, YES, 0); |
(...skipping 15 matching lines...) Expand all Loading... |
41 CGPointMake(centerPoint.x - logoImage.size.width / 2.0, | 44 CGPointMake(centerPoint.x - logoImage.size.width / 2.0, |
42 centerPoint.y - logoImage.size.height / 2.0)); | 45 centerPoint.y - logoImage.size.height / 2.0)); |
43 [logoImage drawAtPoint:corner]; | 46 [logoImage drawAtPoint:corner]; |
44 } | 47 } |
45 UIImage* background = UIGraphicsGetImageFromCurrentImageContext(); | 48 UIImage* background = UIGraphicsGetImageFromCurrentImageContext(); |
46 UIGraphicsEndImageContext(); | 49 UIGraphicsEndImageContext(); |
47 return background; | 50 return background; |
48 } | 51 } |
49 | 52 |
50 void InstallBackgroundInView(UIView* view) { | 53 void InstallBackgroundInView(UIView* view) { |
51 UIImageView* imageView = | 54 UIImageView* imageView = [[UIImageView alloc] initWithFrame:view.bounds]; |
52 [[[UIImageView alloc] initWithFrame:view.bounds] autorelease]; | |
53 imageView.image = [UIImage imageNamed:@"stack_view_background_noise.jpg"]; | 55 imageView.image = [UIImage imageNamed:@"stack_view_background_noise.jpg"]; |
54 imageView.contentMode = UIViewContentModeScaleAspectFill; | 56 imageView.contentMode = UIViewContentModeScaleAspectFill; |
55 imageView.autoresizingMask = | 57 imageView.autoresizingMask = |
56 UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; | 58 UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; |
57 [view insertSubview:imageView atIndex:0]; | 59 [view insertSubview:imageView atIndex:0]; |
58 } | 60 } |
OLD | NEW |