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 #import "ios/chrome/browser/snapshots/snapshot_manager.h" | 5 #import "ios/chrome/browser/snapshots/snapshot_manager.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "ios/chrome/browser/snapshots/snapshot_cache.h" | 10 #import "ios/chrome/browser/snapshots/snapshot_cache.h" |
11 #import "ios/chrome/browser/snapshots/snapshot_overlay.h" | 11 #import "ios/chrome/browser/snapshots/snapshot_overlay.h" |
12 | 12 |
13 @implementation SnapshotManager | 13 @implementation SnapshotManager |
14 | 14 |
15 - (UIImage*)generateSnapshotForView:(UIView*)view | 15 - (UIImage*)generateSnapshotForView:(UIView*)view |
16 withRect:(CGRect)rect | 16 withRect:(CGRect)rect |
17 overlays:(NSArray*)overlays { | 17 overlays:(NSArray*)overlays { |
18 DCHECK(view); | 18 DCHECK(view); |
19 CGSize size = rect.size; | 19 CGSize size = rect.size; |
20 DCHECK(isnormal(size.width) && (size.width > 0)) | 20 DCHECK(std::isnormal(size.width) && (size.width > 0)) |
21 << ": size.width=" << size.width; | 21 << ": size.width=" << size.width; |
22 DCHECK(isnormal(size.height) && (size.height > 0)) | 22 DCHECK(std::isnormal(size.height) && (size.height > 0)) |
23 << ": size.height=" << size.height; | 23 << ": size.height=" << size.height; |
24 const CGFloat kScale = [SnapshotCache snapshotScaleForDevice]; | 24 const CGFloat kScale = [SnapshotCache snapshotScaleForDevice]; |
25 UIGraphicsBeginImageContextWithOptions(size, YES, kScale); | 25 UIGraphicsBeginImageContextWithOptions(size, YES, kScale); |
26 CGContext* context = UIGraphicsGetCurrentContext(); | 26 CGContext* context = UIGraphicsGetCurrentContext(); |
27 if (!context) { | 27 if (!context) { |
28 NOTREACHED(); | 28 NOTREACHED(); |
29 return nil; | 29 return nil; |
30 } | 30 } |
31 | 31 |
32 CGContextSaveGState(context); | 32 CGContextSaveGState(context); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 [[SnapshotCache sharedInstance] removeImageWithSessionID:sessionID]; | 88 [[SnapshotCache sharedInstance] removeImageWithSessionID:sessionID]; |
89 } | 89 } |
90 | 90 |
91 - (void)greyImageForSessionID:(NSString*)sessionID | 91 - (void)greyImageForSessionID:(NSString*)sessionID |
92 callback:(void (^)(UIImage*))callback { | 92 callback:(void (^)(UIImage*))callback { |
93 [[SnapshotCache sharedInstance] greyImageForSessionID:sessionID | 93 [[SnapshotCache sharedInstance] greyImageForSessionID:sessionID |
94 callback:callback]; | 94 callback:callback]; |
95 } | 95 } |
96 | 96 |
97 @end | 97 @end |
OLD | NEW |