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

Side by Side Diff: src/ports/SkFontHost_win.cpp

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontMgr_android.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkAdvancedTypefaceMetrics.h" 9 #include "SkAdvancedTypefaceMetrics.h"
10 #include "SkBase64.h" 10 #include "SkBase64.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 static LogFontTypeface* Create(const LOGFONT& lf) { 249 static LogFontTypeface* Create(const LOGFONT& lf) {
250 return new LogFontTypeface(get_style(lf), lf, false); 250 return new LogFontTypeface(get_style(lf), lf, false);
251 } 251 }
252 252
253 static void EnsureAccessible(const SkTypeface* face) { 253 static void EnsureAccessible(const SkTypeface* face) {
254 call_ensure_accessible(static_cast<const LogFontTypeface*>(face)->fLogFo nt); 254 call_ensure_accessible(static_cast<const LogFontTypeface*>(face)->fLogFo nt);
255 } 255 }
256 256
257 protected: 257 protected:
258 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; 258 SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE;
259 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK _OVERRIDE; 259 SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRID E;
260 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; 260 void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE;
261 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( 261 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
262 SkAdvancedTypefaceMetrics::PerGlyphInfo, 262 SkAdvancedTypefaceMetrics::PerGlyphInfo,
263 const uint32_t*, uint32_t) const SK_OVERRIDE; 263 const uint32_t*, uint32_t) const SK_OVERRIDE;
264 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE ; 264 void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE;
265 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, 265 virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
266 uint16_t glyphs[], int glyphCount) const SK_OVER RIDE; 266 uint16_t glyphs[], int glyphCount) const SK_OVER RIDE;
267 virtual int onCountGlyphs() const SK_OVERRIDE; 267 int onCountGlyphs() const SK_OVERRIDE;
268 virtual int onGetUPEM() const SK_OVERRIDE; 268 int onGetUPEM() const SK_OVERRIDE;
269 virtual void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; 269 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE;
270 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_ OVERRIDE; 270 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE ;
271 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; 271 int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE;
272 virtual size_t onGetTableData(SkFontTableTag, size_t offset, 272 virtual size_t onGetTableData(SkFontTableTag, size_t offset,
273 size_t length, void* data) const SK_OVERRIDE; 273 size_t length, void* data) const SK_OVERRIDE;
274 }; 274 };
275 275
276 class FontMemResourceTypeface : public LogFontTypeface { 276 class FontMemResourceTypeface : public LogFontTypeface {
277 public: 277 public:
278 /** 278 /**
279 * The created FontMemResourceTypeface takes ownership of fontMemResource. 279 * The created FontMemResourceTypeface takes ownership of fontMemResource.
280 */ 280 */
281 static FontMemResourceTypeface* Create(const LOGFONT& lf, HANDLE fontMemReso urce) { 281 static FontMemResourceTypeface* Create(const LOGFONT& lf, HANDLE fontMemReso urce) {
282 return new FontMemResourceTypeface(get_style(lf), lf, fontMemResource); 282 return new FontMemResourceTypeface(get_style(lf), lf, fontMemResource);
283 } 283 }
284 284
285 protected: 285 protected:
286 virtual void weak_dispose() const SK_OVERRIDE { 286 void weak_dispose() const SK_OVERRIDE {
287 RemoveFontMemResourceEx(fFontMemResource); 287 RemoveFontMemResourceEx(fFontMemResource);
288 //SkTypefaceCache::Remove(this); 288 //SkTypefaceCache::Remove(this);
289 INHERITED::weak_dispose(); 289 INHERITED::weak_dispose();
290 } 290 }
291 291
292 private: 292 private:
293 /** 293 /**
294 * Takes ownership of fontMemResource. 294 * Takes ownership of fontMemResource.
295 */ 295 */
296 FontMemResourceTypeface(const SkFontStyle& style, const LOGFONT& lf, HANDLE fontMemResource) 296 FontMemResourceTypeface(const SkFontStyle& style, const LOGFONT& lf, HANDLE fontMemResource)
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 class SkScalerContext_GDI : public SkScalerContext { 534 class SkScalerContext_GDI : public SkScalerContext {
535 public: 535 public:
536 SkScalerContext_GDI(SkTypeface*, const SkDescriptor* desc); 536 SkScalerContext_GDI(SkTypeface*, const SkDescriptor* desc);
537 virtual ~SkScalerContext_GDI(); 537 virtual ~SkScalerContext_GDI();
538 538
539 // Returns true if the constructor was able to complete all of its 539 // Returns true if the constructor was able to complete all of its
540 // initializations (which may include calling GDI). 540 // initializations (which may include calling GDI).
541 bool isValid() const; 541 bool isValid() const;
542 542
543 protected: 543 protected:
544 virtual unsigned generateGlyphCount() SK_OVERRIDE; 544 unsigned generateGlyphCount() SK_OVERRIDE;
545 virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; 545 uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE;
546 virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; 546 void generateAdvance(SkGlyph* glyph) SK_OVERRIDE;
547 virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; 547 void generateMetrics(SkGlyph* glyph) SK_OVERRIDE;
548 virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE; 548 void generateImage(const SkGlyph& glyph) SK_OVERRIDE;
549 virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; 549 void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE;
550 virtual void generateFontMetrics(SkPaint::FontMetrics*) SK_OVERRIDE; 550 void generateFontMetrics(SkPaint::FontMetrics*) SK_OVERRIDE;
551 551
552 private: 552 private:
553 DWORD getGDIGlyphPath(const SkGlyph& glyph, UINT flags, 553 DWORD getGDIGlyphPath(const SkGlyph& glyph, UINT flags,
554 SkAutoSTMalloc<BUFFERSIZE, uint8_t>* glyphbuf); 554 SkAutoSTMalloc<BUFFERSIZE, uint8_t>* glyphbuf);
555 555
556 HDCOffscreen fOffscreen; 556 HDCOffscreen fOffscreen;
557 /** fGsA is the non-rotational part of total matrix without the text height scale. 557 /** fGsA is the non-rotational part of total matrix without the text height scale.
558 * Used to find the magnitude of advances. 558 * Used to find the magnitude of advances.
559 */ 559 */
560 MAT2 fGsA; 560 MAT2 fGsA;
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 LOGFONT lf; 2382 LOGFONT lf;
2383 sk_bzero(&lf, sizeof(lf)); 2383 sk_bzero(&lf, sizeof(lf));
2384 lf.lfCharSet = DEFAULT_CHARSET; 2384 lf.lfCharSet = DEFAULT_CHARSET;
2385 _tcscpy_s(lf.lfFaceName, familyName); 2385 _tcscpy_s(lf.lfFaceName, familyName);
2386 2386
2387 HDC hdc = ::CreateCompatibleDC(NULL); 2387 HDC hdc = ::CreateCompatibleDC(NULL);
2388 ::EnumFontFamiliesEx(hdc, &lf, enum_family_proc, (LPARAM)&fArray, 0); 2388 ::EnumFontFamiliesEx(hdc, &lf, enum_family_proc, (LPARAM)&fArray, 0);
2389 ::DeleteDC(hdc); 2389 ::DeleteDC(hdc);
2390 } 2390 }
2391 2391
2392 virtual int count() SK_OVERRIDE { 2392 int count() SK_OVERRIDE {
2393 return fArray.count(); 2393 return fArray.count();
2394 } 2394 }
2395 2395
2396 virtual void getStyle(int index, SkFontStyle* fs, SkString* styleName) SK_OV ERRIDE { 2396 void getStyle(int index, SkFontStyle* fs, SkString* styleName) SK_OVERRIDE {
2397 if (fs) { 2397 if (fs) {
2398 *fs = get_style(fArray[index].elfLogFont); 2398 *fs = get_style(fArray[index].elfLogFont);
2399 } 2399 }
2400 if (styleName) { 2400 if (styleName) {
2401 const ENUMLOGFONTEX& ref = fArray[index]; 2401 const ENUMLOGFONTEX& ref = fArray[index];
2402 // For some reason, ENUMLOGFONTEX and LOGFONT disagree on their type in the 2402 // For some reason, ENUMLOGFONTEX and LOGFONT disagree on their type in the
2403 // non-unicode version. 2403 // non-unicode version.
2404 // ENUMLOGFONTEX uses BYTE 2404 // ENUMLOGFONTEX uses BYTE
2405 // LOGFONT uses CHAR 2405 // LOGFONT uses CHAR
2406 // Here we assert they that the style name is logically the same (si ze) as 2406 // Here we assert they that the style name is logically the same (si ze) as
2407 // a TCHAR, so we can use the same converter function. 2407 // a TCHAR, so we can use the same converter function.
2408 SkASSERT(sizeof(TCHAR) == sizeof(ref.elfStyle[0])); 2408 SkASSERT(sizeof(TCHAR) == sizeof(ref.elfStyle[0]));
2409 tchar_to_skstring((const TCHAR*)ref.elfStyle, styleName); 2409 tchar_to_skstring((const TCHAR*)ref.elfStyle, styleName);
2410 } 2410 }
2411 } 2411 }
2412 2412
2413 virtual SkTypeface* createTypeface(int index) SK_OVERRIDE { 2413 SkTypeface* createTypeface(int index) SK_OVERRIDE {
2414 return SkCreateTypefaceFromLOGFONT(fArray[index].elfLogFont); 2414 return SkCreateTypefaceFromLOGFONT(fArray[index].elfLogFont);
2415 } 2415 }
2416 2416
2417 virtual SkTypeface* matchStyle(const SkFontStyle& pattern) SK_OVERRIDE { 2417 SkTypeface* matchStyle(const SkFontStyle& pattern) SK_OVERRIDE {
2418 // todo: 2418 // todo:
2419 return SkCreateTypefaceFromLOGFONT(fArray[0].elfLogFont); 2419 return SkCreateTypefaceFromLOGFONT(fArray[0].elfLogFont);
2420 } 2420 }
2421 2421
2422 private: 2422 private:
2423 SkTDArray<ENUMLOGFONTEX> fArray; 2423 SkTDArray<ENUMLOGFONTEX> fArray;
2424 }; 2424 };
2425 2425
2426 class SkFontMgrGDI : public SkFontMgr { 2426 class SkFontMgrGDI : public SkFontMgr {
2427 public: 2427 public:
2428 SkFontMgrGDI() { 2428 SkFontMgrGDI() {
2429 LOGFONT lf; 2429 LOGFONT lf;
2430 sk_bzero(&lf, sizeof(lf)); 2430 sk_bzero(&lf, sizeof(lf));
2431 lf.lfCharSet = DEFAULT_CHARSET; 2431 lf.lfCharSet = DEFAULT_CHARSET;
2432 2432
2433 HDC hdc = ::CreateCompatibleDC(NULL); 2433 HDC hdc = ::CreateCompatibleDC(NULL);
2434 ::EnumFontFamiliesEx(hdc, &lf, enum_family_proc, (LPARAM)&fLogFontArray, 0); 2434 ::EnumFontFamiliesEx(hdc, &lf, enum_family_proc, (LPARAM)&fLogFontArray, 0);
2435 ::DeleteDC(hdc); 2435 ::DeleteDC(hdc);
2436 } 2436 }
2437 2437
2438 protected: 2438 protected:
2439 virtual int onCountFamilies() const SK_OVERRIDE { 2439 int onCountFamilies() const SK_OVERRIDE {
2440 return fLogFontArray.count(); 2440 return fLogFontArray.count();
2441 } 2441 }
2442 2442
2443 virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERR IDE { 2443 void onGetFamilyName(int index, SkString* familyName) const SK_OVERRIDE {
2444 SkASSERT((unsigned)index < (unsigned)fLogFontArray.count()); 2444 SkASSERT((unsigned)index < (unsigned)fLogFontArray.count());
2445 tchar_to_skstring(fLogFontArray[index].elfLogFont.lfFaceName, familyName ); 2445 tchar_to_skstring(fLogFontArray[index].elfLogFont.lfFaceName, familyName );
2446 } 2446 }
2447 2447
2448 virtual SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE { 2448 SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE {
2449 SkASSERT((unsigned)index < (unsigned)fLogFontArray.count()); 2449 SkASSERT((unsigned)index < (unsigned)fLogFontArray.count());
2450 return SkNEW_ARGS(SkFontStyleSetGDI, (fLogFontArray[index].elfLogFont.lf FaceName)); 2450 return SkNEW_ARGS(SkFontStyleSetGDI, (fLogFontArray[index].elfLogFont.lf FaceName));
2451 } 2451 }
2452 2452
2453 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVER RIDE { 2453 SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVERRIDE {
2454 if (NULL == familyName) { 2454 if (NULL == familyName) {
2455 familyName = ""; // do we need this check??? 2455 familyName = ""; // do we need this check???
2456 } 2456 }
2457 LOGFONT lf; 2457 LOGFONT lf;
2458 logfont_for_name(familyName, &lf); 2458 logfont_for_name(familyName, &lf);
2459 return SkNEW_ARGS(SkFontStyleSetGDI, (lf.lfFaceName)); 2459 return SkNEW_ARGS(SkFontStyleSetGDI, (lf.lfFaceName));
2460 } 2460 }
2461 2461
2462 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], 2462 virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
2463 const SkFontStyle& fontstyle) const S K_OVERRIDE { 2463 const SkFontStyle& fontstyle) const S K_OVERRIDE {
2464 // could be in base impl 2464 // could be in base impl
2465 SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName)); 2465 SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName));
2466 return sset->matchStyle(fontstyle); 2466 return sset->matchStyle(fontstyle);
2467 } 2467 }
2468 2468
2469 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con st SkFontStyle&, 2469 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con st SkFontStyle&,
2470 const char* bcp47[], int bcp 47Count, 2470 const char* bcp47[], int bcp 47Count,
2471 SkUnichar character) const S K_OVERRIDE { 2471 SkUnichar character) const S K_OVERRIDE {
2472 return NULL; 2472 return NULL;
2473 } 2473 }
2474 2474
2475 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, 2475 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
2476 const SkFontStyle& fontstyle) const SK_ OVERRIDE { 2476 const SkFontStyle& fontstyle) const SK_ OVERRIDE {
2477 // could be in base impl 2477 // could be in base impl
2478 SkString familyName; 2478 SkString familyName;
2479 ((LogFontTypeface*)familyMember)->getFamilyName(&familyName); 2479 ((LogFontTypeface*)familyMember)->getFamilyName(&familyName);
2480 return this->matchFamilyStyle(familyName.c_str(), fontstyle); 2480 return this->matchFamilyStyle(familyName.c_str(), fontstyle);
2481 } 2481 }
2482 2482
2483 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE { 2483 SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVER RIDE {
2484 return create_from_stream(stream); 2484 return create_from_stream(stream);
2485 } 2485 }
2486 2486
2487 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OV ERRIDE { 2487 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OVERRIDE {
2488 // could be in base impl 2488 // could be in base impl
2489 SkAutoTUnref<SkStream> stream(SkNEW_ARGS(SkMemoryStream, (data))); 2489 SkAutoTUnref<SkStream> stream(SkNEW_ARGS(SkMemoryStream, (data)));
2490 return this->createFromStream(stream); 2490 return this->createFromStream(stream);
2491 } 2491 }
2492 2492
2493 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERRIDE { 2493 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR IDE {
2494 // could be in base impl 2494 // could be in base impl
2495 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); 2495 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
2496 return this->createFromStream(stream); 2496 return this->createFromStream(stream);
2497 } 2497 }
2498 2498
2499 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], 2499 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
2500 unsigned styleBits) const SK_OVER RIDE { 2500 unsigned styleBits) const SK_OVER RIDE {
2501 LOGFONT lf; 2501 LOGFONT lf;
2502 if (NULL == familyName) { 2502 if (NULL == familyName) {
2503 lf = get_default_font(); 2503 lf = get_default_font();
2504 } else { 2504 } else {
2505 logfont_for_name(familyName, &lf); 2505 logfont_for_name(familyName, &lf);
2506 } 2506 }
2507 2507
2508 SkTypeface::Style style = (SkTypeface::Style)styleBits; 2508 SkTypeface::Style style = (SkTypeface::Style)styleBits;
2509 lf.lfWeight = (style & SkTypeface::kBold) != 0 ? FW_BOLD : FW_NORMAL; 2509 lf.lfWeight = (style & SkTypeface::kBold) != 0 ? FW_BOLD : FW_NORMAL;
2510 lf.lfItalic = ((style & SkTypeface::kItalic) != 0); 2510 lf.lfItalic = ((style & SkTypeface::kItalic) != 0);
2511 return SkCreateTypefaceFromLOGFONT(lf); 2511 return SkCreateTypefaceFromLOGFONT(lf);
2512 } 2512 }
2513 2513
2514 private: 2514 private:
2515 SkTDArray<ENUMLOGFONTEX> fLogFontArray; 2515 SkTDArray<ENUMLOGFONTEX> fLogFontArray;
2516 }; 2516 };
2517 2517
2518 /////////////////////////////////////////////////////////////////////////////// 2518 ///////////////////////////////////////////////////////////////////////////////
2519 2519
2520 SkFontMgr* SkFontMgr_New_GDI() { 2520 SkFontMgr* SkFontMgr_New_GDI() {
2521 return SkNEW(SkFontMgrGDI); 2521 return SkNEW(SkFontMgrGDI);
2522 } 2522 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontMgr_android.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698