OLD | NEW |
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 "core/include/fxge/fx_ge.h" | 7 #include "core/include/fxge/fx_ge.h" |
8 | 8 |
9 CFX_RenderDevice::CFX_RenderDevice() { | 9 CFX_RenderDevice::CFX_RenderDevice() { |
10 m_pDeviceDriver = NULL; | 10 m_pDeviceDriver = NULL; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 m_ClipBox.left = 0; | 107 m_ClipBox.left = 0; |
108 m_ClipBox.top = 0; | 108 m_ClipBox.top = 0; |
109 m_ClipBox.right = m_Width; | 109 m_ClipBox.right = m_Width; |
110 m_ClipBox.bottom = m_Height; | 110 m_ClipBox.bottom = m_Height; |
111 } | 111 } |
112 | 112 |
113 FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, | 113 FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, |
114 const CFX_Matrix* pObject2Device, | 114 const CFX_Matrix* pObject2Device, |
115 const CFX_GraphStateData* pGraphState, | 115 const CFX_GraphStateData* pGraphState, |
116 FX_DWORD fill_color, | 116 uint32_t fill_color, |
117 FX_DWORD stroke_color, | 117 uint32_t stroke_color, |
118 int fill_mode, | 118 int fill_mode, |
119 int alpha_flag, | 119 int alpha_flag, |
120 void* pIccTransform, | 120 void* pIccTransform, |
121 int blend_type) { | 121 int blend_type) { |
122 uint8_t fill_alpha, stroke_alpha; | 122 uint8_t fill_alpha, stroke_alpha; |
123 if (FXGETFLAG_COLORTYPE(alpha_flag)) { | 123 if (FXGETFLAG_COLORTYPE(alpha_flag)) { |
124 fill_alpha = FXGETFLAG_ALPHA_FILL(alpha_flag); | 124 fill_alpha = FXGETFLAG_ALPHA_FILL(alpha_flag); |
125 stroke_alpha = FXGETFLAG_ALPHA_STROKE(alpha_flag); | 125 stroke_alpha = FXGETFLAG_ALPHA_STROKE(alpha_flag); |
126 } else { | 126 } else { |
127 fill_alpha = FXARGB_A(fill_color); | 127 fill_alpha = FXARGB_A(fill_color); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 194 } |
195 } | 195 } |
196 if ((fill_mode & 3) && stroke_alpha == 0 && !(fill_mode & FX_FILL_STROKE) && | 196 if ((fill_mode & 3) && stroke_alpha == 0 && !(fill_mode & FX_FILL_STROKE) && |
197 !(fill_mode & FX_FILL_TEXT_MODE)) { | 197 !(fill_mode & FX_FILL_TEXT_MODE)) { |
198 CFX_PathData newPath; | 198 CFX_PathData newPath; |
199 FX_BOOL bThin = FALSE; | 199 FX_BOOL bThin = FALSE; |
200 if (pPathData->GetZeroAreaPath(newPath, (CFX_Matrix*)pObject2Device, bThin, | 200 if (pPathData->GetZeroAreaPath(newPath, (CFX_Matrix*)pObject2Device, bThin, |
201 m_pDeviceDriver->GetDriverType())) { | 201 m_pDeviceDriver->GetDriverType())) { |
202 CFX_GraphStateData graphState; | 202 CFX_GraphStateData graphState; |
203 graphState.m_LineWidth = 0.0f; | 203 graphState.m_LineWidth = 0.0f; |
204 FX_DWORD strokecolor = fill_color; | 204 uint32_t strokecolor = fill_color; |
205 if (bThin) { | 205 if (bThin) { |
206 if (FXGETFLAG_COLORTYPE(alpha_flag)) { | 206 if (FXGETFLAG_COLORTYPE(alpha_flag)) { |
207 FXSETFLAG_ALPHA_STROKE(alpha_flag, fill_alpha >> 2); | 207 FXSETFLAG_ALPHA_STROKE(alpha_flag, fill_alpha >> 2); |
208 } else { | 208 } else { |
209 strokecolor = | 209 strokecolor = |
210 (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); | 210 (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); |
211 } | 211 } |
212 } | 212 } |
213 CFX_Matrix* pMatrix = NULL; | 213 CFX_Matrix* pMatrix = NULL; |
214 if (pObject2Device && !pObject2Device->IsIdentity()) { | 214 if (pObject2Device && !pObject2Device->IsIdentity()) { |
(...skipping 22 matching lines...) Expand all Loading... |
237 return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, | 237 return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, |
238 fill_color, stroke_color, fill_mode, | 238 fill_color, stroke_color, fill_mode, |
239 alpha_flag, pIccTransform, blend_type); | 239 alpha_flag, pIccTransform, blend_type); |
240 } | 240 } |
241 | 241 |
242 // This can be removed once PDFium entirely relies on Skia | 242 // This can be removed once PDFium entirely relies on Skia |
243 FX_BOOL CFX_RenderDevice::DrawFillStrokePath( | 243 FX_BOOL CFX_RenderDevice::DrawFillStrokePath( |
244 const CFX_PathData* pPathData, | 244 const CFX_PathData* pPathData, |
245 const CFX_Matrix* pObject2Device, | 245 const CFX_Matrix* pObject2Device, |
246 const CFX_GraphStateData* pGraphState, | 246 const CFX_GraphStateData* pGraphState, |
247 FX_DWORD fill_color, | 247 uint32_t fill_color, |
248 FX_DWORD stroke_color, | 248 uint32_t stroke_color, |
249 int fill_mode, | 249 int fill_mode, |
250 int alpha_flag, | 250 int alpha_flag, |
251 void* pIccTransform, | 251 void* pIccTransform, |
252 int blend_type) { | 252 int blend_type) { |
253 if (!(m_RenderCaps & FXRC_GET_BITS)) { | 253 if (!(m_RenderCaps & FXRC_GET_BITS)) { |
254 return FALSE; | 254 return FALSE; |
255 } | 255 } |
256 CFX_FloatRect bbox; | 256 CFX_FloatRect bbox; |
257 if (pGraphState) { | 257 if (pGraphState) { |
258 bbox = pPathData->GetBoundingBox(pGraphState->m_LineWidth, | 258 bbox = pPathData->GetBoundingBox(pGraphState->m_LineWidth, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 return FALSE; | 295 return FALSE; |
296 } | 296 } |
297 FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX), | 297 FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX), |
298 FXSYS_round(rect.Height() * fScaleY)); | 298 FXSYS_round(rect.Height() * fScaleY)); |
299 return m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, rect.left, | 299 return m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, rect.left, |
300 rect.top, FXDIB_BLEND_NORMAL); | 300 rect.top, FXDIB_BLEND_NORMAL); |
301 } | 301 } |
302 | 302 |
303 FX_BOOL CFX_RenderDevice::SetPixel(int x, | 303 FX_BOOL CFX_RenderDevice::SetPixel(int x, |
304 int y, | 304 int y, |
305 FX_DWORD color, | 305 uint32_t color, |
306 int alpha_flag, | 306 int alpha_flag, |
307 void* pIccTransform) { | 307 void* pIccTransform) { |
308 if (m_pDeviceDriver->SetPixel(x, y, color, alpha_flag, pIccTransform)) { | 308 if (m_pDeviceDriver->SetPixel(x, y, color, alpha_flag, pIccTransform)) { |
309 return TRUE; | 309 return TRUE; |
310 } | 310 } |
311 FX_RECT rect(x, y, x + 1, y + 1); | 311 FX_RECT rect(x, y, x + 1, y + 1); |
312 return FillRect(&rect, color, alpha_flag, pIccTransform); | 312 return FillRect(&rect, color, alpha_flag, pIccTransform); |
313 } | 313 } |
314 FX_BOOL CFX_RenderDevice::FillRect(const FX_RECT* pRect, | 314 FX_BOOL CFX_RenderDevice::FillRect(const FX_RECT* pRect, |
315 FX_DWORD fill_color, | 315 uint32_t fill_color, |
316 int alpha_flag, | 316 int alpha_flag, |
317 void* pIccTransform, | 317 void* pIccTransform, |
318 int blend_type) { | 318 int blend_type) { |
319 if (m_pDeviceDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransform, | 319 if (m_pDeviceDriver->FillRect(pRect, fill_color, alpha_flag, pIccTransform, |
320 blend_type)) { | 320 blend_type)) { |
321 return TRUE; | 321 return TRUE; |
322 } | 322 } |
323 if (!(m_RenderCaps & FXRC_GET_BITS)) { | 323 if (!(m_RenderCaps & FXRC_GET_BITS)) { |
324 return FALSE; | 324 return FALSE; |
325 } | 325 } |
(...skipping 10 matching lines...) Expand all Loading... |
336 } | 336 } |
337 FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); | 337 FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); |
338 m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top, | 338 m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top, |
339 FXDIB_BLEND_NORMAL); | 339 FXDIB_BLEND_NORMAL); |
340 return TRUE; | 340 return TRUE; |
341 } | 341 } |
342 FX_BOOL CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, | 342 FX_BOOL CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, |
343 FX_FLOAT y1, | 343 FX_FLOAT y1, |
344 FX_FLOAT x2, | 344 FX_FLOAT x2, |
345 FX_FLOAT y2, | 345 FX_FLOAT y2, |
346 FX_DWORD color, | 346 uint32_t color, |
347 int fill_mode, | 347 int fill_mode, |
348 int alpha_flag, | 348 int alpha_flag, |
349 void* pIccTransform, | 349 void* pIccTransform, |
350 int blend_type) { | 350 int blend_type) { |
351 if (((m_RenderCaps & FXRC_ALPHA_PATH) && | 351 if (((m_RenderCaps & FXRC_ALPHA_PATH) && |
352 (FXGETFLAG_COLORTYPE(alpha_flag) && | 352 (FXGETFLAG_COLORTYPE(alpha_flag) && |
353 FXGETFLAG_ALPHA_FILL(alpha_flag) == 0xff)) || | 353 FXGETFLAG_ALPHA_FILL(alpha_flag) == 0xff)) || |
354 color >= 0xff000000) { | 354 color >= 0xff000000) { |
355 if (m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, alpha_flag, | 355 if (m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, alpha_flag, |
356 pIccTransform, blend_type)) { | 356 pIccTransform, blend_type)) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } | 429 } |
430 return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, | 430 return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, |
431 dest_rect.top, blend_mode, 0, | 431 dest_rect.top, blend_mode, 0, |
432 pIccTransform); | 432 pIccTransform); |
433 } | 433 } |
434 FX_BOOL CFX_RenderDevice::StretchDIBits(const CFX_DIBSource* pBitmap, | 434 FX_BOOL CFX_RenderDevice::StretchDIBits(const CFX_DIBSource* pBitmap, |
435 int left, | 435 int left, |
436 int top, | 436 int top, |
437 int dest_width, | 437 int dest_width, |
438 int dest_height, | 438 int dest_height, |
439 FX_DWORD flags, | 439 uint32_t flags, |
440 void* pIccTransform, | 440 void* pIccTransform, |
441 int blend_mode) { | 441 int blend_mode) { |
442 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); | 442 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); |
443 FX_RECT clip_box = m_ClipBox; | 443 FX_RECT clip_box = m_ClipBox; |
444 clip_box.Intersect(dest_rect); | 444 clip_box.Intersect(dest_rect); |
445 if (clip_box.IsEmpty()) { | 445 if (clip_box.IsEmpty()) { |
446 return TRUE; | 446 return TRUE; |
447 } | 447 } |
448 return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width, | 448 return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width, |
449 dest_height, &clip_box, flags, 0, | 449 dest_height, &clip_box, flags, 0, |
450 pIccTransform, blend_mode); | 450 pIccTransform, blend_mode); |
451 } | 451 } |
452 FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, | 452 FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, |
453 int left, | 453 int left, |
454 int top, | 454 int top, |
455 FX_DWORD argb, | 455 uint32_t argb, |
456 int alpha_flag, | 456 int alpha_flag, |
457 void* pIccTransform) { | 457 void* pIccTransform) { |
458 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); | 458 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); |
459 return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, | 459 return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, |
460 FXDIB_BLEND_NORMAL, alpha_flag, | 460 FXDIB_BLEND_NORMAL, alpha_flag, |
461 pIccTransform); | 461 pIccTransform); |
462 } | 462 } |
463 FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, | 463 FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, |
464 int left, | 464 int left, |
465 int top, | 465 int top, |
466 int dest_width, | 466 int dest_width, |
467 int dest_height, | 467 int dest_height, |
468 FX_DWORD argb, | 468 uint32_t argb, |
469 FX_DWORD flags, | 469 uint32_t flags, |
470 int alpha_flag, | 470 int alpha_flag, |
471 void* pIccTransform) { | 471 void* pIccTransform) { |
472 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); | 472 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); |
473 FX_RECT clip_box = m_ClipBox; | 473 FX_RECT clip_box = m_ClipBox; |
474 clip_box.Intersect(dest_rect); | 474 clip_box.Intersect(dest_rect); |
475 return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, | 475 return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, |
476 dest_height, &clip_box, flags, | 476 dest_height, &clip_box, flags, |
477 alpha_flag, pIccTransform); | 477 alpha_flag, pIccTransform); |
478 } | 478 } |
479 FX_BOOL CFX_RenderDevice::StartDIBits(const CFX_DIBSource* pBitmap, | 479 FX_BOOL CFX_RenderDevice::StartDIBits(const CFX_DIBSource* pBitmap, |
480 int bitmap_alpha, | 480 int bitmap_alpha, |
481 FX_DWORD argb, | 481 uint32_t argb, |
482 const CFX_Matrix* pMatrix, | 482 const CFX_Matrix* pMatrix, |
483 FX_DWORD flags, | 483 uint32_t flags, |
484 void*& handle, | 484 void*& handle, |
485 int alpha_flag, | 485 int alpha_flag, |
486 void* pIccTransform, | 486 void* pIccTransform, |
487 int blend_mode) { | 487 int blend_mode) { |
488 return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, | 488 return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, |
489 flags, handle, alpha_flag, pIccTransform, | 489 flags, handle, alpha_flag, pIccTransform, |
490 blend_mode); | 490 blend_mode); |
491 } | 491 } |
492 FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { | 492 FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { |
493 return m_pDeviceDriver->ContinueDIBits(handle, pPause); | 493 return m_pDeviceDriver->ContinueDIBits(handle, pPause); |
494 } | 494 } |
495 void CFX_RenderDevice::CancelDIBits(void* handle) { | 495 void CFX_RenderDevice::CancelDIBits(void* handle) { |
496 m_pDeviceDriver->CancelDIBits(handle); | 496 m_pDeviceDriver->CancelDIBits(handle); |
497 } | 497 } |
OLD | NEW |