| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "gfx/canvas.h" | 7 #include "gfx/canvas.h" |
| 8 | 8 |
| 9 #include "base/scoped_cftyperef.h" | 9 #include "base/scoped_cftyperef.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 int flags) { | 37 int flags) { |
| 38 if (!IntersectsClipRectInt(x, y, w, h)) | 38 if (!IntersectsClipRectInt(x, y, w, h)) |
| 39 return; | 39 return; |
| 40 | 40 |
| 41 CGContextRef context = beginPlatformPaint(); | 41 CGContextRef context = beginPlatformPaint(); |
| 42 CGContextSaveGState(context); | 42 CGContextSaveGState(context); |
| 43 | 43 |
| 44 NSColor* ns_color = [NSColor colorWithDeviceRed:SkColorGetR(color) / 255.0 | 44 NSColor* ns_color = [NSColor colorWithDeviceRed:SkColorGetR(color) / 255.0 |
| 45 green:SkColorGetG(color) / 255.0 | 45 green:SkColorGetG(color) / 255.0 |
| 46 blue:SkColorGetB(color) / 255.0 | 46 blue:SkColorGetB(color) / 255.0 |
| 47 alpha:1.0]; | 47 alpha:SkColorGetA(color) / 255.0]; |
| 48 NSMutableParagraphStyle *ns_style = | 48 NSMutableParagraphStyle *ns_style = |
| 49 [[[NSParagraphStyle alloc] init] autorelease]; | 49 [[[NSParagraphStyle alloc] init] autorelease]; |
| 50 if (flags & TEXT_ALIGN_CENTER) | 50 if (flags & TEXT_ALIGN_CENTER) |
| 51 [ns_style setAlignment:NSCenterTextAlignment]; | 51 [ns_style setAlignment:NSCenterTextAlignment]; |
| 52 // TODO(awalker): Implement the rest of the Canvas text flags | 52 // TODO(awalker): Implement the rest of the Canvas text flags |
| 53 | 53 |
| 54 NSDictionary* attributes = | 54 NSDictionary* attributes = |
| 55 [NSDictionary dictionaryWithObjectsAndKeys: | 55 [NSDictionary dictionaryWithObjectsAndKeys: |
| 56 font.nativeFont(), NSFontAttributeName, | 56 font.nativeFont(), NSFontAttributeName, |
| 57 ns_color, NSForegroundColorAttributeName, | 57 ns_color, NSForegroundColorAttributeName, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 69 CGPathAddRect(path, NULL, text_bounds); | 69 CGPathAddRect(path, NULL, text_bounds); |
| 70 | 70 |
| 71 scoped_cftyperef<CTFrameRef> frame( | 71 scoped_cftyperef<CTFrameRef> frame( |
| 72 CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, NULL)); | 72 CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, NULL)); |
| 73 CTFrameDraw(frame, context); | 73 CTFrameDraw(frame, context); |
| 74 CGContextRestoreGState(context); | 74 CGContextRestoreGState(context); |
| 75 endPlatformPaint(); | 75 endPlatformPaint(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace gfx | 78 } // namespace gfx |
| OLD | NEW |