Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: ios/chrome/browser/ui/util/snapshot_util.mm

Issue 2580333003: Upstream Chrome on iOS source code [10/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/util/snapshot_util.h ('k') | ios/chrome/browser/ui/util/text_frame.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ios/chrome/browser/ui/util/snapshot_util.h ('k') | ios/chrome/browser/ui/util/text_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698