Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp

Issue 1726893002: Remove FXSYS_MulDiv(a, b, c). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/src/fpdfapi/fpdf_render/render_int.h" 7 #include "core/src/fpdfapi/fpdf_render/render_int.h"
8 8
9 #include "core/include/fpdfapi/fpdf_pageobj.h" 9 #include "core/include/fpdfapi/fpdf_pageobj.h"
10 #include "core/include/fpdfapi/fpdf_render.h" 10 #include "core/include/fpdfapi/fpdf_render.h"
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 312 }
313 if (y1 < y2) { 313 if (y1 < y2) {
314 if (y < y1 || y > y2) { 314 if (y < y1 || y > y2) {
315 return FALSE; 315 return FALSE;
316 } 316 }
317 } else { 317 } else {
318 if (y < y2 || y > y1) { 318 if (y < y2 || y > y1) {
319 return FALSE; 319 return FALSE;
320 } 320 }
321 } 321 }
322 x = x1 + FXSYS_MulDiv(x2 - x1, y - y1, y2 - y1); 322 x = x1 + ((x2 - x1) * (y - y1) / (y2 - y1));
323 return TRUE; 323 return TRUE;
324 } 324 }
325 static void DrawGouraud(CFX_DIBitmap* pBitmap, 325 static void DrawGouraud(CFX_DIBitmap* pBitmap,
326 int alpha, 326 int alpha,
327 CPDF_MeshVertex triangle[3]) { 327 CPDF_MeshVertex triangle[3]) {
328 FX_FLOAT min_y = triangle[0].y, max_y = triangle[0].y; 328 FX_FLOAT min_y = triangle[0].y, max_y = triangle[0].y;
329 for (int i = 1; i < 3; i++) { 329 for (int i = 1; i < 3; i++) {
330 if (min_y > triangle[i].y) { 330 if (min_y > triangle[i].y) {
331 min_y = triangle[i].y; 331 min_y = triangle[i].y;
332 } 332 }
(...skipping 15 matching lines...) Expand all
348 int nIntersects = 0; 348 int nIntersects = 0;
349 FX_FLOAT inter_x[3], r[3], g[3], b[3]; 349 FX_FLOAT inter_x[3], r[3], g[3], b[3];
350 for (int i = 0; i < 3; i++) { 350 for (int i = 0; i < 3; i++) {
351 CPDF_MeshVertex& vertex1 = triangle[i]; 351 CPDF_MeshVertex& vertex1 = triangle[i];
352 CPDF_MeshVertex& vertex2 = triangle[(i + 1) % 3]; 352 CPDF_MeshVertex& vertex2 = triangle[(i + 1) % 3];
353 FX_BOOL bIntersect = _GetScanlineIntersect( 353 FX_BOOL bIntersect = _GetScanlineIntersect(
354 y, vertex1.x, vertex1.y, vertex2.x, vertex2.y, inter_x[nIntersects]); 354 y, vertex1.x, vertex1.y, vertex2.x, vertex2.y, inter_x[nIntersects]);
355 if (!bIntersect) { 355 if (!bIntersect) {
356 continue; 356 continue;
357 } 357 }
358 r[nIntersects] = 358
359 vertex1.r + FXSYS_MulDiv(vertex2.r - vertex1.r, y - vertex1.y, 359 FX_FLOAT y_dist = (y - vertex1.y) / (vertex2.y - vertex1.y);
360 vertex2.y - vertex1.y); 360 r[nIntersects] = vertex1.r + ((vertex2.r - vertex1.r) * y_dist);
361 g[nIntersects] = 361 g[nIntersects] = vertex1.g + ((vertex2.g - vertex1.g) * y_dist);
362 vertex1.g + FXSYS_MulDiv(vertex2.g - vertex1.g, y - vertex1.y, 362 b[nIntersects] = vertex1.b + ((vertex2.b - vertex1.b) * y_dist);
363 vertex2.y - vertex1.y);
364 b[nIntersects] =
365 vertex1.b + FXSYS_MulDiv(vertex2.b - vertex1.b, y - vertex1.y,
366 vertex2.y - vertex1.y);
367 nIntersects++; 363 nIntersects++;
368 } 364 }
369 if (nIntersects != 2) { 365 if (nIntersects != 2) {
370 continue; 366 continue;
371 } 367 }
372 int min_x, max_x, start_index, end_index; 368 int min_x, max_x, start_index, end_index;
373 if (inter_x[0] < inter_x[1]) { 369 if (inter_x[0] < inter_x[1]) {
374 min_x = (int)FXSYS_floor(inter_x[0]); 370 min_x = (int)FXSYS_floor(inter_x[0]);
375 max_x = (int)FXSYS_ceil(inter_x[1]); 371 max_x = (int)FXSYS_ceil(inter_x[1]);
376 start_index = 0; 372 start_index = 0;
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 } 1202 }
1207 } 1203 }
1208 if (bStroke) { 1204 if (bStroke) {
1209 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); 1205 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor();
1210 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { 1206 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) {
1211 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); 1207 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE);
1212 bStroke = FALSE; 1208 bStroke = FALSE;
1213 } 1209 }
1214 } 1210 }
1215 } 1211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698