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

Side by Side Diff: core/src/fxge/win32/fx_win32_dwrite.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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 | « core/src/fxge/win32/fx_win32_dib.cpp ('k') | core/src/fxge/win32/fx_win32_gdipext.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 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 "../../../include/fxge/fx_ge.h" 7 #include "../../../include/fxge/fx_ge.h"
8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ 8 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
9 #include "../../../include/fxge/fx_ge_win32.h" 9 #include "../../../include/fxge/fx_ge_win32.h"
10 #include "dwrite_int.h" 10 #include "dwrite_int.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 CDWriteExt::~CDWriteExt() 127 CDWriteExt::~CDWriteExt()
128 { 128 {
129 Unload(); 129 Unload();
130 } 130 }
131 LPVOID CDWriteExt::DwCreateFontFaceFromStream(uint8_t* pData, FX_DWORD size, in t simulation_style) 131 LPVOID CDWriteExt::DwCreateFontFaceFromStream(uint8_t* pData, FX_DWORD size, in t simulation_style)
132 { 132 {
133 IDWriteFactory* pDwFactory = (IDWriteFactory*)m_pDWriteFactory; 133 IDWriteFactory* pDwFactory = (IDWriteFactory*)m_pDWriteFactory;
134 IDWriteFontFile* pDwFontFile = NULL; 134 IDWriteFontFile* pDwFontFile = NULL;
135 IDWriteFontFace* pDwFontFace = NULL; 135 IDWriteFontFace* pDwFontFace = NULL;
136 BOOL isSupportedFontType = FALSE; 136 BOOL isSupportedFontType = false;
137 DWRITE_FONT_FILE_TYPE fontFileType; 137 DWRITE_FONT_FILE_TYPE fontFileType;
138 DWRITE_FONT_FACE_TYPE fontFaceType; 138 DWRITE_FONT_FACE_TYPE fontFaceType;
139 UINT32 numberOfFaces; 139 UINT32 numberOfFaces;
140 DWRITE_FONT_SIMULATIONS fontStyle = (DWRITE_FONT_SIMULATIONS)(simulation_sty le & 3); 140 DWRITE_FONT_SIMULATIONS fontStyle = (DWRITE_FONT_SIMULATIONS)(simulation_sty le & 3);
141 HRESULT hr = S_OK; 141 HRESULT hr = S_OK;
142 hr = pDwFactory->CreateCustomFontFileReference( 142 hr = pDwFactory->CreateCustomFontFileReference(
143 (void const*)pData, 143 (void const*)pData,
144 (UINT32)size, 144 (UINT32)size,
145 CDwFontFileLoader::GetLoader(), 145 CDwFontFileLoader::GetLoader(),
146 &pDwFontFile 146 &pDwFontFile
(...skipping 20 matching lines...) Expand all
167 ); 167 );
168 if (FAILED(hr)) { 168 if (FAILED(hr)) {
169 goto failed; 169 goto failed;
170 } 170 }
171 SafeRelease(&pDwFontFile); 171 SafeRelease(&pDwFontFile);
172 return pDwFontFace; 172 return pDwFontFace;
173 failed: 173 failed:
174 SafeRelease(&pDwFontFile); 174 SafeRelease(&pDwFontFile);
175 return NULL; 175 return NULL;
176 } 176 }
177 FX_BOOL CDWriteExt::DwCreateRenderingTarget(CFX_DIBitmap* pBitmap, void** render Target) 177 bool CDWriteExt::DwCreateRenderingTarget(CFX_DIBitmap* pBitmap, void** renderTar get)
178 { 178 {
179 if (pBitmap->GetFormat() > FXDIB_Argb) { 179 if (pBitmap->GetFormat() > FXDIB_Argb) {
180 return FALSE; 180 return false;
181 } 181 }
182 IDWriteFactory* pDwFactory = (IDWriteFactory*)m_pDWriteFactory; 182 IDWriteFactory* pDwFactory = (IDWriteFactory*)m_pDWriteFactory;
183 IDWriteGdiInterop* pGdiInterop = NULL; 183 IDWriteGdiInterop* pGdiInterop = NULL;
184 IDWriteBitmapRenderTarget* pBitmapRenderTarget = NULL; 184 IDWriteBitmapRenderTarget* pBitmapRenderTarget = NULL;
185 IDWriteRenderingParams* pRenderingParams = NULL; 185 IDWriteRenderingParams* pRenderingParams = NULL;
186 HRESULT hr = S_OK; 186 HRESULT hr = S_OK;
187 hr = pDwFactory->GetGdiInterop(&pGdiInterop); 187 hr = pDwFactory->GetGdiInterop(&pGdiInterop);
188 if (FAILED(hr)) { 188 if (FAILED(hr)) {
189 goto failed; 189 goto failed;
190 } 190 }
(...skipping 14 matching lines...) Expand all
205 goto failed; 205 goto failed;
206 } 206 }
207 hr = pBitmapRenderTarget->SetPixelsPerDip(1.0f); 207 hr = pBitmapRenderTarget->SetPixelsPerDip(1.0f);
208 if (FAILED(hr)) { 208 if (FAILED(hr)) {
209 goto failed; 209 goto failed;
210 } 210 }
211 *(CDwGdiTextRenderer**)renderTarget = new CDwGdiTextRenderer(pBitmap, pBitma pRenderTarget, pRenderingParams); 211 *(CDwGdiTextRenderer**)renderTarget = new CDwGdiTextRenderer(pBitmap, pBitma pRenderTarget, pRenderingParams);
212 SafeRelease(&pGdiInterop); 212 SafeRelease(&pGdiInterop);
213 SafeRelease(&pBitmapRenderTarget); 213 SafeRelease(&pBitmapRenderTarget);
214 SafeRelease(&pRenderingParams); 214 SafeRelease(&pRenderingParams);
215 return TRUE; 215 return true;
216 failed: 216 failed:
217 SafeRelease(&pGdiInterop); 217 SafeRelease(&pGdiInterop);
218 SafeRelease(&pBitmapRenderTarget); 218 SafeRelease(&pBitmapRenderTarget);
219 SafeRelease(&pRenderingParams); 219 SafeRelease(&pRenderingParams);
220 return FALSE; 220 return false;
221 } 221 }
222 FX_BOOL»CDWriteExt::DwRendingString(void* renderTarget, CFX_ClipRgn* pClipRgn, F X_RECT& stringRect, CFX_AffineMatrix* pMatrix, 222 bool» CDWriteExt::DwRendingString(void* renderTarget, CFX_ClipRgn* pClipRgn, F X_RECT& stringRect, CFX_AffineMatrix* pMatrix,
223 void *font, FX_FLOAT font_size, FX_ARGB text _color, 223 void *font, FX_FLOAT font_size, FX_ARGB text _color,
224 int glyph_count, unsigned short* glyph_indic es, 224 int glyph_count, unsigned short* glyph_indic es,
225 FX_FLOAT baselineOriginX, FX_FLOAT baselineO riginY, 225 FX_FLOAT baselineOriginX, FX_FLOAT baselineO riginY,
226 void* glyph_offsets, 226 void* glyph_offsets,
227 FX_FLOAT* glyph_advances) 227 FX_FLOAT* glyph_advances)
228 { 228 {
229 if (renderTarget == NULL) { 229 if (renderTarget == NULL) {
230 return TRUE; 230 return true;
231 } 231 }
232 CDwGdiTextRenderer* pTextRenderer = (CDwGdiTextRenderer*)renderTarget; 232 CDwGdiTextRenderer* pTextRenderer = (CDwGdiTextRenderer*)renderTarget;
233 DWRITE_MATRIX transform; 233 DWRITE_MATRIX transform;
234 DWRITE_GLYPH_RUN glyphRun; 234 DWRITE_GLYPH_RUN glyphRun;
235 HRESULT hr = S_OK; 235 HRESULT hr = S_OK;
236 if (pMatrix) { 236 if (pMatrix) {
237 transform.m11 = pMatrix->a; 237 transform.m11 = pMatrix->a;
238 transform.m12 = pMatrix->b; 238 transform.m12 = pMatrix->b;
239 transform.m21 = pMatrix->c; 239 transform.m21 = pMatrix->c;
240 transform.m22 = pMatrix->d; 240 transform.m22 = pMatrix->d;
241 transform.dx = pMatrix->e; 241 transform.dx = pMatrix->e;
242 transform.dy = pMatrix->f; 242 transform.dy = pMatrix->f;
243 } 243 }
244 glyphRun.fontFace = (IDWriteFontFace*)font; 244 glyphRun.fontFace = (IDWriteFontFace*)font;
245 glyphRun.fontEmSize = font_size; 245 glyphRun.fontEmSize = font_size;
246 glyphRun.glyphCount = glyph_count; 246 glyphRun.glyphCount = glyph_count;
247 glyphRun.glyphIndices = glyph_indices; 247 glyphRun.glyphIndices = glyph_indices;
248 glyphRun.glyphAdvances = glyph_advances; 248 glyphRun.glyphAdvances = glyph_advances;
249 glyphRun.glyphOffsets = (DWRITE_GLYPH_OFFSET*)glyph_offsets; 249 glyphRun.glyphOffsets = (DWRITE_GLYPH_OFFSET*)glyph_offsets;
250 glyphRun.isSideways = FALSE; 250 glyphRun.isSideways = false;
251 glyphRun.bidiLevel = 0; 251 glyphRun.bidiLevel = 0;
252 hr = pTextRenderer->DrawGlyphRun( 252 hr = pTextRenderer->DrawGlyphRun(
253 stringRect, 253 stringRect,
254 pClipRgn, 254 pClipRgn,
255 pMatrix ? &transform : NULL, 255 pMatrix ? &transform : NULL,
256 baselineOriginX, baselineOriginY, 256 baselineOriginX, baselineOriginY,
257 DWRITE_MEASURING_MODE_NATURAL, 257 DWRITE_MEASURING_MODE_NATURAL,
258 &glyphRun, 258 &glyphRun,
259 RGB(FXARGB_R(text_color), FXARGB_G(text_color), FXARGB_B(text_color )) 259 RGB(FXARGB_R(text_color), FXARGB_G(text_color), FXARGB_B(text_color ))
260 ); 260 );
261 return SUCCEEDED(hr) ? TRUE : FALSE; 261 return SUCCEEDED(hr) ? true : false;
262 } 262 }
263 void CDWriteExt::DwDeleteRenderingTarget(void* renderTarget) 263 void CDWriteExt::DwDeleteRenderingTarget(void* renderTarget)
264 { 264 {
265 delete (CDwGdiTextRenderer*)renderTarget; 265 delete (CDwGdiTextRenderer*)renderTarget;
266 } 266 }
267 void CDWriteExt::DwDeleteFont(void* pFont) 267 void CDWriteExt::DwDeleteFont(void* pFont)
268 { 268 {
269 if (pFont) { 269 if (pFont) {
270 SafeRelease((IDWriteFontFace**)&pFont); 270 SafeRelease((IDWriteFontFace**)&pFont);
271 } 271 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 text_bbox.Height(), 462 text_bbox.Height(),
463 &dib, 463 &dib,
464 text_bbox.left, 464 text_bbox.left,
465 text_bbox.top, 465 text_bbox.top,
466 FXDIB_BLEND_NORMAL, 466 FXDIB_BLEND_NORMAL,
467 pClipRgn 467 pClipRgn
468 ); 468 );
469 return hr; 469 return hr;
470 } 470 }
471 #endif 471 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/win32/fx_win32_dib.cpp ('k') | core/src/fxge/win32/fx_win32_gdipext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698