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

Side by Side Diff: core/fxge/android/cfpf_skiafontmgr.cpp

Issue 2451493002: Refcount all the IFX_ stream classes all the time. (Closed)
Patch Set: Clean up cast expression Created 4 years 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 | « core/fxge/android/cfpf_skiafontmgr.h ('k') | core/fxge/fx_font.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 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fxge/android/cfpf_skiafontmgr.h" 7 #include "core/fxge/android/cfpf_skiafontmgr.h"
8 8
9 #define FPF_SKIAMATCHWEIGHT_NAME1 62 9 #define FPF_SKIAMATCHWEIGHT_NAME1 62
10 #define FPF_SKIAMATCHWEIGHT_NAME2 60 10 #define FPF_SKIAMATCHWEIGHT_NAME2 60
(...skipping 10 matching lines...) Expand all
21 #include "core/fxge/android/cfpf_skiapathfont.h" 21 #include "core/fxge/android/cfpf_skiapathfont.h"
22 #include "core/fxge/fx_freetype.h" 22 #include "core/fxge/fx_freetype.h"
23 23
24 #ifdef __cplusplus 24 #ifdef __cplusplus
25 extern "C" { 25 extern "C" {
26 #endif 26 #endif
27 static unsigned long FPF_SkiaStream_Read(FXFT_Stream stream, 27 static unsigned long FPF_SkiaStream_Read(FXFT_Stream stream,
28 unsigned long offset, 28 unsigned long offset,
29 unsigned char* buffer, 29 unsigned char* buffer,
30 unsigned long count) { 30 unsigned long count) {
31 if (count == 0)
32 return 0;
33
31 IFX_SeekableReadStream* pFileRead = 34 IFX_SeekableReadStream* pFileRead =
32 (IFX_SeekableReadStream*)stream->descriptor.pointer; 35 static_cast<IFX_SeekableReadStream*>(stream->descriptor.pointer);
33 if (!pFileRead) 36 if (!pFileRead)
34 return 0; 37 return 0;
35 if (count > 0) { 38
36 if (!pFileRead->ReadBlock(buffer, (FX_FILESIZE)offset, (size_t)count)) 39 if (!pFileRead->ReadBlock(buffer, (FX_FILESIZE)offset, (size_t)count))
37 return 0; 40 return 0;
38 } 41
39 return count; 42 return count;
40 } 43 }
41 44
42 static void FPF_SkiaStream_Close(FXFT_Stream stream) {} 45 static void FPF_SkiaStream_Close(FXFT_Stream stream) {}
43 #ifdef __cplusplus 46 #ifdef __cplusplus
44 }; 47 };
45 #endif 48 #endif
46 49
47 namespace { 50 namespace {
48 51
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 CFPF_SkiaFont* pFont = new CFPF_SkiaFont; 354 CFPF_SkiaFont* pFont = new CFPF_SkiaFont;
352 if (pFont->InitFont(this, pBestFontDes, bsFamilyname, dwStyle, uCharset)) { 355 if (pFont->InitFont(this, pBestFontDes, bsFamilyname, dwStyle, uCharset)) {
353 m_FamilyFonts[dwHash] = pFont; 356 m_FamilyFonts[dwHash] = pFont;
354 return pFont->Retain(); 357 return pFont->Retain();
355 } 358 }
356 pFont->Release(); 359 pFont->Release();
357 } 360 }
358 return nullptr; 361 return nullptr;
359 } 362 }
360 363
361 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_SeekableReadStream* pFileRead, 364 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(
362 int32_t iFaceIndex) { 365 const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead,
366 int32_t iFaceIndex) {
363 if (!pFileRead) 367 if (!pFileRead)
364 return nullptr; 368 return nullptr;
365 if (pFileRead->GetSize() == 0) 369 if (pFileRead->GetSize() == 0)
366 return nullptr; 370 return nullptr;
367 if (iFaceIndex < 0) 371 if (iFaceIndex < 0)
368 return nullptr; 372 return nullptr;
369 FXFT_StreamRec streamRec; 373 FXFT_StreamRec streamRec;
370 FXSYS_memset(&streamRec, 0, sizeof(FXFT_StreamRec)); 374 FXSYS_memset(&streamRec, 0, sizeof(FXFT_StreamRec));
371 streamRec.size = pFileRead->GetSize(); 375 streamRec.size = pFileRead->GetSize();
372 streamRec.descriptor.pointer = pFileRead; 376 streamRec.descriptor.pointer = static_cast<void*>(pFileRead.Get());
373 streamRec.read = FPF_SkiaStream_Read; 377 streamRec.read = FPF_SkiaStream_Read;
374 streamRec.close = FPF_SkiaStream_Close; 378 streamRec.close = FPF_SkiaStream_Close;
375 FXFT_Open_Args args; 379 FXFT_Open_Args args;
376 args.flags = FT_OPEN_STREAM; 380 args.flags = FT_OPEN_STREAM;
377 args.stream = &streamRec; 381 args.stream = &streamRec;
378 FXFT_Face face; 382 FXFT_Face face;
379 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) 383 if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face))
380 return nullptr; 384 return nullptr;
381 FXFT_Set_Pixel_Sizes(face, 0, 64); 385 FXFT_Set_Pixel_Sizes(face, 0, 64);
382 return face; 386 return face;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 if ((uSerif > 1 && uSerif < 10) || uSerif > 13) 478 if ((uSerif > 1 && uSerif < 10) || uSerif > 13)
475 pFontDesc->m_dwStyle |= FXFONT_SERIF; 479 pFontDesc->m_dwStyle |= FXFONT_SERIF;
476 } 480 }
477 } 481 }
478 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) 482 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31)))
479 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; 483 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC;
480 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); 484 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2);
481 pFontDesc->m_iFaceIndex = face->face_index; 485 pFontDesc->m_iFaceIndex = face->face_index;
482 pFontDesc->m_iGlyphNum = face->num_glyphs; 486 pFontDesc->m_iGlyphNum = face->num_glyphs;
483 } 487 }
OLDNEW
« no previous file with comments | « core/fxge/android/cfpf_skiafontmgr.h ('k') | core/fxge/fx_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698