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

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

Issue 1879423002: Remove requestedStyle from SkTypefaceCache. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More interesting coverage. Created 4 years, 8 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_fontconfig.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkTypes.h" 8 #include "SkTypes.h"
9 #if defined(SK_BUILD_FOR_WIN32) 9 #if defined(SK_BUILD_FOR_WIN32)
10 10
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 HANDLE fFontMemResource; 301 HANDLE fFontMemResource;
302 302
303 typedef LogFontTypeface INHERITED; 303 typedef LogFontTypeface INHERITED;
304 }; 304 };
305 305
306 static const LOGFONT& get_default_font() { 306 static const LOGFONT& get_default_font() {
307 static LOGFONT gDefaultFont; 307 static LOGFONT gDefaultFont;
308 return gDefaultFont; 308 return gDefaultFont;
309 } 309 }
310 310
311 static bool FindByLogFont(SkTypeface* face, const SkFontStyle& requestedStyle, v oid* ctx) { 311 static bool FindByLogFont(SkTypeface* face, void* ctx) {
312 LogFontTypeface* lface = static_cast<LogFontTypeface*>(face); 312 LogFontTypeface* lface = static_cast<LogFontTypeface*>(face);
313 const LOGFONT* lf = reinterpret_cast<const LOGFONT*>(ctx); 313 const LOGFONT* lf = reinterpret_cast<const LOGFONT*>(ctx);
314 314
315 return lface && 315 return !memcmp(&lface->fLogFont, lf, sizeof(LOGFONT));
316 get_style(lface->fLogFont) == requestedStyle &&
317 !memcmp(&lface->fLogFont, lf, sizeof(LOGFONT));
318 } 316 }
319 317
320 /** 318 /**
321 * This guy is public. It first searches the cache, and if a match is not found , 319 * This guy is public. It first searches the cache, and if a match is not found ,
322 * it creates a new face. 320 * it creates a new face.
323 */ 321 */
324 SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT& origLF) { 322 SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT& origLF) {
325 LOGFONT lf = origLF; 323 LOGFONT lf = origLF;
326 make_canonical(&lf); 324 make_canonical(&lf);
327 SkTypeface* face = SkTypefaceCache::FindByProcAndRef(FindByLogFont, &lf); 325 SkTypeface* face = SkTypefaceCache::FindByProcAndRef(FindByLogFont, &lf);
328 if (nullptr == face) { 326 if (nullptr == face) {
329 face = LogFontTypeface::Create(lf); 327 face = LogFontTypeface::Create(lf);
330 SkTypefaceCache::Add(face, get_style(lf)); 328 SkTypefaceCache::Add(face);
331 } 329 }
332 return face; 330 return face;
333 } 331 }
334 332
335 /** 333 /**
336 * The created SkTypeface takes ownership of fontMemResource. 334 * The created SkTypeface takes ownership of fontMemResource.
337 */ 335 */
338 SkTypeface* SkCreateFontMemResourceTypefaceFromLOGFONT(const LOGFONT& origLF, HA NDLE fontMemResource) { 336 SkTypeface* SkCreateFontMemResourceTypefaceFromLOGFONT(const LOGFONT& origLF, HA NDLE fontMemResource) {
339 LOGFONT lf = origLF; 337 LOGFONT lf = origLF;
340 make_canonical(&lf); 338 make_canonical(&lf);
(...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 2514
2517 private: 2515 private:
2518 SkTDArray<ENUMLOGFONTEX> fLogFontArray; 2516 SkTDArray<ENUMLOGFONTEX> fLogFontArray;
2519 }; 2517 };
2520 2518
2521 /////////////////////////////////////////////////////////////////////////////// 2519 ///////////////////////////////////////////////////////////////////////////////
2522 2520
2523 SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; } 2521 SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; }
2524 2522
2525 #endif//defined(SK_BUILD_FOR_WIN32) 2523 #endif//defined(SK_BUILD_FOR_WIN32)
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkFontMgr_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698