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 "../../../include/fpdfapi/fpdf_render.h" | 7 #include "../../../include/fpdfapi/fpdf_render.h" |
8 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 8 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
9 #include "../../../include/fxge/fx_ge.h" | 9 #include "../../../include/fxge/fx_ge.h" |
10 #include "../fpdf_page/pageint.h" | 10 #include "../fpdf_page/pageint.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 pCS->GetRGB(pResults, R, G, B); | 70 pCS->GetRGB(pResults, R, G, B); |
71 rgb_array[i] = FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), FXS
YS_round(G * 255), FXSYS_round(B * 255))); | 71 rgb_array[i] = FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), FXS
YS_round(G * 255), FXSYS_round(B * 255))); |
72 } | 72 } |
73 int pitch = pBitmap->GetPitch(); | 73 int pitch = pBitmap->GetPitch(); |
74 for (int row = 0; row < height; row ++) { | 74 for (int row = 0; row < height; row ++) { |
75 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); | 75 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); |
76 for (int column = 0; column < width; column ++) { | 76 for (int column = 0; column < width; column ++) { |
77 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; | 77 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; |
78 matrix.Transform(x, y); | 78 matrix.Transform(x, y); |
79 FX_FLOAT scale = FXSYS_Div(FXSYS_Mul(x - start_x, x_span) + FXSYS_Mu
l(y - start_y, y_span), axis_len_square); | 79 FX_FLOAT scale = FXSYS_Div(FXSYS_Mul(x - start_x, x_span) + FXSYS_Mu
l(y - start_y, y_span), axis_len_square); |
80 int index = (FX_INT32)(scale * (SHADING_STEPS - 1)); | 80 int index = (int32_t)(scale * (SHADING_STEPS - 1)); |
81 if (index < 0) { | 81 if (index < 0) { |
82 if (!bStartExtend) { | 82 if (!bStartExtend) { |
83 continue; | 83 continue; |
84 } | 84 } |
85 index = 0; | 85 index = 0; |
86 } else if (index >= SHADING_STEPS) { | 86 } else if (index >= SHADING_STEPS) { |
87 if (!bEndExtend) { | 87 if (!bEndExtend) { |
88 continue; | 88 continue; |
89 } | 89 } |
90 index = SHADING_STEPS - 1; | 90 index = SHADING_STEPS - 1; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 if (s2 <= 1.0f || bEndExtend) { | 198 if (s2 <= 1.0f || bEndExtend) { |
199 s = s2; | 199 s = s2; |
200 } else { | 200 } else { |
201 s = s1; | 201 s = s1; |
202 } | 202 } |
203 } | 203 } |
204 if ((start_r + s * (end_r - start_r)) < 0) { | 204 if ((start_r + s * (end_r - start_r)) < 0) { |
205 continue; | 205 continue; |
206 } | 206 } |
207 } | 207 } |
208 int index = (FX_INT32)(s * (SHADING_STEPS - 1)); | 208 int index = (int32_t)(s * (SHADING_STEPS - 1)); |
209 if (index < 0) { | 209 if (index < 0) { |
210 if (!bStartExtend) { | 210 if (!bStartExtend) { |
211 continue; | 211 continue; |
212 } | 212 } |
213 index = 0; | 213 index = 0; |
214 } | 214 } |
215 if (index >= SHADING_STEPS) { | 215 if (index >= SHADING_STEPS) { |
216 if (!bEndExtend) { | 216 if (!bEndExtend) { |
217 continue; | 217 continue; |
218 } | 218 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 for (int j = 0; j < nFuncs; j ++) { | 270 for (int j = 0; j < nFuncs; j ++) { |
271 if (pFuncs[j]) { | 271 if (pFuncs[j]) { |
272 int nresults; | 272 int nresults; |
273 if (pFuncs[j]->Call(input, 2, pResults + offset, nresults))
{ | 273 if (pFuncs[j]->Call(input, 2, pResults + offset, nresults))
{ |
274 offset += nresults; | 274 offset += nresults; |
275 } | 275 } |
276 } | 276 } |
277 } | 277 } |
278 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; | 278 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; |
279 pCS->GetRGB(pResults, R, G, B); | 279 pCS->GetRGB(pResults, R, G, B); |
280 dib_buf[column] = FXARGB_TODIB(FXARGB_MAKE(alpha, (FX_INT32)(R * 255
), (FX_INT32)(G * 255), (FX_INT32)(B * 255))); | 280 dib_buf[column] = FXARGB_TODIB(FXARGB_MAKE(alpha, (int32_t)(R * 255)
, (int32_t)(G * 255), (int32_t)(B * 255))); |
281 } | 281 } |
282 } | 282 } |
283 } | 283 } |
284 FX_BOOL _GetScanlineIntersect(int y, FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_F
LOAT y2, FX_FLOAT& x) | 284 FX_BOOL _GetScanlineIntersect(int y, FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_F
LOAT y2, FX_FLOAT& x) |
285 { | 285 { |
286 if (y1 == y2) { | 286 if (y1 == y2) { |
287 return FALSE; | 287 return FALSE; |
288 } | 288 } |
289 if (y1 < y2) { | 289 if (y1 < y2) { |
290 if (y < y1 || y > y2) { | 290 if (y < y1 || y > y2) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 FX_FLOAT r_unit = (r[end_index] - r[start_index]) / (max_x - min_x); | 361 FX_FLOAT r_unit = (r[end_index] - r[start_index]) / (max_x - min_x); |
362 FX_FLOAT g_unit = (g[end_index] - g[start_index]) / (max_x - min_x); | 362 FX_FLOAT g_unit = (g[end_index] - g[start_index]) / (max_x - min_x); |
363 FX_FLOAT b_unit = (b[end_index] - b[start_index]) / (max_x - min_x); | 363 FX_FLOAT b_unit = (b[end_index] - b[start_index]) / (max_x - min_x); |
364 FX_FLOAT R = r[start_index] + (start_x - min_x) * r_unit; | 364 FX_FLOAT R = r[start_index] + (start_x - min_x) * r_unit; |
365 FX_FLOAT G = g[start_index] + (start_x - min_x) * g_unit; | 365 FX_FLOAT G = g[start_index] + (start_x - min_x) * g_unit; |
366 FX_FLOAT B = b[start_index] + (start_x - min_x) * b_unit; | 366 FX_FLOAT B = b[start_index] + (start_x - min_x) * b_unit; |
367 for (int x = start_x; x < end_x; x ++) { | 367 for (int x = start_x; x < end_x; x ++) { |
368 R += r_unit; | 368 R += r_unit; |
369 G += g_unit; | 369 G += g_unit; |
370 B += b_unit; | 370 B += b_unit; |
371 FXARGB_SETDIB(dib_buf, FXARGB_MAKE(alpha, (FX_INT32)(R * 255), (FX_I
NT32)(G * 255), (FX_INT32)(B * 255))); | 371 FXARGB_SETDIB(dib_buf, FXARGB_MAKE(alpha, (int32_t)(R * 255), (int32
_t)(G * 255), (int32_t)(B * 255))); |
372 dib_buf += 4; | 372 dib_buf += 4; |
373 } | 373 } |
374 } | 374 } |
375 } | 375 } |
376 static void _DrawFreeGouraudShading(CFX_DIBitmap* pBitmap, CFX_AffineMatrix* pOb
ject2Bitmap, | 376 static void _DrawFreeGouraudShading(CFX_DIBitmap* pBitmap, CFX_AffineMatrix* pOb
ject2Bitmap, |
377 CPDF_Stream* pShadingStream, CPDF_Function**
pFuncs, int nFuncs, | 377 CPDF_Stream* pShadingStream, CPDF_Function**
pFuncs, int nFuncs, |
378 CPDF_ColorSpace* pCS, int alpha) | 378 CPDF_ColorSpace* pCS, int alpha) |
379 { | 379 { |
380 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); | 380 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); |
381 if (pShadingStream->GetType() != PDFOBJ_STREAM) { | 381 if (pShadingStream->GetType() != PDFOBJ_STREAM) { |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 tempColors[1] = patch.patch_colors[(flag + 1) % 4]; | 739 tempColors[1] = patch.patch_colors[(flag + 1) % 4]; |
740 FXSYS_memcpy32(patch.patch_colors, tempColors, sizeof(Coon_Color) *
2); | 740 FXSYS_memcpy32(patch.patch_colors, tempColors, sizeof(Coon_Color) *
2); |
741 } | 741 } |
742 for (i = iStartPoint; i < point_count; i ++) { | 742 for (i = iStartPoint; i < point_count; i ++) { |
743 stream.GetCoords(coords[i].x, coords[i].y); | 743 stream.GetCoords(coords[i].x, coords[i].y); |
744 pObject2Bitmap->Transform(coords[i].x, coords[i].y); | 744 pObject2Bitmap->Transform(coords[i].x, coords[i].y); |
745 } | 745 } |
746 for (i = iStartColor; i < 4; i ++) { | 746 for (i = iStartColor; i < 4; i ++) { |
747 FX_FLOAT r=0.0f, g=0.0f, b=0.0f; | 747 FX_FLOAT r=0.0f, g=0.0f, b=0.0f; |
748 stream.GetColor(r, g, b); | 748 stream.GetColor(r, g, b); |
749 patch.patch_colors[i].comp[0] = (FX_INT32)(r * 255); | 749 patch.patch_colors[i].comp[0] = (int32_t)(r * 255); |
750 patch.patch_colors[i].comp[1] = (FX_INT32)(g * 255); | 750 patch.patch_colors[i].comp[1] = (int32_t)(g * 255); |
751 patch.patch_colors[i].comp[2] = (FX_INT32)(b * 255); | 751 patch.patch_colors[i].comp[2] = (int32_t)(b * 255); |
752 } | 752 } |
753 CFX_FloatRect bbox = CFX_FloatRect::GetBBox(coords, point_count); | 753 CFX_FloatRect bbox = CFX_FloatRect::GetBBox(coords, point_count); |
754 if (bbox.right <= 0 || bbox.left >= (FX_FLOAT)pBitmap->GetWidth() || bbo
x.top <= 0 || | 754 if (bbox.right <= 0 || bbox.left >= (FX_FLOAT)pBitmap->GetWidth() || bbo
x.top <= 0 || |
755 bbox.bottom >= (FX_FLOAT)pBitmap->GetHeight()) { | 755 bbox.bottom >= (FX_FLOAT)pBitmap->GetHeight()) { |
756 continue; | 756 continue; |
757 } | 757 } |
758 Coon_Bezier C1, C2, D1, D2; | 758 Coon_Bezier C1, C2, D1, D2; |
759 C1.FromPoints(coords[0].x, coords[0].y, coords[11].x, coords[11].y, coor
ds[10].x, coords[10].y, | 759 C1.FromPoints(coords[0].x, coords[0].y, coords[11].x, coords[11].y, coor
ds[10].x, coords[10].y, |
760 coords[9].x, coords[9].y); | 760 coords[9].x, coords[9].y); |
761 C2.FromPoints(coords[3].x, coords[3].y, coords[4].x, coords[4].y, coords
[5].x, coords[5].y, | 761 C2.FromPoints(coords[3].x, coords[3].y, coords[4].x, coords[4].y, coords
[5].x, coords[5].y, |
(...skipping 18 matching lines...) Expand all Loading... |
780 FX_ARGB background = 0; | 780 FX_ARGB background = 0; |
781 if (!pPattern->m_bShadingObj && pPattern->m_pShadingObj->GetDict()->KeyExist
(FX_BSTRC("Background"))) { | 781 if (!pPattern->m_bShadingObj && pPattern->m_pShadingObj->GetDict()->KeyExist
(FX_BSTRC("Background"))) { |
782 CPDF_Array* pBackColor = pPattern->m_pShadingObj->GetDict()->GetArray(FX
_BSTRC("Background")); | 782 CPDF_Array* pBackColor = pPattern->m_pShadingObj->GetDict()->GetArray(FX
_BSTRC("Background")); |
783 if (pBackColor && pBackColor->GetCount() >= (FX_DWORD)pColorSpace->Count
Components()) { | 783 if (pBackColor && pBackColor->GetCount() >= (FX_DWORD)pColorSpace->Count
Components()) { |
784 CFX_FixedBufGrow<FX_FLOAT, 16> comps(pColorSpace->CountComponents())
; | 784 CFX_FixedBufGrow<FX_FLOAT, 16> comps(pColorSpace->CountComponents())
; |
785 for (int i = 0; i < pColorSpace->CountComponents(); i ++) { | 785 for (int i = 0; i < pColorSpace->CountComponents(); i ++) { |
786 comps[i] = pBackColor->GetNumber(i); | 786 comps[i] = pBackColor->GetNumber(i); |
787 } | 787 } |
788 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; | 788 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; |
789 pColorSpace->GetRGB(comps, R, G, B); | 789 pColorSpace->GetRGB(comps, R, G, B); |
790 background = ArgbEncode(255, (FX_INT32)(R * 255), (FX_INT32)(G * 255
), (FX_INT32)(B * 255)); | 790 background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255),
(int32_t)(B * 255)); |
791 } | 791 } |
792 } | 792 } |
793 if (pDict->KeyExist(FX_BSTRC("BBox"))) { | 793 if (pDict->KeyExist(FX_BSTRC("BBox"))) { |
794 CFX_FloatRect rect = pDict->GetRect(FX_BSTRC("BBox")); | 794 CFX_FloatRect rect = pDict->GetRect(FX_BSTRC("BBox")); |
795 rect.Transform(pMatrix); | 795 rect.Transform(pMatrix); |
796 clip_rect.Intersect(rect.GetOutterRect()); | 796 clip_rect.Intersect(rect.GetOutterRect()); |
797 } | 797 } |
798 CPDF_DeviceBuffer buffer; | 798 CPDF_DeviceBuffer buffer; |
799 buffer.Initialize(m_pContext, m_pDevice, &clip_rect, m_pCurObj, 150); | 799 buffer.Initialize(m_pContext, m_pDevice, &clip_rect, m_pCurObj, 150); |
800 CFX_AffineMatrix FinalMatrix = *pMatrix; | 800 CFX_AffineMatrix FinalMatrix = *pMatrix; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 return; | 932 return; |
933 } | 933 } |
934 FX_RECT clip_box = m_pDevice->GetClipBox(); | 934 FX_RECT clip_box = m_pDevice->GetClipBox(); |
935 if (clip_box.IsEmpty()) { | 935 if (clip_box.IsEmpty()) { |
936 m_pDevice->RestoreState(); | 936 m_pDevice->RestoreState(); |
937 return; | 937 return; |
938 } | 938 } |
939 CFX_Matrix dCTM = m_pDevice->GetCTM(); | 939 CFX_Matrix dCTM = m_pDevice->GetCTM(); |
940 FX_FLOAT sa = FXSYS_fabs(dCTM.a); | 940 FX_FLOAT sa = FXSYS_fabs(dCTM.a); |
941 FX_FLOAT sd = FXSYS_fabs(dCTM.d); | 941 FX_FLOAT sd = FXSYS_fabs(dCTM.d); |
942 clip_box.right = clip_box.left + (FX_INT32)FXSYS_ceil(clip_box.Width() * sa)
; | 942 clip_box.right = clip_box.left + (int32_t)FXSYS_ceil(clip_box.Width() * sa); |
943 clip_box.bottom = clip_box.top + (FX_INT32)FXSYS_ceil(clip_box.Height() * sd
); | 943 clip_box.bottom = clip_box.top + (int32_t)FXSYS_ceil(clip_box.Height() * sd)
; |
944 CFX_AffineMatrix mtPattern2Device = pPattern->m_Pattern2Form; | 944 CFX_AffineMatrix mtPattern2Device = pPattern->m_Pattern2Form; |
945 mtPattern2Device.Concat(*pObj2Device); | 945 mtPattern2Device.Concat(*pObj2Device); |
946 GetScaledMatrix(mtPattern2Device); | 946 GetScaledMatrix(mtPattern2Device); |
947 FX_BOOL bAligned = FALSE; | 947 FX_BOOL bAligned = FALSE; |
948 if (pPattern->m_BBox.left == 0 && pPattern->m_BBox.bottom == 0 && | 948 if (pPattern->m_BBox.left == 0 && pPattern->m_BBox.bottom == 0 && |
949 pPattern->m_BBox.right == pPattern->m_XStep && pPattern->m_BBox.top
== pPattern->m_YStep && | 949 pPattern->m_BBox.right == pPattern->m_XStep && pPattern->m_BBox.top
== pPattern->m_YStep && |
950 (mtPattern2Device.IsScaled() || mtPattern2Device.Is90Rotated())) { | 950 (mtPattern2Device.IsScaled() || mtPattern2Device.Is90Rotated())) { |
951 bAligned = TRUE; | 951 bAligned = TRUE; |
952 } | 952 } |
953 CFX_FloatRect cell_bbox = pPattern->m_BBox; | 953 CFX_FloatRect cell_bbox = pPattern->m_BBox; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 } | 1103 } |
1104 } | 1104 } |
1105 if(bStroke) { | 1105 if(bStroke) { |
1106 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); | 1106 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); |
1107 if(StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN)
{ | 1107 if(StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN)
{ |
1108 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); | 1108 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); |
1109 bStroke = FALSE; | 1109 bStroke = FALSE; |
1110 } | 1110 } |
1111 } | 1111 } |
1112 } | 1112 } |
OLD | NEW |