OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/cocoa/animatable_image.h" | 5 #import "chrome/browser/cocoa/animatable_image.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/mac_util.h" | 8 #import "base/mac_util.h" |
9 #include "base/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
10 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" | 10 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" |
11 | 11 |
12 @interface AnimatableImage (Private) | 12 @interface AnimatableImage (Private) |
13 - (void)setLayerContents:(CALayer*)layer; | 13 - (void)setLayerContents:(CALayer*)layer; |
14 @end | 14 @end |
15 | 15 |
16 @implementation AnimatableImage | 16 @implementation AnimatableImage |
17 | 17 |
18 @synthesize startFrame = startFrame_; | 18 @synthesize startFrame = startFrame_; |
19 @synthesize endFrame = endFrame_; | 19 @synthesize endFrame = endFrame_; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 [layer addAnimation:boundsAnimation forKey:@"bounds"]; | 123 [layer addAnimation:boundsAnimation forKey:@"bounds"]; |
124 } | 124 } |
125 [layer addAnimation:positionAnimation forKey:@"position"]; | 125 [layer addAnimation:positionAnimation forKey:@"position"]; |
126 [layer addAnimation:opacityAnimation forKey:@"opacity"]; | 126 [layer addAnimation:opacityAnimation forKey:@"opacity"]; |
127 [CATransaction commit]; | 127 [CATransaction commit]; |
128 } | 128 } |
129 | 129 |
130 // Sets the layer contents by converting the NSImage to a CGImageRef. This will | 130 // Sets the layer contents by converting the NSImage to a CGImageRef. This will |
131 // rasterize PDF resources. | 131 // rasterize PDF resources. |
132 - (void)setLayerContents:(CALayer*)layer { | 132 - (void)setLayerContents:(CALayer*)layer { |
133 scoped_cftyperef<CGImageRef> image( | 133 base::mac::ScopedCFTypeRef<CGImageRef> image( |
134 mac_util::CopyNSImageToCGImage(image_.get())); | 134 mac_util::CopyNSImageToCGImage(image_.get())); |
135 // Create the layer that will be animated. | 135 // Create the layer that will be animated. |
136 [layer setContents:(id)image.get()]; | 136 [layer setContents:(id)image.get()]; |
137 } | 137 } |
138 | 138 |
139 // CAAnimation delegate method called when the animation is complete. | 139 // CAAnimation delegate method called when the animation is complete. |
140 - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)flag { | 140 - (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)flag { |
141 // Close the window, releasing self. | 141 // Close the window, releasing self. |
142 [self close]; | 142 [self close]; |
143 } | 143 } |
144 | 144 |
145 @end | 145 @end |
OLD | NEW |