diff options
author | groby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 02:52:40 +0000 |
---|---|---|
committer | groby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-10 02:52:40 +0000 |
commit | c382f649d425e4a4a534ff73dc1b9836e27ae6af (patch) | |
tree | ccedfc848519a8e8b783507052778b0dad1c32f0 /ui/gfx/canvas_mac.mm | |
parent | 754b1c4b3c8fca1834b1833a78c4dd22542febc6 (diff) | |
download | chromium_src-c382f649d425e4a4a534ff73dc1b9836e27ae6af.zip chromium_src-c382f649d425e4a4a534ff73dc1b9836e27ae6af.tar.gz chromium_src-c382f649d425e4a4a534ff73dc1b9836e27ae6af.tar.bz2 |
Turn on canvas_skia for OSX
Re-submit of r221930, with fixed include path.
TBR=asvitkine@chromium.org
BUG=151935
Review URL: https://chromiumcodereview.appspot.com/23454018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/canvas_mac.mm')
-rw-r--r-- | ui/gfx/canvas_mac.mm | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/ui/gfx/canvas_mac.mm b/ui/gfx/canvas_mac.mm deleted file mode 100644 index 247c28b..0000000 --- a/ui/gfx/canvas_mac.mm +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2012 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. - -#include "ui/gfx/canvas.h" - -#import <Cocoa/Cocoa.h> - -#include "base/logging.h" -#include "base/strings/sys_string_conversions.h" -#include "third_party/skia/include/core/SkTypeface.h" -#include "ui/gfx/font_list.h" -#include "ui/gfx/rect.h" - -// Note: This is a temporary Skia-based implementation of the ui/gfx text -// rendering routines for views/aura. It replaces the stale Cocoa-based -// implementation. A future |canvas_skia.cc| implementation will supersede -// this and the other platform-specific implmenentations. Most drawing options, -// such as alignment, multi-line, and line heights are not implemented here. - -namespace { - -SkTypeface::Style FontTypefaceStyle(const gfx::Font& font) { - int style = 0; - if (font.GetStyle() & gfx::Font::BOLD) - style |= SkTypeface::kBold; - if (font.GetStyle() & gfx::Font::ITALIC) - style |= SkTypeface::kItalic; - - return static_cast<SkTypeface::Style>(style); -} - -} // namespace - -namespace gfx { - -// static -void Canvas::SizeStringInt(const base::string16& text, - const FontList& font_list, - int* width, - int* height, - int line_height, - int flags) { - DLOG_IF(WARNING, line_height != 0) << "Line heights not implemented."; - DLOG_IF(WARNING, flags & Canvas::MULTI_LINE) << "Multi-line not implemented."; - - NSFont* native_font = font_list.GetPrimaryFont().GetNativeFont(); - NSString* ns_string = base::SysUTF16ToNSString(text); - NSDictionary* attributes = - [NSDictionary dictionaryWithObject:native_font - forKey:NSFontAttributeName]; - NSSize string_size = [ns_string sizeWithAttributes:attributes]; - *width = string_size.width; - *height = font_list.GetHeight(); -} - -void Canvas::DrawStringRectWithShadows(const base::string16& text, - const FontList& font_list, - SkColor color, - const Rect& text_bounds, - int line_height, - int flags, - const ShadowValues& shadows) { - DLOG_IF(WARNING, line_height != 0) << "Line heights not implemented."; - DLOG_IF(WARNING, flags & Canvas::MULTI_LINE) << "Multi-line not implemented."; - DLOG_IF(WARNING, !shadows.empty()) << "Text shadows not implemented."; - - const Font& font = font_list.GetPrimaryFont(); - skia::RefPtr<SkTypeface> typeface = skia::AdoptRef( - SkTypeface::CreateFromName( - font.GetFontName().c_str(), FontTypefaceStyle(font))); - SkPaint paint; - paint.setTypeface(typeface.get()); - paint.setColor(color); - canvas_->drawText(text.c_str(), - text.size() * sizeof(base::string16::value_type), - text_bounds.x(), - text_bounds.bottom(), - paint); -} - -void Canvas::DrawStringRectWithHalo(const base::string16& text, - const FontList& font_list, - SkColor text_color, - SkColor halo_color, - const Rect& display_rect, - int flags) { -} - -} // namespace gfx |