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

Side by Side Diff: src/ports/SkTypeface_win_dw.h

Issue 314193002: Split SkFontHost_win_dw. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unneeded includes. Created 6 years, 6 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/ports/SkScalerContext_win_dw.h ('k') | src/ports/SkTypeface_win_dw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkTypeface_win_dw_DEFINED
9 #define SkTypeface_win_dw_DEFINED
10
11 #include "SkAdvancedTypefaceMetrics.h"
12 #include "SkDWrite.h"
13 #include "SkHRESULT.h"
14 #include "SkTScopedComPtr.h"
15 #include "SkTypeface.h"
16 #include "SkTypefaceCache.h"
17 #include "SkTypes.h"
18
19 #include <dwrite.h>
20
21 class SkFontDescriptor;
22 struct SkScalerContextRec;
23
24 static SkTypeface::Style get_style(IDWriteFont* font) {
25 int style = SkTypeface::kNormal;
26 DWRITE_FONT_WEIGHT weight = font->GetWeight();
27 if (DWRITE_FONT_WEIGHT_DEMI_BOLD <= weight) {
28 style |= SkTypeface::kBold;
29 }
30 DWRITE_FONT_STYLE angle = font->GetStyle();
31 if (DWRITE_FONT_STYLE_OBLIQUE == angle || DWRITE_FONT_STYLE_ITALIC == angle) {
32 style |= SkTypeface::kItalic;
33 }
34 return static_cast<SkTypeface::Style>(style);
35 }
36
37 class DWriteFontTypeface : public SkTypeface {
38 private:
39 DWriteFontTypeface(SkTypeface::Style style, SkFontID fontID,
40 IDWriteFactory* factory,
41 IDWriteFontFace* fontFace,
42 IDWriteFont* font,
43 IDWriteFontFamily* fontFamily,
44 IDWriteFontFileLoader* fontFileLoader = NULL,
45 IDWriteFontCollectionLoader* fontCollectionLoader = NULL)
46 : SkTypeface(style, fontID, false)
47 , fFactory(SkRefComPtr(factory))
48 , fDWriteFontCollectionLoader(SkSafeRefComPtr(fontCollectionLoader))
49 , fDWriteFontFileLoader(SkSafeRefComPtr(fontFileLoader))
50 , fDWriteFontFamily(SkRefComPtr(fontFamily))
51 , fDWriteFont(SkRefComPtr(font))
52 , fDWriteFontFace(SkRefComPtr(fontFace))
53 { }
54
55 public:
56 SkTScopedComPtr<IDWriteFactory> fFactory;
57 SkTScopedComPtr<IDWriteFontCollectionLoader> fDWriteFontCollectionLoader;
58 SkTScopedComPtr<IDWriteFontFileLoader> fDWriteFontFileLoader;
59 SkTScopedComPtr<IDWriteFontFamily> fDWriteFontFamily;
60 SkTScopedComPtr<IDWriteFont> fDWriteFont;
61 SkTScopedComPtr<IDWriteFontFace> fDWriteFontFace;
62
63 static DWriteFontTypeface* Create(IDWriteFactory* factory,
64 IDWriteFontFace* fontFace,
65 IDWriteFont* font,
66 IDWriteFontFamily* fontFamily,
67 IDWriteFontFileLoader* fontFileLoader = NU LL,
68 IDWriteFontCollectionLoader* fontCollectio nLoader = NULL) {
69 SkTypeface::Style style = get_style(font);
70 SkFontID fontID = SkTypefaceCache::NewFontID();
71 return SkNEW_ARGS(DWriteFontTypeface, (style, fontID,
72 factory, fontFace, font, fontFami ly,
73 fontFileLoader, fontCollectionLoa der));
74 }
75
76 protected:
77 virtual void weak_dispose() const SK_OVERRIDE {
78 if (fDWriteFontCollectionLoader.get()) {
79 HRV(fFactory->UnregisterFontCollectionLoader(fDWriteFontCollectionLo ader.get()));
80 }
81 if (fDWriteFontFileLoader.get()) {
82 HRV(fFactory->UnregisterFontFileLoader(fDWriteFontFileLoader.get())) ;
83 }
84
85 //SkTypefaceCache::Remove(this);
86 INHERITED::weak_dispose();
87 }
88
89 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE;
90 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK _OVERRIDE;
91 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE;
92 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
93 SkAdvancedTypefaceMetrics::PerGlyphInfo,
94 const uint32_t*, uint32_t) const SK_OVERRIDE;
95 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE ;
96 virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
97 uint16_t glyphs[], int glyphCount) const SK_OVER RIDE;
98 virtual int onCountGlyphs() const SK_OVERRIDE;
99 virtual int onGetUPEM() const SK_OVERRIDE;
100 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_ OVERRIDE;
101 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE;
102 virtual size_t onGetTableData(SkFontTableTag, size_t offset,
103 size_t length, void* data) const SK_OVERRIDE;
104
105 private:
106 typedef SkTypeface INHERITED;
107 };
108
109 #endif
OLDNEW
« no previous file with comments | « src/ports/SkScalerContext_win_dw.h ('k') | src/ports/SkTypeface_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698