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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 65 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
66 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT | 66 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT |
67 ? FXDIB_Argb | 67 ? FXDIB_Argb |
68 : FXDIB_Rgb32); | 68 : FXDIB_Rgb32); |
69 #else | 69 #else |
70 return pDIB->Create( | 70 return pDIB->Create( |
71 width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); | 71 width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); |
72 #endif | 72 #endif |
73 } | 73 } |
74 FX_BOOL CFX_RenderDevice::SetClip_PathFill( | 74 FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, |
75 const CFX_PathData* pPathData, | 75 const CFX_Matrix* pObject2Device, |
76 const CFX_AffineMatrix* pObject2Device, | 76 int fill_mode) { |
77 int fill_mode) { | |
78 if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device, | 77 if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device, |
79 fill_mode)) { | 78 fill_mode)) { |
80 return FALSE; | 79 return FALSE; |
81 } | 80 } |
82 UpdateClipBox(); | 81 UpdateClipBox(); |
83 return TRUE; | 82 return TRUE; |
84 } | 83 } |
85 FX_BOOL CFX_RenderDevice::SetClip_PathStroke( | 84 FX_BOOL CFX_RenderDevice::SetClip_PathStroke( |
86 const CFX_PathData* pPathData, | 85 const CFX_PathData* pPathData, |
87 const CFX_AffineMatrix* pObject2Device, | 86 const CFX_Matrix* pObject2Device, |
88 const CFX_GraphStateData* pGraphState) { | 87 const CFX_GraphStateData* pGraphState) { |
89 if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device, | 88 if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device, |
90 pGraphState)) { | 89 pGraphState)) { |
91 return FALSE; | 90 return FALSE; |
92 } | 91 } |
93 UpdateClipBox(); | 92 UpdateClipBox(); |
94 return TRUE; | 93 return TRUE; |
95 } | 94 } |
96 FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT* pRect) { | 95 FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT* pRect) { |
97 CFX_PathData path; | 96 CFX_PathData path; |
98 path.AppendRect((FX_FLOAT)(pRect->left), (FX_FLOAT)(pRect->bottom), | 97 path.AppendRect((FX_FLOAT)(pRect->left), (FX_FLOAT)(pRect->bottom), |
99 (FX_FLOAT)(pRect->right), (FX_FLOAT)(pRect->top)); | 98 (FX_FLOAT)(pRect->right), (FX_FLOAT)(pRect->top)); |
100 if (!SetClip_PathFill(&path, NULL, FXFILL_WINDING)) { | 99 if (!SetClip_PathFill(&path, NULL, FXFILL_WINDING)) { |
101 return FALSE; | 100 return FALSE; |
102 } | 101 } |
103 UpdateClipBox(); | 102 UpdateClipBox(); |
104 return TRUE; | 103 return TRUE; |
105 } | 104 } |
106 void CFX_RenderDevice::UpdateClipBox() { | 105 void CFX_RenderDevice::UpdateClipBox() { |
107 if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) { | 106 if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) { |
108 return; | 107 return; |
109 } | 108 } |
110 m_ClipBox.left = 0; | 109 m_ClipBox.left = 0; |
111 m_ClipBox.top = 0; | 110 m_ClipBox.top = 0; |
112 m_ClipBox.right = m_Width; | 111 m_ClipBox.right = m_Width; |
113 m_ClipBox.bottom = m_Height; | 112 m_ClipBox.bottom = m_Height; |
114 } | 113 } |
115 FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, | 114 FX_BOOL CFX_RenderDevice::DrawPath(const CFX_PathData* pPathData, |
116 const CFX_AffineMatrix* pObject2Device, | 115 const CFX_Matrix* pObject2Device, |
117 const CFX_GraphStateData* pGraphState, | 116 const CFX_GraphStateData* pGraphState, |
118 FX_DWORD fill_color, | 117 FX_DWORD fill_color, |
119 FX_DWORD stroke_color, | 118 FX_DWORD stroke_color, |
120 int fill_mode, | 119 int fill_mode, |
121 int alpha_flag, | 120 int alpha_flag, |
122 void* pIccTransform, | 121 void* pIccTransform, |
123 int blend_type) { | 122 int blend_type) { |
124 uint8_t fill_alpha, stroke_alpha; | 123 uint8_t fill_alpha, stroke_alpha; |
125 if (FXGETFLAG_COLORTYPE(alpha_flag)) { | 124 if (FXGETFLAG_COLORTYPE(alpha_flag)) { |
126 fill_alpha = FXGETFLAG_ALPHA_FILL(alpha_flag); | 125 fill_alpha = FXGETFLAG_ALPHA_FILL(alpha_flag); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 graphState.m_LineWidth = 0.0f; | 204 graphState.m_LineWidth = 0.0f; |
206 FX_DWORD strokecolor = fill_color; | 205 FX_DWORD strokecolor = fill_color; |
207 if (bThin) { | 206 if (bThin) { |
208 if (FXGETFLAG_COLORTYPE(alpha_flag)) { | 207 if (FXGETFLAG_COLORTYPE(alpha_flag)) { |
209 FXSETFLAG_ALPHA_STROKE(alpha_flag, fill_alpha >> 2); | 208 FXSETFLAG_ALPHA_STROKE(alpha_flag, fill_alpha >> 2); |
210 } else { | 209 } else { |
211 strokecolor = | 210 strokecolor = |
212 (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); | 211 (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); |
213 } | 212 } |
214 } | 213 } |
215 CFX_AffineMatrix* pMatrix = NULL; | 214 CFX_Matrix* pMatrix = NULL; |
216 if (pObject2Device && !pObject2Device->IsIdentity()) { | 215 if (pObject2Device && !pObject2Device->IsIdentity()) { |
217 pMatrix = (CFX_AffineMatrix*)pObject2Device; | 216 pMatrix = (CFX_Matrix*)pObject2Device; |
218 } | 217 } |
219 int smooth_path = FX_ZEROAREA_FILL; | 218 int smooth_path = FX_ZEROAREA_FILL; |
220 if (fill_mode & FXFILL_NOPATHSMOOTH) { | 219 if (fill_mode & FXFILL_NOPATHSMOOTH) { |
221 smooth_path |= FXFILL_NOPATHSMOOTH; | 220 smooth_path |= FXFILL_NOPATHSMOOTH; |
222 } | 221 } |
223 m_pDeviceDriver->DrawPath(&newPath, pMatrix, &graphState, 0, strokecolor, | 222 m_pDeviceDriver->DrawPath(&newPath, pMatrix, &graphState, 0, strokecolor, |
224 smooth_path, alpha_flag, pIccTransform, | 223 smooth_path, alpha_flag, pIccTransform, |
225 blend_type); | 224 blend_type); |
226 } | 225 } |
227 } | 226 } |
(...skipping 25 matching lines...) Expand all Loading... |
253 bitmap.Clear(0); | 252 bitmap.Clear(0); |
254 Backdrop.Copy(&bitmap); | 253 Backdrop.Copy(&bitmap); |
255 } else { | 254 } else { |
256 if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top, NULL)) { | 255 if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top, NULL)) { |
257 return FALSE; | 256 return FALSE; |
258 } | 257 } |
259 Backdrop.Copy(&bitmap); | 258 Backdrop.Copy(&bitmap); |
260 } | 259 } |
261 CFX_FxgeDevice bitmap_device; | 260 CFX_FxgeDevice bitmap_device; |
262 bitmap_device.Attach(&bitmap, 0, FALSE, &Backdrop, TRUE); | 261 bitmap_device.Attach(&bitmap, 0, FALSE, &Backdrop, TRUE); |
263 CFX_AffineMatrix matrix; | 262 CFX_Matrix matrix; |
264 if (pObject2Device) { | 263 if (pObject2Device) { |
265 matrix = *pObject2Device; | 264 matrix = *pObject2Device; |
266 } | 265 } |
267 matrix.TranslateI(-rect.left, -rect.top); | 266 matrix.TranslateI(-rect.left, -rect.top); |
268 matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); | 267 matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); |
269 if (!bitmap_device.GetDeviceDriver()->DrawPath( | 268 if (!bitmap_device.GetDeviceDriver()->DrawPath( |
270 pPathData, &matrix, pGraphState, fill_color, stroke_color, | 269 pPathData, &matrix, pGraphState, fill_color, stroke_color, |
271 fill_mode, alpha_flag, pIccTransform, blend_type)) { | 270 fill_mode, alpha_flag, pIccTransform, blend_type)) { |
272 return FALSE; | 271 return FALSE; |
273 } | 272 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 355 } |
357 CFX_DIBitmap* CFX_RenderDevice::GetBackDrop() { | 356 CFX_DIBitmap* CFX_RenderDevice::GetBackDrop() { |
358 return m_pDeviceDriver->GetBackDrop(); | 357 return m_pDeviceDriver->GetBackDrop(); |
359 } | 358 } |
360 FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap, | 359 FX_BOOL CFX_RenderDevice::SetDIBits(const CFX_DIBSource* pBitmap, |
361 int left, | 360 int left, |
362 int top, | 361 int top, |
363 int blend_mode, | 362 int blend_mode, |
364 void* pIccTransform) { | 363 void* pIccTransform) { |
365 ASSERT(!pBitmap->IsAlphaMask()); | 364 ASSERT(!pBitmap->IsAlphaMask()); |
366 CFX_AffineMatrix ctm = GetCTM(); | 365 CFX_Matrix ctm = GetCTM(); |
367 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); | 366 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); |
368 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); | 367 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); |
369 FX_RECT dest_rect(left, top, | 368 FX_RECT dest_rect(left, top, |
370 FXSYS_round(left + pBitmap->GetWidth() / fScaleX), | 369 FXSYS_round(left + pBitmap->GetWidth() / fScaleX), |
371 FXSYS_round(top + pBitmap->GetHeight() / fScaleY)); | 370 FXSYS_round(top + pBitmap->GetHeight() / fScaleY)); |
372 dest_rect.Intersect(m_ClipBox); | 371 dest_rect.Intersect(m_ClipBox); |
373 if (dest_rect.IsEmpty()) { | 372 if (dest_rect.IsEmpty()) { |
374 return TRUE; | 373 return TRUE; |
375 } | 374 } |
376 FX_RECT src_rect(dest_rect.left - left, dest_rect.top - top, | 375 FX_RECT src_rect(dest_rect.left - left, dest_rect.top - top, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); | 450 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); |
452 FX_RECT clip_box = m_ClipBox; | 451 FX_RECT clip_box = m_ClipBox; |
453 clip_box.Intersect(dest_rect); | 452 clip_box.Intersect(dest_rect); |
454 return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, | 453 return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, |
455 dest_height, &clip_box, flags, | 454 dest_height, &clip_box, flags, |
456 alpha_flag, pIccTransform); | 455 alpha_flag, pIccTransform); |
457 } | 456 } |
458 FX_BOOL CFX_RenderDevice::StartDIBits(const CFX_DIBSource* pBitmap, | 457 FX_BOOL CFX_RenderDevice::StartDIBits(const CFX_DIBSource* pBitmap, |
459 int bitmap_alpha, | 458 int bitmap_alpha, |
460 FX_DWORD argb, | 459 FX_DWORD argb, |
461 const CFX_AffineMatrix* pMatrix, | 460 const CFX_Matrix* pMatrix, |
462 FX_DWORD flags, | 461 FX_DWORD flags, |
463 void*& handle, | 462 void*& handle, |
464 int alpha_flag, | 463 int alpha_flag, |
465 void* pIccTransform, | 464 void* pIccTransform, |
466 int blend_mode) { | 465 int blend_mode) { |
467 return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, | 466 return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, |
468 flags, handle, alpha_flag, pIccTransform, | 467 flags, handle, alpha_flag, pIccTransform, |
469 blend_mode); | 468 blend_mode); |
470 } | 469 } |
471 FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { | 470 FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { |
472 return m_pDeviceDriver->ContinueDIBits(handle, pPause); | 471 return m_pDeviceDriver->ContinueDIBits(handle, pPause); |
473 } | 472 } |
474 void CFX_RenderDevice::CancelDIBits(void* handle) { | 473 void CFX_RenderDevice::CancelDIBits(void* handle) { |
475 m_pDeviceDriver->CancelDIBits(handle); | 474 m_pDeviceDriver->CancelDIBits(handle); |
476 } | 475 } |
OLD | NEW |