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

Side by Side Diff: src/core/SkFontMgr.cpp

Issue 799533004: Move SkFontMgr and SkFontStyle impls to own cpp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: The header is elsewhere... Created 5 years, 11 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
« no previous file with comments | « src/core/SkFontHost.cpp ('k') | src/core/SkFontStyle.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009 The Android Open Source Project 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkFontLCDConfig.h" 8 #include "SkFontMgr.h"
9 #include "SkLazyPtr.h" 9 #include "SkLazyPtr.h"
10 #include "SkTypes.h"
10 11
11 static SkFontLCDConfig::LCDOrientation gLCDOrientation = SkFontLCDConfig::kHoriz ontal_LCDOrientation; 12 class SkFontStyle;
12 static SkFontLCDConfig::LCDOrder gLCDOrder = SkFontLCDConfig::kRGB_LCDOrder; 13 class SkStream;
13 14 class SkTypeface;
14 SkFontLCDConfig::LCDOrientation SkFontLCDConfig::GetSubpixelOrientation() {
15 return gLCDOrientation;
16 }
17
18 void SkFontLCDConfig::SetSubpixelOrientation(LCDOrientation orientation) {
19 gLCDOrientation = orientation;
20 }
21
22 SkFontLCDConfig::LCDOrder SkFontLCDConfig::GetSubpixelOrder() {
23 return gLCDOrder;
24 }
25
26 void SkFontLCDConfig::SetSubpixelOrder(LCDOrder order) {
27 gLCDOrder = order;
28 }
29
30 ///////////////////////////////////////////////////////////////////////////////
31 // Legacy wrappers : remove from SkFontHost when webkit switches to new API
32
33 #include "SkFontHost.h"
34
35 SkFontHost::LCDOrientation SkFontHost::GetSubpixelOrientation() {
36 return (SkFontHost::LCDOrientation)SkFontLCDConfig::GetSubpixelOrientation() ;
37 }
38
39 void SkFontHost::SetSubpixelOrientation(LCDOrientation orientation) {
40 SkFontLCDConfig::SetSubpixelOrientation((SkFontLCDConfig::LCDOrientation)ori entation);
41 }
42
43 SkFontHost::LCDOrder SkFontHost::GetSubpixelOrder() {
44 return (SkFontHost::LCDOrder)SkFontLCDConfig::GetSubpixelOrder();
45 }
46
47 void SkFontHost::SetSubpixelOrder(LCDOrder order) {
48 SkFontLCDConfig::SetSubpixelOrder((SkFontLCDConfig::LCDOrder)order);
49 }
50
51 ///////////////////////////////////////////////////////////////////////////////
52 ///////////////////////////////////////////////////////////////////////////////
53
54 #include "SkFontStyle.h"
55
56 SkFontStyle::SkFontStyle() {
57 fUnion.fU32 = 0;
58 fUnion.fR.fWeight = kNormal_Weight;
59 fUnion.fR.fWidth = kNormal_Width;
60 fUnion.fR.fSlant = kUpright_Slant;
61 }
62
63 SkFontStyle::SkFontStyle(int weight, int width, Slant slant) {
64 fUnion.fU32 = 0;
65 fUnion.fR.fWeight = SkPin32(weight, kThin_Weight, kBlack_Weight);
66 fUnion.fR.fWidth = SkPin32(width, kUltraCondensed_Width, kUltaExpanded_Width );
67 fUnion.fR.fSlant = SkPin32(slant, kUpright_Slant, kItalic_Slant);
68 }
69
70 SkFontStyle::SkFontStyle(unsigned oldStyle) {
71 fUnion.fU32 = 0;
72 fUnion.fR.fWeight = (oldStyle & SkTypeface::kBold) ? SkFontStyle::kBold_Weig ht
73 : SkFontStyle::kNormal_We ight;
74 fUnion.fR.fWidth = SkFontStyle::kNormal_Width;
75 fUnion.fR.fSlant = (oldStyle & SkTypeface::kItalic) ? SkFontStyle::kItalic_S lant
76 : SkFontStyle::kUpright_ Slant;
77 }
78
79 #include "SkFontMgr.h"
80 15
81 class SkEmptyFontStyleSet : public SkFontStyleSet { 16 class SkEmptyFontStyleSet : public SkFontStyleSet {
82 public: 17 public:
83 int count() SK_OVERRIDE { return 0; } 18 int count() SK_OVERRIDE { return 0; }
84 void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE { 19 void getStyle(int, SkFontStyle*, SkString*) SK_OVERRIDE {
85 SkDEBUGFAIL("SkFontStyleSet::getStyle called on empty set"); 20 SkDEBUGFAIL("SkFontStyleSet::getStyle called on empty set");
86 } 21 }
87 SkTypeface* createTypeface(int index) SK_OVERRIDE { 22 SkTypeface* createTypeface(int index) SK_OVERRIDE {
88 SkDEBUGFAIL("SkFontStyleSet::createTypeface called on empty set"); 23 SkDEBUGFAIL("SkFontStyleSet::createTypeface called on empty set");
89 return NULL; 24 return NULL;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 SkFontMgr* sk_fontmgr_create_default() { 148 SkFontMgr* sk_fontmgr_create_default() {
214 SkFontMgr* fm = SkFontMgr::Factory(); 149 SkFontMgr* fm = SkFontMgr::Factory();
215 return fm ? fm : SkNEW(SkEmptyFontMgr); 150 return fm ? fm : SkNEW(SkEmptyFontMgr);
216 } 151 }
217 152
218 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default); 153 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default);
219 154
220 SkFontMgr* SkFontMgr::RefDefault() { 155 SkFontMgr* SkFontMgr::RefDefault() {
221 return SkRef(singleton.get()); 156 return SkRef(singleton.get());
222 } 157 }
OLDNEW
« no previous file with comments | « src/core/SkFontHost.cpp ('k') | src/core/SkFontStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698