| 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/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_page/cpdf_graphicstates.h" | 9 #include "core/fpdfapi/fpdf_page/cpdf_graphicstates.h" |
| 10 #include "core/fpdfapi/fpdf_page/cpdf_meshstream.h" | 10 #include "core/fpdfapi/fpdf_page/cpdf_meshstream.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (pFuncs[j]) { | 63 if (pFuncs[j]) { |
| 64 total_results += pFuncs[j]->CountOutputs(); | 64 total_results += pFuncs[j]->CountOutputs(); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 if (pCS->CountComponents() > total_results) { | 67 if (pCS->CountComponents() > total_results) { |
| 68 total_results = pCS->CountComponents(); | 68 total_results = pCS->CountComponents(); |
| 69 } | 69 } |
| 70 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); | 70 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); |
| 71 FX_FLOAT* pResults = result_array; | 71 FX_FLOAT* pResults = result_array; |
| 72 FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); | 72 FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); |
| 73 FX_DWORD rgb_array[SHADING_STEPS]; | 73 uint32_t rgb_array[SHADING_STEPS]; |
| 74 for (int i = 0; i < SHADING_STEPS; i++) { | 74 for (int i = 0; i < SHADING_STEPS; i++) { |
| 75 FX_FLOAT input = (t_max - t_min) * i / SHADING_STEPS + t_min; | 75 FX_FLOAT input = (t_max - t_min) * i / SHADING_STEPS + t_min; |
| 76 int offset = 0; | 76 int offset = 0; |
| 77 for (int j = 0; j < nFuncs; j++) { | 77 for (int j = 0; j < nFuncs; j++) { |
| 78 if (pFuncs[j]) { | 78 if (pFuncs[j]) { |
| 79 int nresults = 0; | 79 int nresults = 0; |
| 80 if (pFuncs[j]->Call(&input, 1, pResults + offset, nresults)) { | 80 if (pFuncs[j]->Call(&input, 1, pResults + offset, nresults)) { |
| 81 offset += nresults; | 81 offset += nresults; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; | 85 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; |
| 86 pCS->GetRGB(pResults, R, G, B); | 86 pCS->GetRGB(pResults, R, G, B); |
| 87 rgb_array[i] = | 87 rgb_array[i] = |
| 88 FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), | 88 FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), |
| 89 FXSYS_round(G * 255), FXSYS_round(B * 255))); | 89 FXSYS_round(G * 255), FXSYS_round(B * 255))); |
| 90 } | 90 } |
| 91 int pitch = pBitmap->GetPitch(); | 91 int pitch = pBitmap->GetPitch(); |
| 92 for (int row = 0; row < height; row++) { | 92 for (int row = 0; row < height; row++) { |
| 93 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); | 93 uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); |
| 94 for (int column = 0; column < width; column++) { | 94 for (int column = 0; column < width; column++) { |
| 95 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; | 95 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; |
| 96 matrix.Transform(x, y); | 96 matrix.Transform(x, y); |
| 97 FX_FLOAT scale = (((x - start_x) * x_span) + ((y - start_y) * y_span)) / | 97 FX_FLOAT scale = (((x - start_x) * x_span) + ((y - start_y) * y_span)) / |
| 98 axis_len_square; | 98 axis_len_square; |
| 99 int index = (int32_t)(scale * (SHADING_STEPS - 1)); | 99 int index = (int32_t)(scale * (SHADING_STEPS - 1)); |
| 100 if (index < 0) { | 100 if (index < 0) { |
| 101 if (!bStartExtend) { | 101 if (!bStartExtend) { |
| 102 continue; | 102 continue; |
| 103 } | 103 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (pFuncs[j]) { | 149 if (pFuncs[j]) { |
| 150 total_results += pFuncs[j]->CountOutputs(); | 150 total_results += pFuncs[j]->CountOutputs(); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 if (pCS->CountComponents() > total_results) { | 153 if (pCS->CountComponents() > total_results) { |
| 154 total_results = pCS->CountComponents(); | 154 total_results = pCS->CountComponents(); |
| 155 } | 155 } |
| 156 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); | 156 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); |
| 157 FX_FLOAT* pResults = result_array; | 157 FX_FLOAT* pResults = result_array; |
| 158 FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); | 158 FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); |
| 159 FX_DWORD rgb_array[SHADING_STEPS]; | 159 uint32_t rgb_array[SHADING_STEPS]; |
| 160 for (int i = 0; i < SHADING_STEPS; i++) { | 160 for (int i = 0; i < SHADING_STEPS; i++) { |
| 161 FX_FLOAT input = (t_max - t_min) * i / SHADING_STEPS + t_min; | 161 FX_FLOAT input = (t_max - t_min) * i / SHADING_STEPS + t_min; |
| 162 int offset = 0; | 162 int offset = 0; |
| 163 for (int j = 0; j < nFuncs; j++) { | 163 for (int j = 0; j < nFuncs; j++) { |
| 164 if (pFuncs[j]) { | 164 if (pFuncs[j]) { |
| 165 int nresults; | 165 int nresults; |
| 166 if (pFuncs[j]->Call(&input, 1, pResults + offset, nresults)) { | 166 if (pFuncs[j]->Call(&input, 1, pResults + offset, nresults)) { |
| 167 offset += nresults; | 167 offset += nresults; |
| 168 } | 168 } |
| 169 } | 169 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 182 int pitch = pBitmap->GetPitch(); | 182 int pitch = pBitmap->GetPitch(); |
| 183 FX_BOOL bDecreasing = FALSE; | 183 FX_BOOL bDecreasing = FALSE; |
| 184 if (start_r > end_r) { | 184 if (start_r > end_r) { |
| 185 int length = (int)FXSYS_sqrt((((start_x - end_x) * (start_x - end_x)) + | 185 int length = (int)FXSYS_sqrt((((start_x - end_x) * (start_x - end_x)) + |
| 186 ((start_y - end_y) * (start_y - end_y)))); | 186 ((start_y - end_y) * (start_y - end_y)))); |
| 187 if (length < start_r - end_r) { | 187 if (length < start_r - end_r) { |
| 188 bDecreasing = TRUE; | 188 bDecreasing = TRUE; |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 for (int row = 0; row < height; row++) { | 191 for (int row = 0; row < height; row++) { |
| 192 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); | 192 uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); |
| 193 for (int column = 0; column < width; column++) { | 193 for (int column = 0; column < width; column++) { |
| 194 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; | 194 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; |
| 195 matrix.Transform(x, y); | 195 matrix.Transform(x, y); |
| 196 FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + | 196 FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) + |
| 197 ((y - start_y) * (end_y - start_y)) + | 197 ((y - start_y) * (end_y - start_y)) + |
| 198 (start_r * (end_r - start_r))); | 198 (start_r * (end_r - start_r))); |
| 199 FX_FLOAT c = ((x - start_x) * (x - start_x)) + | 199 FX_FLOAT c = ((x - start_x) * (x - start_x)) + |
| 200 ((y - start_y) * (y - start_y)) - (start_r * start_r); | 200 ((y - start_y) * (y - start_y)) - (start_r * start_r); |
| 201 FX_FLOAT s; | 201 FX_FLOAT s; |
| 202 if (a == 0) { | 202 if (a == 0) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 total_results += pFuncs[j]->CountOutputs(); | 279 total_results += pFuncs[j]->CountOutputs(); |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 if (pCS->CountComponents() > total_results) { | 282 if (pCS->CountComponents() > total_results) { |
| 283 total_results = pCS->CountComponents(); | 283 total_results = pCS->CountComponents(); |
| 284 } | 284 } |
| 285 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); | 285 CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); |
| 286 FX_FLOAT* pResults = result_array; | 286 FX_FLOAT* pResults = result_array; |
| 287 FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); | 287 FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); |
| 288 for (int row = 0; row < height; row++) { | 288 for (int row = 0; row < height; row++) { |
| 289 FX_DWORD* dib_buf = (FX_DWORD*)(pBitmap->GetBuffer() + row * pitch); | 289 uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); |
| 290 for (int column = 0; column < width; column++) { | 290 for (int column = 0; column < width; column++) { |
| 291 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; | 291 FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; |
| 292 matrix.Transform(x, y); | 292 matrix.Transform(x, y); |
| 293 if (x < xmin || x > xmax || y < ymin || y > ymax) { | 293 if (x < xmin || x > xmax || y < ymin || y > ymax) { |
| 294 continue; | 294 continue; |
| 295 } | 295 } |
| 296 FX_FLOAT input[2]; | 296 FX_FLOAT input[2]; |
| 297 int offset = 0; | 297 int offset = 0; |
| 298 input[0] = x; | 298 input[0] = x; |
| 299 input[1] = y; | 299 input[1] = y; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 425 |
| 426 CPDF_MeshStream stream; | 426 CPDF_MeshStream stream; |
| 427 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) | 427 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) |
| 428 return; | 428 return; |
| 429 | 429 |
| 430 CPDF_MeshVertex triangle[3]; | 430 CPDF_MeshVertex triangle[3]; |
| 431 FXSYS_memset(triangle, 0, sizeof(triangle)); | 431 FXSYS_memset(triangle, 0, sizeof(triangle)); |
| 432 | 432 |
| 433 while (!stream.m_BitStream.IsEOF()) { | 433 while (!stream.m_BitStream.IsEOF()) { |
| 434 CPDF_MeshVertex vertex; | 434 CPDF_MeshVertex vertex; |
| 435 FX_DWORD flag = stream.GetVertex(vertex, pObject2Bitmap); | 435 uint32_t flag = stream.GetVertex(vertex, pObject2Bitmap); |
| 436 if (flag == 0) { | 436 if (flag == 0) { |
| 437 triangle[0] = vertex; | 437 triangle[0] = vertex; |
| 438 for (int j = 1; j < 3; j++) { | 438 for (int j = 1; j < 3; j++) { |
| 439 stream.GetVertex(triangle[j], pObject2Bitmap); | 439 stream.GetVertex(triangle[j], pObject2Bitmap); |
| 440 } | 440 } |
| 441 } else { | 441 } else { |
| 442 if (flag == 1) { | 442 if (flag == 1) { |
| 443 triangle[0] = triangle[1]; | 443 triangle[0] = triangle[1]; |
| 444 } | 444 } |
| 445 triangle[1] = triangle[2]; | 445 triangle[1] = triangle[2]; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 patch.fill_mode = fill_mode; | 775 patch.fill_mode = fill_mode; |
| 776 patch.path.SetPointCount(13); | 776 patch.path.SetPointCount(13); |
| 777 FX_PATHPOINT* pPoints = patch.path.GetPoints(); | 777 FX_PATHPOINT* pPoints = patch.path.GetPoints(); |
| 778 pPoints[0].m_Flag = FXPT_MOVETO; | 778 pPoints[0].m_Flag = FXPT_MOVETO; |
| 779 for (int i = 1; i < 13; i++) { | 779 for (int i = 1; i < 13; i++) { |
| 780 pPoints[i].m_Flag = FXPT_BEZIERTO; | 780 pPoints[i].m_Flag = FXPT_BEZIERTO; |
| 781 } | 781 } |
| 782 CFX_PointF coords[16]; | 782 CFX_PointF coords[16]; |
| 783 int point_count = bTensor ? 16 : 12; | 783 int point_count = bTensor ? 16 : 12; |
| 784 while (!stream.m_BitStream.IsEOF()) { | 784 while (!stream.m_BitStream.IsEOF()) { |
| 785 FX_DWORD flag = stream.GetFlag(); | 785 uint32_t flag = stream.GetFlag(); |
| 786 int iStartPoint = 0, iStartColor = 0, i = 0; | 786 int iStartPoint = 0, iStartColor = 0, i = 0; |
| 787 if (flag) { | 787 if (flag) { |
| 788 iStartPoint = 4; | 788 iStartPoint = 4; |
| 789 iStartColor = 2; | 789 iStartColor = 2; |
| 790 CFX_PointF tempCoords[4]; | 790 CFX_PointF tempCoords[4]; |
| 791 for (i = 0; i < 4; i++) { | 791 for (i = 0; i < 4; i++) { |
| 792 tempCoords[i] = coords[(flag * 3 + i) % 12]; | 792 tempCoords[i] = coords[(flag * 3 + i) % 12]; |
| 793 } | 793 } |
| 794 FXSYS_memcpy(coords, tempCoords, sizeof(tempCoords)); | 794 FXSYS_memcpy(coords, tempCoords, sizeof(tempCoords)); |
| 795 Coon_Color tempColors[2]; | 795 Coon_Color tempColors[2]; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 m_Options.m_BackColor); | 1134 m_Options.m_BackColor); |
| 1135 } | 1135 } |
| 1136 FX_ARGB fill_argb = GetFillArgb(pPageObj); | 1136 FX_ARGB fill_argb = GetFillArgb(pPageObj); |
| 1137 int clip_width = clip_box.right - clip_box.left; | 1137 int clip_width = clip_box.right - clip_box.left; |
| 1138 int clip_height = clip_box.bottom - clip_box.top; | 1138 int clip_height = clip_box.bottom - clip_box.top; |
| 1139 CFX_DIBitmap screen; | 1139 CFX_DIBitmap screen; |
| 1140 if (!screen.Create(clip_width, clip_height, FXDIB_Argb)) { | 1140 if (!screen.Create(clip_width, clip_height, FXDIB_Argb)) { |
| 1141 return; | 1141 return; |
| 1142 } | 1142 } |
| 1143 screen.Clear(0); | 1143 screen.Clear(0); |
| 1144 FX_DWORD* src_buf = (FX_DWORD*)pPatternBitmap->GetBuffer(); | 1144 uint32_t* src_buf = (uint32_t*)pPatternBitmap->GetBuffer(); |
| 1145 for (int col = min_col; col <= max_col; col++) { | 1145 for (int col = min_col; col <= max_col; col++) { |
| 1146 for (int row = min_row; row <= max_row; row++) { | 1146 for (int row = min_row; row <= max_row; row++) { |
| 1147 int start_x, start_y; | 1147 int start_x, start_y; |
| 1148 if (bAligned) { | 1148 if (bAligned) { |
| 1149 start_x = FXSYS_round(mtPattern2Device.e) + col * width - clip_box.left; | 1149 start_x = FXSYS_round(mtPattern2Device.e) + col * width - clip_box.left; |
| 1150 start_y = FXSYS_round(mtPattern2Device.f) + row * height - clip_box.top; | 1150 start_y = FXSYS_round(mtPattern2Device.f) + row * height - clip_box.top; |
| 1151 } else { | 1151 } else { |
| 1152 FX_FLOAT orig_x = col * pPattern->m_XStep; | 1152 FX_FLOAT orig_x = col * pPattern->m_XStep; |
| 1153 FX_FLOAT orig_y = row * pPattern->m_YStep; | 1153 FX_FLOAT orig_y = row * pPattern->m_YStep; |
| 1154 mtPattern2Device.Transform(orig_x, orig_y); | 1154 mtPattern2Device.Transform(orig_x, orig_y); |
| 1155 start_x = FXSYS_round(orig_x + left_offset) - clip_box.left; | 1155 start_x = FXSYS_round(orig_x + left_offset) - clip_box.left; |
| 1156 start_y = FXSYS_round(orig_y + top_offset) - clip_box.top; | 1156 start_y = FXSYS_round(orig_y + top_offset) - clip_box.top; |
| 1157 } | 1157 } |
| 1158 if (width == 1 && height == 1) { | 1158 if (width == 1 && height == 1) { |
| 1159 if (start_x < 0 || start_x >= clip_box.Width() || start_y < 0 || | 1159 if (start_x < 0 || start_x >= clip_box.Width() || start_y < 0 || |
| 1160 start_y >= clip_box.Height()) { | 1160 start_y >= clip_box.Height()) { |
| 1161 continue; | 1161 continue; |
| 1162 } | 1162 } |
| 1163 FX_DWORD* dest_buf = | 1163 uint32_t* dest_buf = |
| 1164 (FX_DWORD*)(screen.GetBuffer() + screen.GetPitch() * start_y + | 1164 (uint32_t*)(screen.GetBuffer() + screen.GetPitch() * start_y + |
| 1165 start_x * 4); | 1165 start_x * 4); |
| 1166 if (pPattern->m_bColored) { | 1166 if (pPattern->m_bColored) { |
| 1167 *dest_buf = *src_buf; | 1167 *dest_buf = *src_buf; |
| 1168 } else { | 1168 } else { |
| 1169 *dest_buf = (*(uint8_t*)src_buf << 24) | (fill_argb & 0xffffff); | 1169 *dest_buf = (*(uint8_t*)src_buf << 24) | (fill_argb & 0xffffff); |
| 1170 } | 1170 } |
| 1171 } else { | 1171 } else { |
| 1172 if (pPattern->m_bColored) { | 1172 if (pPattern->m_bColored) { |
| 1173 screen.CompositeBitmap(start_x, start_y, width, height, | 1173 screen.CompositeBitmap(start_x, start_y, width, height, |
| 1174 pPatternBitmap, 0, 0); | 1174 pPatternBitmap, 0, 0); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 } | 1212 } |
| 1213 } | 1213 } |
| 1214 if (bStroke) { | 1214 if (bStroke) { |
| 1215 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); | 1215 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); |
| 1216 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { | 1216 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { |
| 1217 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); | 1217 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); |
| 1218 bStroke = FALSE; | 1218 bStroke = FALSE; |
| 1219 } | 1219 } |
| 1220 } | 1220 } |
| 1221 } | 1221 } |
| OLD | NEW |