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

Side by Side Diff: chrome/browser/cocoa/tabpose_window.mm

Issue 3855001: Move scoped_cftyperef from base to base/mac, use the new namespace, and name ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/tabpose_window.h ('k') | chrome/browser/file_path_watcher_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
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/tabpose_window.h" 5 #import "chrome/browser/cocoa/tabpose_window.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/mac_util.h" 10 #include "base/mac_util.h"
(...skipping 27 matching lines...) Expand all
38 const CGFloat kSlomoFactor = 4; 38 const CGFloat kSlomoFactor = 4;
39 const CGFloat kObserverChangeAnimationDuration = 0.75; // In seconds. 39 const CGFloat kObserverChangeAnimationDuration = 0.75; // In seconds.
40 40
41 // CAGradientLayer is 10.6-only -- roll our own. 41 // CAGradientLayer is 10.6-only -- roll our own.
42 @interface DarkGradientLayer : CALayer 42 @interface DarkGradientLayer : CALayer
43 - (void)drawInContext:(CGContextRef)context; 43 - (void)drawInContext:(CGContextRef)context;
44 @end 44 @end
45 45
46 @implementation DarkGradientLayer 46 @implementation DarkGradientLayer
47 - (void)drawInContext:(CGContextRef)context { 47 - (void)drawInContext:(CGContextRef)context {
48 scoped_cftyperef<CGColorSpaceRef> grayColorSpace( 48 mac/scoped_cftyperef<CGColorSpaceRef> grayColorSpace(
49 CGColorSpaceCreateWithName(kCGColorSpaceGenericGray)); 49 CGColorSpaceCreateWithName(kCGColorSpaceGenericGray));
50 CGFloat grays[] = { 0.277, 1.0, 0.39, 1.0 }; 50 CGFloat grays[] = { 0.277, 1.0, 0.39, 1.0 };
51 CGFloat locations[] = { 0, 1 }; 51 CGFloat locations[] = { 0, 1 };
52 scoped_cftyperef<CGGradientRef> gradient(CGGradientCreateWithColorComponents( 52 base::mac::ScopedCFTypeRef<CGGradientRef> gradient(
53 grayColorSpace.get(), grays, locations, arraysize(locations))); 53 CGGradientCreateWithColorComponents(
54 grayColorSpace.get(), grays, locations, arraysize(locations)));
54 CGPoint topLeft = CGPointMake(0.0, kTopGradientHeight); 55 CGPoint topLeft = CGPointMake(0.0, kTopGradientHeight);
55 CGContextDrawLinearGradient(context, gradient.get(), topLeft, CGPointZero, 0); 56 CGContextDrawLinearGradient(context, gradient.get(), topLeft, CGPointZero, 0);
56 } 57 }
57 @end 58 @end
58 59
59 namespace tabpose { 60 namespace tabpose {
60 class ThumbnailLoader; 61 class ThumbnailLoader;
61 } 62 }
62 63
63 // A CALayer that draws a thumbnail for a TabContents object. The layer tries 64 // A CALayer that draws a thumbnail for a TabContents object. The layer tries
64 // to draw the TabContents's backing store directly if possible, and requests 65 // to draw the TabContents's backing store directly if possible, and requests
65 // a thumbnail bitmap from the TabContents's renderer process if not. 66 // a thumbnail bitmap from the TabContents's renderer process if not.
66 @interface ThumbnailLayer : CALayer { 67 @interface ThumbnailLayer : CALayer {
67 // The TabContents the thumbnail is for. 68 // The TabContents the thumbnail is for.
68 TabContents* contents_; // weak 69 TabContents* contents_; // weak
69 70
70 // The size the thumbnail is drawn at when zoomed in. 71 // The size the thumbnail is drawn at when zoomed in.
71 NSSize fullSize_; 72 NSSize fullSize_;
72 73
73 // Used to load a thumbnail, if required. 74 // Used to load a thumbnail, if required.
74 scoped_refptr<tabpose::ThumbnailLoader> loader_; 75 scoped_refptr<tabpose::ThumbnailLoader> loader_;
75 76
76 // If the backing store couldn't be used and a thumbnail was returned from a 77 // If the backing store couldn't be used and a thumbnail was returned from a
77 // renderer process, it's stored in |thumbnail_|. 78 // renderer process, it's stored in |thumbnail_|.
78 scoped_cftyperef<CGImageRef> thumbnail_; 79 base::mac::ScopedCFTypeRef<CGImageRef> thumbnail_;
79 80
80 // True if the layer already sent a thumbnail request to a renderer. 81 // True if the layer already sent a thumbnail request to a renderer.
81 BOOL didSendLoad_; 82 BOOL didSendLoad_;
82 } 83 }
83 - (id)initWithTabContents:(TabContents*)contents fullSize:(NSSize)fullSize; 84 - (id)initWithTabContents:(TabContents*)contents fullSize:(NSSize)fullSize;
84 - (void)drawInContext:(CGContextRef)context; 85 - (void)drawInContext:(CGContextRef)context;
85 - (void)setThumbnail:(const SkBitmap&)bitmap; 86 - (void)setThumbnail:(const SkBitmap&)bitmap;
86 @end 87 @end
87 88
88 namespace tabpose { 89 namespace tabpose {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 216
216 - (void)drawBackingStore:(BackingStoreMac*)backing_store 217 - (void)drawBackingStore:(BackingStoreMac*)backing_store
217 inRect:(CGRect)destRect 218 inRect:(CGRect)destRect
218 context:(CGContextRef)context { 219 context:(CGContextRef)context {
219 // TODO(thakis): Add a sublayer for each accelerated surface in the rwhv. 220 // TODO(thakis): Add a sublayer for each accelerated surface in the rwhv.
220 // Until then, accelerated layers (CoreAnimation NPAPI plugins, compositor) 221 // Until then, accelerated layers (CoreAnimation NPAPI plugins, compositor)
221 // won't show up in tabpose. 222 // won't show up in tabpose.
222 if (backing_store->cg_layer()) { 223 if (backing_store->cg_layer()) {
223 CGContextDrawLayerInRect(context, destRect, backing_store->cg_layer()); 224 CGContextDrawLayerInRect(context, destRect, backing_store->cg_layer());
224 } else { 225 } else {
225 scoped_cftyperef<CGImageRef> image( 226 base::mac::ScopedCFTypeRef<CGImageRef> image(
226 CGBitmapContextCreateImage(backing_store->cg_bitmap())); 227 CGBitmapContextCreateImage(backing_store->cg_bitmap()));
227 CGContextDrawImage(context, destRect, image); 228 CGContextDrawImage(context, destRect, image);
228 } 229 }
229 } 230 }
230 231
231 - (void)drawInContext:(CGContextRef)context { 232 - (void)drawInContext:(CGContextRef)context {
232 RenderWidgetHost* rwh = contents_->render_view_host(); 233 RenderWidgetHost* rwh = contents_->render_view_host();
233 // NULL if renderer crashed. 234 // NULL if renderer crashed.
234 RenderWidgetHostView* rwhv = rwh ? rwh->view() : NULL; 235 RenderWidgetHostView* rwhv = rwh ? rwh->view() : NULL;
235 if (!rwhv) { 236 if (!rwhv) {
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 942
942 NSImage* nsFavicon = gfx::SkBitmapToNSImage(tile.favicon()); 943 NSImage* nsFavicon = gfx::SkBitmapToNSImage(tile.favicon());
943 // Either we don't have a valid favicon or there was some issue converting 944 // Either we don't have a valid favicon or there was some issue converting
944 // it from an SkBitmap. Either way, just show the default. 945 // it from an SkBitmap. Either way, just show the default.
945 if (!nsFavicon) { 946 if (!nsFavicon) {
946 NSImage* defaultFavIcon = 947 NSImage* defaultFavIcon =
947 ResourceBundle::GetSharedInstance().GetNSImageNamed( 948 ResourceBundle::GetSharedInstance().GetNSImageNamed(
948 IDR_DEFAULT_FAVICON); 949 IDR_DEFAULT_FAVICON);
949 nsFavicon = defaultFavIcon; 950 nsFavicon = defaultFavIcon;
950 } 951 }
951 scoped_cftyperef<CGImageRef> favicon( 952 base::mac::ScopedCFTypeRef<CGImageRef> favicon(
952 mac_util::CopyNSImageToCGImage(nsFavicon)); 953 mac_util::CopyNSImageToCGImage(nsFavicon));
953 954
954 CALayer* faviconLayer = [CALayer layer]; 955 CALayer* faviconLayer = [CALayer layer];
955 faviconLayer.frame = NSRectToCGRect(tile.favicon_rect()); 956 faviconLayer.frame = NSRectToCGRect(tile.favicon_rect());
956 faviconLayer.contents = (id)favicon.get(); 957 faviconLayer.contents = (id)favicon.get();
957 faviconLayer.zPosition = 1; // On top of the thumb shadow. 958 faviconLayer.zPosition = 1; // On top of the thumb shadow.
958 if (state_ == tabpose::kFadingIn) 959 if (state_ == tabpose::kFadingIn)
959 faviconLayer.hidden = YES; 960 faviconLayer.hidden = YES;
960 [bgLayer_ addSublayer:faviconLayer]; 961 [bgLayer_ addSublayer:faviconLayer];
961 [allFaviconLayers_ addObject:faviconLayer]; 962 [allFaviconLayers_ addObject:faviconLayer];
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 tile.set_tab_contents(contents); 1418 tile.set_tab_contents(contents);
1418 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index]; 1419 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index];
1419 [thumbLayer setTabContents:contents]; 1420 [thumbLayer setTabContents:contents];
1420 } 1421 }
1421 1422
1422 - (void)tabStripModelDeleted { 1423 - (void)tabStripModelDeleted {
1423 [self close]; 1424 [self close];
1424 } 1425 }
1425 1426
1426 @end 1427 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/tabpose_window.h ('k') | chrome/browser/file_path_watcher_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698