| Index: ios/chrome/browser/ui/util/snapshot_util.mm
|
| diff --git a/ios/chrome/browser/ui/util/snapshot_util.mm b/ios/chrome/browser/ui/util/snapshot_util.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e058d9ba7daa5263d002e5a03fc42d8e950e173a
|
| --- /dev/null
|
| +++ b/ios/chrome/browser/ui/util/snapshot_util.mm
|
| @@ -0,0 +1,25 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#import "ios/chrome/browser/ui/util/snapshot_util.h"
|
| +
|
| +namespace snapshot_util {
|
| +
|
| +UIView* GenerateSnapshot(UIView* view) {
|
| + UIView* snapshot;
|
| + if (view.window) {
|
| + // |view| is in a view hierarchy.
|
| + snapshot = [view snapshotViewAfterScreenUpdates:NO];
|
| + } else {
|
| + UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, 0);
|
| + [view.layer renderInContext:UIGraphicsGetCurrentContext()];
|
| + UIImage* screenshot = UIGraphicsGetImageFromCurrentImageContext();
|
| + UIGraphicsEndImageContext();
|
| + snapshot = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
|
| + snapshot.layer.contents = static_cast<id>(screenshot.CGImage);
|
| + }
|
| + return snapshot;
|
| +}
|
| +
|
| +} // namespace snapshot_util
|
|
|