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