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

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

Issue 552383002: Detect presence of dwrite_1.h. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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.cpp ('k') | src/utils/win/SkDWrite.h » ('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 2014 Google Inc. 2 * Copyright 2014 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 #ifndef SkTypeface_win_dw_DEFINED 8 #ifndef SkTypeface_win_dw_DEFINED
9 #define SkTypeface_win_dw_DEFINED 9 #define SkTypeface_win_dw_DEFINED
10 10
11 #include "SkAdvancedTypefaceMetrics.h" 11 #include "SkAdvancedTypefaceMetrics.h"
12 #include "SkDWrite.h" 12 #include "SkDWrite.h"
13 #include "SkHRESULT.h" 13 #include "SkHRESULT.h"
14 #include "SkTScopedComPtr.h" 14 #include "SkTScopedComPtr.h"
15 #include "SkTypeface.h" 15 #include "SkTypeface.h"
16 #include "SkTypefaceCache.h" 16 #include "SkTypefaceCache.h"
17 #include "SkTypes.h" 17 #include "SkTypes.h"
18 18
19 #include <dwrite.h> 19 #include <dwrite.h>
20 #include <dwrite_1.h> 20 #if SK_HAS_DWRITE_1_H
21 # include <dwrite_1.h>
22 #endif
21 23
22 class SkFontDescriptor; 24 class SkFontDescriptor;
23 struct SkScalerContextRec; 25 struct SkScalerContextRec;
24 26
25 static SkTypeface::Style get_style(IDWriteFont* font) { 27 static SkTypeface::Style get_style(IDWriteFont* font) {
26 int style = SkTypeface::kNormal; 28 int style = SkTypeface::kNormal;
27 DWRITE_FONT_WEIGHT weight = font->GetWeight(); 29 DWRITE_FONT_WEIGHT weight = font->GetWeight();
28 if (DWRITE_FONT_WEIGHT_DEMI_BOLD <= weight) { 30 if (DWRITE_FONT_WEIGHT_DEMI_BOLD <= weight) {
29 style |= SkTypeface::kBold; 31 style |= SkTypeface::kBold;
30 } 32 }
(...skipping 14 matching lines...) Expand all
45 IDWriteFontFileLoader* fontFileLoader = NULL, 47 IDWriteFontFileLoader* fontFileLoader = NULL,
46 IDWriteFontCollectionLoader* fontCollectionLoader = NULL) 48 IDWriteFontCollectionLoader* fontCollectionLoader = NULL)
47 : SkTypeface(style, fontID, false) 49 : SkTypeface(style, fontID, false)
48 , fFactory(SkRefComPtr(factory)) 50 , fFactory(SkRefComPtr(factory))
49 , fDWriteFontCollectionLoader(SkSafeRefComPtr(fontCollectionLoader)) 51 , fDWriteFontCollectionLoader(SkSafeRefComPtr(fontCollectionLoader))
50 , fDWriteFontFileLoader(SkSafeRefComPtr(fontFileLoader)) 52 , fDWriteFontFileLoader(SkSafeRefComPtr(fontFileLoader))
51 , fDWriteFontFamily(SkRefComPtr(fontFamily)) 53 , fDWriteFontFamily(SkRefComPtr(fontFamily))
52 , fDWriteFont(SkRefComPtr(font)) 54 , fDWriteFont(SkRefComPtr(font))
53 , fDWriteFontFace(SkRefComPtr(fontFace)) 55 , fDWriteFontFace(SkRefComPtr(fontFace))
54 { 56 {
57 #if SK_HAS_DWRITE_1_H
55 if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) { 58 if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) {
56 // IUnknown::QueryInterface states that if it fails, punk will be se t to NULL. 59 // IUnknown::QueryInterface states that if it fails, punk will be se t to NULL.
57 // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx 60 // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
58 SK_ALWAYSBREAK(NULL == fDWriteFontFace1.get()); 61 SK_ALWAYSBREAK(NULL == fDWriteFontFace1.get());
59 } 62 }
63 #endif
60 } 64 }
61 65
62 public: 66 public:
63 SkTScopedComPtr<IDWriteFactory> fFactory; 67 SkTScopedComPtr<IDWriteFactory> fFactory;
64 SkTScopedComPtr<IDWriteFontCollectionLoader> fDWriteFontCollectionLoader; 68 SkTScopedComPtr<IDWriteFontCollectionLoader> fDWriteFontCollectionLoader;
65 SkTScopedComPtr<IDWriteFontFileLoader> fDWriteFontFileLoader; 69 SkTScopedComPtr<IDWriteFontFileLoader> fDWriteFontFileLoader;
66 SkTScopedComPtr<IDWriteFontFamily> fDWriteFontFamily; 70 SkTScopedComPtr<IDWriteFontFamily> fDWriteFontFamily;
67 SkTScopedComPtr<IDWriteFont> fDWriteFont; 71 SkTScopedComPtr<IDWriteFont> fDWriteFont;
68 SkTScopedComPtr<IDWriteFontFace> fDWriteFontFace; 72 SkTScopedComPtr<IDWriteFontFace> fDWriteFontFace;
73 #if SK_HAS_DWRITE_1_H
69 SkTScopedComPtr<IDWriteFontFace1> fDWriteFontFace1; 74 SkTScopedComPtr<IDWriteFontFace1> fDWriteFontFace1;
75 #endif
70 76
71 static DWriteFontTypeface* Create(IDWriteFactory* factory, 77 static DWriteFontTypeface* Create(IDWriteFactory* factory,
72 IDWriteFontFace* fontFace, 78 IDWriteFontFace* fontFace,
73 IDWriteFont* font, 79 IDWriteFont* font,
74 IDWriteFontFamily* fontFamily, 80 IDWriteFontFamily* fontFamily,
75 IDWriteFontFileLoader* fontFileLoader = NU LL, 81 IDWriteFontFileLoader* fontFileLoader = NU LL,
76 IDWriteFontCollectionLoader* fontCollectio nLoader = NULL) { 82 IDWriteFontCollectionLoader* fontCollectio nLoader = NULL) {
77 SkTypeface::Style style = get_style(font); 83 SkTypeface::Style style = get_style(font);
78 SkFontID fontID = SkTypefaceCache::NewFontID(); 84 SkFontID fontID = SkTypefaceCache::NewFontID();
79 return SkNEW_ARGS(DWriteFontTypeface, (style, fontID, 85 return SkNEW_ARGS(DWriteFontTypeface, (style, fontID,
(...skipping 28 matching lines...) Expand all
108 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_ OVERRIDE; 114 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_ OVERRIDE;
109 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; 115 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE;
110 virtual size_t onGetTableData(SkFontTableTag, size_t offset, 116 virtual size_t onGetTableData(SkFontTableTag, size_t offset,
111 size_t length, void* data) const SK_OVERRIDE; 117 size_t length, void* data) const SK_OVERRIDE;
112 118
113 private: 119 private:
114 typedef SkTypeface INHERITED; 120 typedef SkTypeface INHERITED;
115 }; 121 };
116 122
117 #endif 123 #endif
OLDNEW
« no previous file with comments | « src/ports/SkScalerContext_win_dw.cpp ('k') | src/utils/win/SkDWrite.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698