| 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 11 matching lines...) Expand all Loading... |
| 22 FX_FLOAT start_x = pCoords->GetNumber(0); | 22 FX_FLOAT start_x = pCoords->GetNumber(0); |
| 23 FX_FLOAT start_y = pCoords->GetNumber(1); | 23 FX_FLOAT start_y = pCoords->GetNumber(1); |
| 24 FX_FLOAT end_x = pCoords->GetNumber(2); | 24 FX_FLOAT end_x = pCoords->GetNumber(2); |
| 25 FX_FLOAT end_y = pCoords->GetNumber(3); | 25 FX_FLOAT end_y = pCoords->GetNumber(3); |
| 26 FX_FLOAT t_min = 0, t_max = 1.0f; | 26 FX_FLOAT t_min = 0, t_max = 1.0f; |
| 27 CPDF_Array* pArray = pDict->GetArray(FX_BSTRC("Domain")); | 27 CPDF_Array* pArray = pDict->GetArray(FX_BSTRC("Domain")); |
| 28 if (pArray) { | 28 if (pArray) { |
| 29 t_min = pArray->GetNumber(0); | 29 t_min = pArray->GetNumber(0); |
| 30 t_max = pArray->GetNumber(1); | 30 t_max = pArray->GetNumber(1); |
| 31 } | 31 } |
| 32 FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; | 32 bool bStartExtend = false, bEndExtend = false; |
| 33 pArray = pDict->GetArray(FX_BSTRC("Extend")); | 33 pArray = pDict->GetArray(FX_BSTRC("Extend")); |
| 34 if (pArray) { | 34 if (pArray) { |
| 35 bStartExtend = pArray->GetInteger(0); | 35 bStartExtend = pArray->GetInteger(0); |
| 36 bEndExtend = pArray->GetInteger(1); | 36 bEndExtend = pArray->GetInteger(1); |
| 37 } | 37 } |
| 38 int width = pBitmap->GetWidth(); | 38 int width = pBitmap->GetWidth(); |
| 39 int height = pBitmap->GetHeight(); | 39 int height = pBitmap->GetHeight(); |
| 40 FX_FLOAT x_span = end_x - start_x; | 40 FX_FLOAT x_span = end_x - start_x; |
| 41 FX_FLOAT y_span = end_y - start_y; | 41 FX_FLOAT y_span = end_y - start_y; |
| 42 FX_FLOAT axis_len_square = FXSYS_Mul(x_span, x_span) + FXSYS_Mul(y_span, y_s
pan); | 42 FX_FLOAT axis_len_square = FXSYS_Mul(x_span, x_span) + FXSYS_Mul(y_span, y_s
pan); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 FX_FLOAT end_y = pCoords->GetNumber(4); | 109 FX_FLOAT end_y = pCoords->GetNumber(4); |
| 110 FX_FLOAT end_r = pCoords->GetNumber(5); | 110 FX_FLOAT end_r = pCoords->GetNumber(5); |
| 111 CFX_AffineMatrix matrix; | 111 CFX_AffineMatrix matrix; |
| 112 matrix.SetReverse(*pObject2Bitmap); | 112 matrix.SetReverse(*pObject2Bitmap); |
| 113 FX_FLOAT t_min = 0, t_max = 1.0f; | 113 FX_FLOAT t_min = 0, t_max = 1.0f; |
| 114 CPDF_Array* pArray = pDict->GetArray(FX_BSTRC("Domain")); | 114 CPDF_Array* pArray = pDict->GetArray(FX_BSTRC("Domain")); |
| 115 if (pArray) { | 115 if (pArray) { |
| 116 t_min = pArray->GetNumber(0); | 116 t_min = pArray->GetNumber(0); |
| 117 t_max = pArray->GetNumber(1); | 117 t_max = pArray->GetNumber(1); |
| 118 } | 118 } |
| 119 FX_BOOL bStartExtend = FALSE, bEndExtend = FALSE; | 119 bool bStartExtend = false, bEndExtend = false; |
| 120 pArray = pDict->GetArray(FX_BSTRC("Extend")); | 120 pArray = pDict->GetArray(FX_BSTRC("Extend")); |
| 121 if (pArray) { | 121 if (pArray) { |
| 122 bStartExtend = pArray->GetInteger(0); | 122 bStartExtend = pArray->GetInteger(0); |
| 123 bEndExtend = pArray->GetInteger(1); | 123 bEndExtend = pArray->GetInteger(1); |
| 124 } | 124 } |
| 125 int total_results = 0; | 125 int total_results = 0; |
| 126 for (int j = 0; j < nFuncs; j ++) { | 126 for (int j = 0; j < nFuncs; j ++) { |
| 127 if (pFuncs[j]) { | 127 if (pFuncs[j]) { |
| 128 total_results += pFuncs[j]->CountOutputs(); | 128 total_results += pFuncs[j]->CountOutputs(); |
| 129 } | 129 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 148 } | 148 } |
| 149 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; | 149 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; |
| 150 pCS->GetRGB(pResults, R, G, B); | 150 pCS->GetRGB(pResults, R, G, B); |
| 151 rgb_array[i] = FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), FXS
YS_round(G * 255), FXSYS_round(B * 255))); | 151 rgb_array[i] = FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), FXS
YS_round(G * 255), FXSYS_round(B * 255))); |
| 152 } | 152 } |
| 153 FX_FLOAT a = FXSYS_Mul(start_x - end_x, start_x - end_x) + | 153 FX_FLOAT a = FXSYS_Mul(start_x - end_x, start_x - end_x) + |
| 154 FXSYS_Mul(start_y - end_y, start_y - end_y) - FXSYS_Mul(start_r
- end_r, start_r - end_r); | 154 FXSYS_Mul(start_y - end_y, start_y - end_y) - FXSYS_Mul(start_r
- end_r, start_r - end_r); |
| 155 int width = pBitmap->GetWidth(); | 155 int width = pBitmap->GetWidth(); |
| 156 int height = pBitmap->GetHeight(); | 156 int height = pBitmap->GetHeight(); |
| 157 int pitch = pBitmap->GetPitch(); | 157 int pitch = pBitmap->GetPitch(); |
| 158 FX_BOOL bDecreasing = FALSE; | 158 bool bDecreasing = false; |
| 159 if (start_r > end_r) { | 159 if (start_r > end_r) { |
| 160 int length = (int)FXSYS_sqrt((FXSYS_Mul(start_x - end_x, start_x - end_x
) + FXSYS_Mul(start_y - end_y, start_y - end_y))); | 160 int length = (int)FXSYS_sqrt((FXSYS_Mul(start_x - end_x, start_x - end_x
) + FXSYS_Mul(start_y - end_y, start_y - end_y))); |
| 161 if (length < start_r - end_r) { | 161 if (length < start_r - end_r) { |
| 162 bDecreasing = TRUE; | 162 bDecreasing = true; |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 for (int row = 0; row < height; row ++) { | 165 for (int row = 0; row < height; row ++) { |
| 166 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); | 166 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); |
| 167 for (int column = 0; column < width; column ++) { | 167 for (int column = 0; column < width; column ++) { |
| 168 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; | 168 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; |
| 169 matrix.Transform(x, y); | 169 matrix.Transform(x, y); |
| 170 FX_FLOAT b = -2 * (FXSYS_Mul(x - start_x, end_x - start_x) + FXSYS_M
ul(y - start_y, end_y - start_y) + | 170 FX_FLOAT b = -2 * (FXSYS_Mul(x - start_x, end_x - start_x) + FXSYS_M
ul(y - start_y, end_y - start_y) + |
| 171 FXSYS_Mul(start_r, end_r - start_r)); | 171 FXSYS_Mul(start_r, end_r - start_r)); |
| 172 FX_FLOAT c = FXSYS_Mul(x - start_x, x - start_x) + FXSYS_Mul(y - sta
rt_y, y - start_y) - | 172 FX_FLOAT c = FXSYS_Mul(x - start_x, x - start_x) + FXSYS_Mul(y - sta
rt_y, y - start_y) - |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, (int32_t)(R * 255)
, (int32_t)(G * 255), (int32_t)(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 bool _GetScanlineIntersect(int y, FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOA
T 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) { |
| 291 return FALSE; | 291 return false; |
| 292 } | 292 } |
| 293 } else { | 293 } else { |
| 294 if (y < y2 || y > y1) { | 294 if (y < y2 || y > y1) { |
| 295 return FALSE; | 295 return false; |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 x = x1 + FXSYS_MulDiv(x2 - x1, y - y1, y2 - y1); | 298 x = x1 + FXSYS_MulDiv(x2 - x1, y - y1, y2 - y1); |
| 299 return TRUE; | 299 return true; |
| 300 } | 300 } |
| 301 static void _DrawGouraud(CFX_DIBitmap* pBitmap, int alpha, CPDF_MeshVertex trian
gle[3]) | 301 static void _DrawGouraud(CFX_DIBitmap* pBitmap, int alpha, CPDF_MeshVertex trian
gle[3]) |
| 302 { | 302 { |
| 303 FX_FLOAT min_y = triangle[0].y, max_y = triangle[0].y; | 303 FX_FLOAT min_y = triangle[0].y, max_y = triangle[0].y; |
| 304 for (int i = 1; i < 3; i ++) { | 304 for (int i = 1; i < 3; i ++) { |
| 305 if (min_y > triangle[i].y) { | 305 if (min_y > triangle[i].y) { |
| 306 min_y = triangle[i].y; | 306 min_y = triangle[i].y; |
| 307 } | 307 } |
| 308 if (max_y < triangle[i].y) { | 308 if (max_y < triangle[i].y) { |
| 309 max_y = triangle[i].y; | 309 max_y = triangle[i].y; |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 if (min_y == max_y) { | 312 if (min_y == max_y) { |
| 313 return; | 313 return; |
| 314 } | 314 } |
| 315 int min_yi = (int)FXSYS_floor(min_y), max_yi = (int)FXSYS_ceil(max_y); | 315 int min_yi = (int)FXSYS_floor(min_y), max_yi = (int)FXSYS_ceil(max_y); |
| 316 if (min_yi < 0) { | 316 if (min_yi < 0) { |
| 317 min_yi = 0; | 317 min_yi = 0; |
| 318 } | 318 } |
| 319 if (max_yi >= pBitmap->GetHeight()) { | 319 if (max_yi >= pBitmap->GetHeight()) { |
| 320 max_yi = pBitmap->GetHeight() - 1; | 320 max_yi = pBitmap->GetHeight() - 1; |
| 321 } | 321 } |
| 322 for (int y = min_yi; y <= max_yi; y ++) { | 322 for (int y = min_yi; y <= max_yi; y ++) { |
| 323 int nIntersects = 0; | 323 int nIntersects = 0; |
| 324 FX_FLOAT inter_x[3], r[3], g[3], b[3]; | 324 FX_FLOAT inter_x[3], r[3], g[3], b[3]; |
| 325 for (int i = 0; i < 3; i ++) { | 325 for (int i = 0; i < 3; i ++) { |
| 326 CPDF_MeshVertex& vertex1 = triangle[i]; | 326 CPDF_MeshVertex& vertex1 = triangle[i]; |
| 327 CPDF_MeshVertex& vertex2 = triangle[(i + 1) % 3]; | 327 CPDF_MeshVertex& vertex2 = triangle[(i + 1) % 3]; |
| 328 FX_BOOL bIntersect = _GetScanlineIntersect(y, vertex1.x, vertex1.y, | 328 bool bIntersect = _GetScanlineIntersect(y, vertex1.x, vertex1.y, |
| 329 vertex2.x, vertex2.y, inter_x[nIntersects]); | 329 vertex2.x, vertex2.y, inter_x[nIntersects]); |
| 330 if (!bIntersect) { | 330 if (!bIntersect) { |
| 331 continue; | 331 continue; |
| 332 } | 332 } |
| 333 r[nIntersects] = vertex1.r + FXSYS_MulDiv(vertex2.r - vertex1.r, y -
vertex1.y, vertex2.y - vertex1.y); | 333 r[nIntersects] = vertex1.r + FXSYS_MulDiv(vertex2.r - vertex1.r, y -
vertex1.y, vertex2.y - vertex1.y); |
| 334 g[nIntersects] = vertex1.g + FXSYS_MulDiv(vertex2.g - vertex1.g, y -
vertex1.y, vertex2.y - vertex1.y); | 334 g[nIntersects] = vertex1.g + FXSYS_MulDiv(vertex2.g - vertex1.g, y -
vertex1.y, vertex2.y - vertex1.y); |
| 335 b[nIntersects] = vertex1.b + FXSYS_MulDiv(vertex2.b - vertex1.b, y -
vertex1.y, vertex2.y - vertex1.y); | 335 b[nIntersects] = vertex1.b + FXSYS_MulDiv(vertex2.b - vertex1.b, y -
vertex1.y, vertex2.y - vertex1.y); |
| 336 nIntersects ++; | 336 nIntersects ++; |
| 337 } | 337 } |
| 338 if (nIntersects != 2) { | 338 if (nIntersects != 2) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 }; | 594 }; |
| 595 struct CPDF_PatchDrawer { | 595 struct CPDF_PatchDrawer { |
| 596 Coon_Color patch_colors[4]; | 596 Coon_Color patch_colors[4]; |
| 597 int max_delta; | 597 int max_delta; |
| 598 CFX_PathData path; | 598 CFX_PathData path; |
| 599 CFX_RenderDevice* pDevice; | 599 CFX_RenderDevice* pDevice; |
| 600 int fill_mode; | 600 int fill_mode; |
| 601 int alpha; | 601 int alpha; |
| 602 void Draw(int x_scale, int y_scale, int left, int bottom, Coon_Bezier C1, Co
on_Bezier C2, Coon_Bezier D1, Coon_Bezier D2) | 602 void Draw(int x_scale, int y_scale, int left, int bottom, Coon_Bezier C1, Co
on_Bezier C2, Coon_Bezier D1, Coon_Bezier D2) |
| 603 { | 603 { |
| 604 FX_BOOL bSmall = C1.Distance() < 2 && C2.Distance() < 2 && D1.Distance()
< 2 && D2.Distance() < 2; | 604 bool bSmall = C1.Distance() < 2 && C2.Distance() < 2 && D1.Distance() <
2 && D2.Distance() < 2; |
| 605 Coon_Color div_colors[4]; | 605 Coon_Color div_colors[4]; |
| 606 int d_bottom, d_left, d_top, d_right; | 606 int d_bottom, d_left, d_top, d_right; |
| 607 div_colors[0].BiInterpol(patch_colors, left, bottom, x_scale, y_scale); | 607 div_colors[0].BiInterpol(patch_colors, left, bottom, x_scale, y_scale); |
| 608 if (!bSmall) { | 608 if (!bSmall) { |
| 609 div_colors[1].BiInterpol(patch_colors, left, bottom + 1, x_scale, y_
scale); | 609 div_colors[1].BiInterpol(patch_colors, left, bottom + 1, x_scale, y_
scale); |
| 610 div_colors[2].BiInterpol(patch_colors, left + 1, bottom + 1, x_scale
, y_scale); | 610 div_colors[2].BiInterpol(patch_colors, left + 1, bottom + 1, x_scale
, y_scale); |
| 611 div_colors[3].BiInterpol(patch_colors, left + 1, bottom, x_scale, y_
scale); | 611 div_colors[3].BiInterpol(patch_colors, left + 1, bottom, x_scale, y_
scale); |
| 612 d_bottom = div_colors[3].Distance(div_colors[0]); | 612 d_bottom = div_colors[3].Distance(div_colors[0]); |
| 613 d_left = div_colors[1].Distance(div_colors[0]); | 613 d_left = div_colors[1].Distance(div_colors[0]); |
| 614 d_top = div_colors[1].Distance(div_colors[2]); | 614 d_top = div_colors[1].Distance(div_colors[2]); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 bottom *= 2; | 656 bottom *= 2; |
| 657 Draw(x_scale, y_scale, left, bottom, C1.first_half(), m1f, D1.fi
rst_half(), m2f); | 657 Draw(x_scale, y_scale, left, bottom, C1.first_half(), m1f, D1.fi
rst_half(), m2f); |
| 658 Draw(x_scale, y_scale, left, bottom + 1, m1f, C2.first_half(), D
1.second_half(), m2s); | 658 Draw(x_scale, y_scale, left, bottom + 1, m1f, C2.first_half(), D
1.second_half(), m2s); |
| 659 Draw(x_scale, y_scale, left + 1, bottom, C1.second_half(), m1s,
m2f, D2.first_half()); | 659 Draw(x_scale, y_scale, left + 1, bottom, C1.second_half(), m1s,
m2f, D2.first_half()); |
| 660 Draw(x_scale, y_scale, left + 1, bottom + 1, m1s, C2.second_half
(), m2s, D2.second_half()); | 660 Draw(x_scale, y_scale, left + 1, bottom + 1, m1s, C2.second_half
(), m2s, D2.second_half()); |
| 661 } | 661 } |
| 662 } | 662 } |
| 663 } | 663 } |
| 664 }; | 664 }; |
| 665 | 665 |
| 666 FX_BOOL _CheckCoonTensorPara(const CPDF_MeshStream &stream) | 666 bool _CheckCoonTensorPara(const CPDF_MeshStream &stream) |
| 667 { | 667 { |
| 668 FX_BOOL bCoorBits = ( stream.m_nCoordBits== 1 || | 668 bool bCoorBits = ( stream.m_nCoordBits== 1 || |
| 669 stream.m_nCoordBits == 2 || | 669 stream.m_nCoordBits == 2 || |
| 670 stream.m_nCoordBits == 4 || | 670 stream.m_nCoordBits == 4 || |
| 671 stream.m_nCoordBits == 8 || | 671 stream.m_nCoordBits == 8 || |
| 672 stream.m_nCoordBits == 12 || | 672 stream.m_nCoordBits == 12 || |
| 673 stream.m_nCoordBits == 16 || | 673 stream.m_nCoordBits == 16 || |
| 674 stream.m_nCoordBits == 24 || | 674 stream.m_nCoordBits == 24 || |
| 675 stream.m_nCoordBits == 32 ); | 675 stream.m_nCoordBits == 32 ); |
| 676 | 676 |
| 677 FX_BOOL bCompBits = ( stream.m_nCompBits == 1 || | 677 bool bCompBits = ( stream.m_nCompBits == 1 || |
| 678 stream.m_nCompBits == 2 || | 678 stream.m_nCompBits == 2 || |
| 679 stream.m_nCompBits == 4 || | 679 stream.m_nCompBits == 4 || |
| 680 stream.m_nCompBits == 8 || | 680 stream.m_nCompBits == 8 || |
| 681 stream.m_nCompBits == 12 || | 681 stream.m_nCompBits == 12 || |
| 682 stream.m_nCompBits == 16 ); | 682 stream.m_nCompBits == 16 ); |
| 683 | 683 |
| 684 FX_BOOL bFlagBits = ( stream.m_nFlagBits == 2 || | 684 bool bFlagBits = ( stream.m_nFlagBits == 2 || |
| 685 stream.m_nFlagBits == 4 || | 685 stream.m_nFlagBits == 4 || |
| 686 stream.m_nFlagBits == 8 ); | 686 stream.m_nFlagBits == 8 ); |
| 687 | 687 |
| 688 return bCoorBits && bCompBits && bFlagBits; | 688 return bCoorBits && bCompBits && bFlagBits; |
| 689 } | 689 } |
| 690 | 690 |
| 691 static void _DrawCoonPatchMeshes(FX_BOOL bTensor, CFX_DIBitmap* pBitmap, CFX_Aff
ineMatrix* pObject2Bitmap, | 691 static void _DrawCoonPatchMeshes(bool bTensor, CFX_DIBitmap* pBitmap, CFX_Affine
Matrix* pObject2Bitmap, |
| 692 CPDF_Stream* pShadingStream, CPDF_Function** pF
uncs, int nFuncs, | 692 CPDF_Stream* pShadingStream, CPDF_Function** pF
uncs, int nFuncs, |
| 693 CPDF_ColorSpace* pCS, int fill_mode, int alpha) | 693 CPDF_ColorSpace* pCS, int fill_mode, int alpha) |
| 694 { | 694 { |
| 695 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); | 695 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); |
| 696 if (pShadingStream->GetType() != PDFOBJ_STREAM) { | 696 if (pShadingStream->GetType() != PDFOBJ_STREAM) { |
| 697 return; | 697 return; |
| 698 } | 698 } |
| 699 CFX_FxgeDevice device; | 699 CFX_FxgeDevice device; |
| 700 device.Attach(pBitmap); | 700 device.Attach(pBitmap); |
| 701 CPDF_MeshStream stream; | 701 CPDF_MeshStream stream; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, |
| 762 coords[6].x, coords[6].y); | 762 coords[6].x, coords[6].y); |
| 763 D1.FromPoints(coords[0].x, coords[0].y, coords[1].x, coords[1].y, coords
[2].x, coords[2].y, | 763 D1.FromPoints(coords[0].x, coords[0].y, coords[1].x, coords[1].y, coords
[2].x, coords[2].y, |
| 764 coords[3].x, coords[3].y); | 764 coords[3].x, coords[3].y); |
| 765 D2.FromPoints(coords[9].x, coords[9].y, coords[8].x, coords[8].y, coords
[7].x, coords[7].y, | 765 D2.FromPoints(coords[9].x, coords[9].y, coords[8].x, coords[8].y, coords
[7].x, coords[7].y, |
| 766 coords[6].x, coords[6].y); | 766 coords[6].x, coords[6].y); |
| 767 patch.Draw(1, 1, 0, 0, C1, C2, D1, D2); | 767 patch.Draw(1, 1, 0, 0, C1, C2, D1, D2); |
| 768 } | 768 } |
| 769 } | 769 } |
| 770 void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, CFX_AffineMat
rix* pMatrix, | 770 void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, CFX_AffineMat
rix* pMatrix, |
| 771 FX_RECT& clip_rect, int alpha, FX_BOOL bAlph
aMode) | 771 FX_RECT& clip_rect, int alpha, bool bAlphaMo
de) |
| 772 { | 772 { |
| 773 CPDF_Function** pFuncs = pPattern->m_pFunctions; | 773 CPDF_Function** pFuncs = pPattern->m_pFunctions; |
| 774 int nFuncs = pPattern->m_nFuncs; | 774 int nFuncs = pPattern->m_nFuncs; |
| 775 CPDF_Dictionary* pDict = pPattern->m_pShadingObj->GetDict(); | 775 CPDF_Dictionary* pDict = pPattern->m_pShadingObj->GetDict(); |
| 776 CPDF_ColorSpace* pColorSpace = pPattern->m_pCS; | 776 CPDF_ColorSpace* pColorSpace = pPattern->m_pCS; |
| 777 if (pColorSpace == NULL) { | 777 if (pColorSpace == NULL) { |
| 778 return; | 778 return; |
| 779 } | 779 } |
| 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"))) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 break; | 833 break; |
| 834 } | 834 } |
| 835 if (bAlphaMode) { | 835 if (bAlphaMode) { |
| 836 pBitmap->LoadChannel(FXDIB_Red, pBitmap, FXDIB_Alpha); | 836 pBitmap->LoadChannel(FXDIB_Red, pBitmap, FXDIB_Alpha); |
| 837 } | 837 } |
| 838 if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) { | 838 if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) { |
| 839 pBitmap->ConvertColorScale(m_Options.m_ForeColor, m_Options.m_BackColor)
; | 839 pBitmap->ConvertColorScale(m_Options.m_ForeColor, m_Options.m_BackColor)
; |
| 840 } | 840 } |
| 841 buffer.OutputToDevice(); | 841 buffer.OutputToDevice(); |
| 842 } | 842 } |
| 843 void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern, CPDF_Pa
geObject* pPageObj, const CFX_AffineMatrix* pObj2Device, FX_BOOL bStroke) | 843 void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern, CPDF_Pa
geObject* pPageObj, const CFX_AffineMatrix* pObj2Device, bool bStroke) |
| 844 { | 844 { |
| 845 if (!pattern->Load()) { | 845 if (!pattern->Load()) { |
| 846 return; | 846 return; |
| 847 } | 847 } |
| 848 m_pDevice->SaveState(); | 848 m_pDevice->SaveState(); |
| 849 if (pPageObj->m_Type == PDFPAGE_PATH) { | 849 if (pPageObj->m_Type == PDFPAGE_PATH) { |
| 850 if (!SelectClipPath((CPDF_PathObject*)pPageObj, pObj2Device, bStroke)) { | 850 if (!SelectClipPath((CPDF_PathObject*)pPageObj, pObj2Device, bStroke)) { |
| 851 m_pDevice->RestoreState(); | 851 m_pDevice->RestoreState(); |
| 852 return; | 852 return; |
| 853 } | 853 } |
| 854 } else if (pPageObj->m_Type == PDFPAGE_IMAGE) { | 854 } else if (pPageObj->m_Type == PDFPAGE_IMAGE) { |
| 855 FX_RECT rect = pPageObj->GetBBox(pObj2Device); | 855 FX_RECT rect = pPageObj->GetBBox(pObj2Device); |
| 856 m_pDevice->SetClip_Rect(&rect); | 856 m_pDevice->SetClip_Rect(&rect); |
| 857 } else { | 857 } else { |
| 858 return; | 858 return; |
| 859 } | 859 } |
| 860 FX_RECT rect; | 860 FX_RECT rect; |
| 861 if (GetObjectClippedRect(pPageObj, pObj2Device, FALSE, rect)) { | 861 if (GetObjectClippedRect(pPageObj, pObj2Device, false, rect)) { |
| 862 m_pDevice->RestoreState(); | 862 m_pDevice->RestoreState(); |
| 863 return; | 863 return; |
| 864 } | 864 } |
| 865 CFX_AffineMatrix matrix = pattern->m_Pattern2Form; | 865 CFX_AffineMatrix matrix = pattern->m_Pattern2Form; |
| 866 matrix.Concat(*pObj2Device); | 866 matrix.Concat(*pObj2Device); |
| 867 GetScaledMatrix(matrix); | 867 GetScaledMatrix(matrix); |
| 868 int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke); | 868 int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke); |
| 869 DrawShading(pattern, &matrix, rect, alpha, m_Options.m_ColorMode == RENDER_C
OLOR_ALPHA); | 869 DrawShading(pattern, &matrix, rect, alpha, m_Options.m_ColorMode == RENDER_C
OLOR_ALPHA); |
| 870 m_pDevice->RestoreState(); | 870 m_pDevice->RestoreState(); |
| 871 } | 871 } |
| 872 FX_BOOL CPDF_RenderStatus::ProcessShading(CPDF_ShadingObject* pShadingObj, const
CFX_AffineMatrix* pObj2Device) | 872 bool CPDF_RenderStatus::ProcessShading(CPDF_ShadingObject* pShadingObj, const CF
X_AffineMatrix* pObj2Device) |
| 873 { | 873 { |
| 874 FX_RECT rect = pShadingObj->GetBBox(pObj2Device); | 874 FX_RECT rect = pShadingObj->GetBBox(pObj2Device); |
| 875 FX_RECT clip_box = m_pDevice->GetClipBox(); | 875 FX_RECT clip_box = m_pDevice->GetClipBox(); |
| 876 rect.Intersect(clip_box); | 876 rect.Intersect(clip_box); |
| 877 if (rect.IsEmpty()) { | 877 if (rect.IsEmpty()) { |
| 878 return TRUE; | 878 return true; |
| 879 } | 879 } |
| 880 CFX_AffineMatrix matrix = pShadingObj->m_Matrix; | 880 CFX_AffineMatrix matrix = pShadingObj->m_Matrix; |
| 881 matrix.Concat(*pObj2Device); | 881 matrix.Concat(*pObj2Device); |
| 882 DrawShading(pShadingObj->m_pShading, &matrix, rect, pShadingObj->m_GeneralSt
ate.GetAlpha(FALSE), | 882 DrawShading(pShadingObj->m_pShading, &matrix, rect, pShadingObj->m_GeneralSt
ate.GetAlpha(false), |
| 883 m_Options.m_ColorMode == RENDER_COLOR_ALPHA); | 883 m_Options.m_ColorMode == RENDER_COLOR_ALPHA); |
| 884 return TRUE; | 884 return true; |
| 885 } | 885 } |
| 886 static CFX_DIBitmap* DrawPatternBitmap(CPDF_Document* pDoc, CPDF_PageRenderCache
* pCache, | 886 static CFX_DIBitmap* DrawPatternBitmap(CPDF_Document* pDoc, CPDF_PageRenderCache
* pCache, |
| 887 CPDF_TilingPattern* pPattern, const CFX_A
ffineMatrix* pObject2Device, | 887 CPDF_TilingPattern* pPattern, const CFX_A
ffineMatrix* pObject2Device, |
| 888 int width, int height, int flags) | 888 int width, int height, int flags) |
| 889 { | 889 { |
| 890 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 890 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
| 891 if (!pBitmap->Create(width, height, pPattern->m_bColored ? FXDIB_Argb : FXDI
B_8bppMask)) { | 891 if (!pBitmap->Create(width, height, pPattern->m_bColored ? FXDIB_Argb : FXDI
B_8bppMask)) { |
| 892 delete pBitmap; | 892 delete pBitmap; |
| 893 return NULL; | 893 return NULL; |
| 894 } | 894 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 907 if (!pPattern->m_bColored) { | 907 if (!pPattern->m_bColored) { |
| 908 options.m_ColorMode = RENDER_COLOR_ALPHA; | 908 options.m_ColorMode = RENDER_COLOR_ALPHA; |
| 909 } | 909 } |
| 910 flags |= RENDER_FORCE_HALFTONE; | 910 flags |= RENDER_FORCE_HALFTONE; |
| 911 options.m_Flags = flags; | 911 options.m_Flags = flags; |
| 912 CPDF_RenderContext context; | 912 CPDF_RenderContext context; |
| 913 context.Create(pDoc, pCache, NULL); | 913 context.Create(pDoc, pCache, NULL); |
| 914 context.DrawObjectList(&bitmap_device, pPattern->m_pForm, &mtPattern2Bitmap,
&options); | 914 context.DrawObjectList(&bitmap_device, pPattern->m_pForm, &mtPattern2Bitmap,
&options); |
| 915 return pBitmap; | 915 return pBitmap; |
| 916 } | 916 } |
| 917 void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, CPDF_Pag
eObject* pPageObj, const CFX_AffineMatrix* pObj2Device, FX_BOOL bStroke) | 917 void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, CPDF_Pag
eObject* pPageObj, const CFX_AffineMatrix* pObj2Device, bool bStroke) |
| 918 { | 918 { |
| 919 if (!pPattern->Load()) { | 919 if (!pPattern->Load()) { |
| 920 return; | 920 return; |
| 921 } | 921 } |
| 922 m_pDevice->SaveState(); | 922 m_pDevice->SaveState(); |
| 923 if (pPageObj->m_Type == PDFPAGE_PATH) { | 923 if (pPageObj->m_Type == PDFPAGE_PATH) { |
| 924 if (!SelectClipPath((CPDF_PathObject*)pPageObj, pObj2Device, bStroke)) { | 924 if (!SelectClipPath((CPDF_PathObject*)pPageObj, pObj2Device, bStroke)) { |
| 925 m_pDevice->RestoreState(); | 925 m_pDevice->RestoreState(); |
| 926 return; | 926 return; |
| 927 } | 927 } |
| 928 } else if (pPageObj->m_Type == PDFPAGE_IMAGE) { | 928 } else if (pPageObj->m_Type == PDFPAGE_IMAGE) { |
| 929 FX_RECT rect = pPageObj->GetBBox(pObj2Device); | 929 FX_RECT rect = pPageObj->GetBBox(pObj2Device); |
| 930 m_pDevice->SetClip_Rect(&rect); | 930 m_pDevice->SetClip_Rect(&rect); |
| 931 } else { | 931 } else { |
| 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 + (int32_t)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 + (int32_t)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 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; |
| 954 mtPattern2Device.TransformRect(cell_bbox); | 954 mtPattern2Device.TransformRect(cell_bbox); |
| 955 int width = (int)FXSYS_ceil(cell_bbox.Width()); | 955 int width = (int)FXSYS_ceil(cell_bbox.Width()); |
| 956 int height = (int)FXSYS_ceil(cell_bbox.Height()); | 956 int height = (int)FXSYS_ceil(cell_bbox.Height()); |
| 957 if (width == 0) { | 957 if (width == 0) { |
| 958 width = 1; | 958 width = 1; |
| 959 } | 959 } |
| 960 if (height == 0) { | 960 if (height == 0) { |
| 961 height = 1; | 961 height = 1; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 } | 1068 } |
| 1069 } else { | 1069 } else { |
| 1070 if (pPattern->m_bColored) { | 1070 if (pPattern->m_bColored) { |
| 1071 screen.CompositeBitmap(start_x, start_y, width, height, pPat
ternBitmap, 0, 0); | 1071 screen.CompositeBitmap(start_x, start_y, width, height, pPat
ternBitmap, 0, 0); |
| 1072 } else { | 1072 } else { |
| 1073 screen.CompositeMask(start_x, start_y, width, height, pPatte
rnBitmap, fill_argb, 0, 0); | 1073 screen.CompositeMask(start_x, start_y, width, height, pPatte
rnBitmap, fill_argb, 0, 0); |
| 1074 } | 1074 } |
| 1075 } | 1075 } |
| 1076 } | 1076 } |
| 1077 } | 1077 } |
| 1078 CompositeDIBitmap(&screen, clip_box.left, clip_box.top, 0, 255, FXDIB_BLEND_
NORMAL, FALSE); | 1078 CompositeDIBitmap(&screen, clip_box.left, clip_box.top, 0, 255, FXDIB_BLEND_
NORMAL, false); |
| 1079 m_pDevice->RestoreState(); | 1079 m_pDevice->RestoreState(); |
| 1080 delete pPatternBitmap; | 1080 delete pPatternBitmap; |
| 1081 } | 1081 } |
| 1082 void CPDF_RenderStatus::DrawPathWithPattern(CPDF_PathObject* pPathObj, const CFX
_AffineMatrix* pObj2Device, CPDF_Color* pColor, FX_BOOL bStroke) | 1082 void CPDF_RenderStatus::DrawPathWithPattern(CPDF_PathObject* pPathObj, const CFX
_AffineMatrix* pObj2Device, CPDF_Color* pColor, bool bStroke) |
| 1083 { | 1083 { |
| 1084 CPDF_Pattern* pattern = pColor->GetPattern(); | 1084 CPDF_Pattern* pattern = pColor->GetPattern(); |
| 1085 if (pattern == NULL) { | 1085 if (pattern == NULL) { |
| 1086 return; | 1086 return; |
| 1087 } | 1087 } |
| 1088 if(pattern->m_PatternType == PATTERN_TILING) { | 1088 if(pattern->m_PatternType == PATTERN_TILING) { |
| 1089 DrawTilingPattern((CPDF_TilingPattern*)pattern, pPathObj, pObj2Device, b
Stroke); | 1089 DrawTilingPattern((CPDF_TilingPattern*)pattern, pPathObj, pObj2Device, b
Stroke); |
| 1090 } else { | 1090 } else { |
| 1091 DrawShadingPattern((CPDF_ShadingPattern*)pattern, pPathObj, pObj2Device,
bStroke); | 1091 DrawShadingPattern((CPDF_ShadingPattern*)pattern, pPathObj, pObj2Device,
bStroke); |
| 1092 } | 1092 } |
| 1093 } | 1093 } |
| 1094 void CPDF_RenderStatus::ProcessPathPattern(CPDF_PathObject* pPathObj, const CFX_
AffineMatrix* pObj2Device, int& filltype, FX_BOOL& bStroke) | 1094 void CPDF_RenderStatus::ProcessPathPattern(CPDF_PathObject* pPathObj, const CFX_
AffineMatrix* pObj2Device, int& filltype, bool& bStroke) |
| 1095 { | 1095 { |
| 1096 if(filltype) { | 1096 if(filltype) { |
| 1097 CPDF_Color& FillColor = *pPathObj->m_ColorState.GetFillColor(); | 1097 CPDF_Color& FillColor = *pPathObj->m_ColorState.GetFillColor(); |
| 1098 if(FillColor.m_pCS && FillColor.m_pCS->GetFamily() == PDFCS_PATTERN) { | 1098 if(FillColor.m_pCS && FillColor.m_pCS->GetFamily() == PDFCS_PATTERN) { |
| 1099 DrawPathWithPattern(pPathObj, pObj2Device, &FillColor, FALSE); | 1099 DrawPathWithPattern(pPathObj, pObj2Device, &FillColor, false); |
| 1100 filltype = 0; | 1100 filltype = 0; |
| 1101 } | 1101 } |
| 1102 } | 1102 } |
| 1103 if(bStroke) { | 1103 if(bStroke) { |
| 1104 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); | 1104 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); |
| 1105 if(StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN)
{ | 1105 if(StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN)
{ |
| 1106 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); | 1106 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, true); |
| 1107 bStroke = FALSE; | 1107 bStroke = false; |
| 1108 } | 1108 } |
| 1109 } | 1109 } |
| 1110 } | 1110 } |
| OLD | NEW |