| 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "ui/gfx/canvas_skia.h" | 7 #include "ui/gfx/canvas_skia.h" |
| 8 | 8 |
| 9 #include "base/mac_util.h" |
| 9 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| 10 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 11 #include "third_party/skia/include/core/SkShader.h" | 12 #include "third_party/skia/include/core/SkShader.h" |
| 12 #include "ui/gfx/font.h" | 13 #include "ui/gfx/font.h" |
| 13 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 | 17 |
| 17 CanvasSkia::CanvasSkia(int width, int height, bool is_opaque) | 18 CanvasSkia::CanvasSkia(int width, int height, bool is_opaque) |
| 18 : skia::PlatformCanvas(width, height, is_opaque) { | 19 : skia::PlatformCanvas(width, height, is_opaque) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 font.GetNativeFont(), NSFontAttributeName, | 66 font.GetNativeFont(), NSFontAttributeName, |
| 66 ns_color, NSForegroundColorAttributeName, | 67 ns_color, NSForegroundColorAttributeName, |
| 67 ns_style, NSParagraphStyleAttributeName, | 68 ns_style, NSParagraphStyleAttributeName, |
| 68 nil]; | 69 nil]; |
| 69 | 70 |
| 70 NSAttributedString* ns_string = | 71 NSAttributedString* ns_string = |
| 71 [[[NSAttributedString alloc] initWithString:base::SysUTF16ToNSString(text) | 72 [[[NSAttributedString alloc] initWithString:base::SysUTF16ToNSString(text) |
| 72 attributes:attributes] autorelease]; | 73 attributes:attributes] autorelease]; |
| 73 base::mac::ScopedCFTypeRef<CTFramesetterRef> framesetter( | 74 base::mac::ScopedCFTypeRef<CTFramesetterRef> framesetter( |
| 74 CTFramesetterCreateWithAttributedString( | 75 CTFramesetterCreateWithAttributedString( |
| 75 reinterpret_cast<CFAttributedStringRef>(ns_string))); | 76 base::mac::NSToCFCast(ns_string))); |
| 76 | 77 |
| 77 CGRect text_bounds = CGRectMake(x, y, w, h); | 78 CGRect text_bounds = CGRectMake(x, y, w, h); |
| 78 CGMutablePathRef path = CGPathCreateMutable(); | 79 CGMutablePathRef path = CGPathCreateMutable(); |
| 79 CGPathAddRect(path, NULL, text_bounds); | 80 CGPathAddRect(path, NULL, text_bounds); |
| 80 | 81 |
| 81 base::mac::ScopedCFTypeRef<CTFrameRef> frame( | 82 base::mac::ScopedCFTypeRef<CTFrameRef> frame( |
| 82 CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, NULL)); | 83 CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, NULL)); |
| 83 CTFrameDraw(frame, context); | 84 CTFrameDraw(frame, context); |
| 84 CGContextRestoreGState(context); | 85 CGContextRestoreGState(context); |
| 85 endPlatformPaint(); | 86 endPlatformPaint(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 } // namespace gfx | 89 } // namespace gfx |
| OLD | NEW |