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

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

Issue 1402413004: Add type cast definitions for CPDF_Stream. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month 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 "../../../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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 R += r_unit; 401 R += r_unit;
402 G += g_unit; 402 G += g_unit;
403 B += b_unit; 403 B += b_unit;
404 FXARGB_SETDIB(dib_buf, 404 FXARGB_SETDIB(dib_buf,
405 FXARGB_MAKE(alpha, (int32_t)(R * 255), (int32_t)(G * 255), 405 FXARGB_MAKE(alpha, (int32_t)(R * 255), (int32_t)(G * 255),
406 (int32_t)(B * 255))); 406 (int32_t)(B * 255)));
407 dib_buf += 4; 407 dib_buf += 4;
408 } 408 }
409 } 409 }
410 } 410 }
411 static void _DrawFreeGouraudShading(CFX_DIBitmap* pBitmap, 411 static void _DrawFreeGouraudShading(CFX_DIBitmap* pBitmap,
Tom Sepez 2015/10/22 17:16:45 nit: as long as you're mucking with this, can we l
dsinclair 2015/10/22 17:42:56 Done.
412 CFX_AffineMatrix* pObject2Bitmap, 412 CFX_AffineMatrix* pObject2Bitmap,
413 CPDF_Stream* pShadingStream, 413 CPDF_Stream* pShadingStream,
414 CPDF_Function** pFuncs, 414 CPDF_Function** pFuncs,
415 int nFuncs, 415 int nFuncs,
416 CPDF_ColorSpace* pCS, 416 CPDF_ColorSpace* pCS,
417 int alpha) { 417 int alpha) {
418 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); 418 ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
419 if (pShadingStream->GetType() != PDFOBJ_STREAM) { 419 if (!pShadingStream->IsStream())
Tom Sepez 2015/10/22 17:16:45 Can a stream be not IsStream() ? Either this shou
dsinclair 2015/10/22 17:42:56 Done. Probably bad casts in the past.
420 return; 420 return;
421 } 421
422 CPDF_MeshStream stream; 422 CPDF_MeshStream stream;
423 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) { 423 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS))
424 return; 424 return;
425 } 425
426 CPDF_MeshVertex triangle[3]; 426 CPDF_MeshVertex triangle[3];
427 FXSYS_memset(triangle, 0, sizeof(triangle)); 427 FXSYS_memset(triangle, 0, sizeof(triangle));
428 428
429 while (!stream.m_BitStream.IsEOF()) { 429 while (!stream.m_BitStream.IsEOF()) {
430 CPDF_MeshVertex vertex; 430 CPDF_MeshVertex vertex;
431 FX_DWORD flag = stream.GetVertex(vertex, pObject2Bitmap); 431 FX_DWORD flag = stream.GetVertex(vertex, pObject2Bitmap);
432 if (flag == 0) { 432 if (flag == 0) {
433 triangle[0] = vertex; 433 triangle[0] = vertex;
434 for (int j = 1; j < 3; j++) { 434 for (int j = 1; j < 3; j++) {
435 stream.GetVertex(triangle[j], pObject2Bitmap); 435 stream.GetVertex(triangle[j], pObject2Bitmap);
436 } 436 }
437 } else { 437 } else {
438 if (flag == 1) { 438 if (flag == 1) {
439 triangle[0] = triangle[1]; 439 triangle[0] = triangle[1];
440 } 440 }
441 triangle[1] = triangle[2]; 441 triangle[1] = triangle[2];
442 triangle[2] = vertex; 442 triangle[2] = vertex;
443 } 443 }
444 _DrawGouraud(pBitmap, alpha, triangle); 444 _DrawGouraud(pBitmap, alpha, triangle);
445 } 445 }
446 } 446 }
447 static void _DrawLatticeGouraudShading(CFX_DIBitmap* pBitmap, 447 static void _DrawLatticeGouraudShading(CFX_DIBitmap* pBitmap,
448 CFX_AffineMatrix* pObject2Bitmap, 448 CFX_AffineMatrix* pObject2Bitmap,
449 CPDF_Stream* pShadingStream, 449 CPDF_Stream* pShadingStream,
450 CPDF_Function** pFuncs, 450 CPDF_Function** pFuncs,
451 int nFuncs, 451 int nFuncs,
452 CPDF_ColorSpace* pCS, 452 CPDF_ColorSpace* pCS,
453 int alpha) { 453 int alpha) {
454 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); 454 ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
455 if (pShadingStream->GetType() != PDFOBJ_STREAM) { 455 if (!pShadingStream->IsStream())
Tom Sepez 2015/10/22 17:16:45 ditto
dsinclair 2015/10/22 17:42:56 Done.
456 return; 456 return;
457 } 457
458 int row_verts = pShadingStream->GetDict()->GetInteger("VerticesPerRow"); 458 int row_verts = pShadingStream->GetDict()->GetInteger("VerticesPerRow");
459 if (row_verts < 2) { 459 if (row_verts < 2)
460 return; 460 return;
461 } 461
462 CPDF_MeshStream stream; 462 CPDF_MeshStream stream;
463 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) { 463 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS))
464 return; 464 return;
465 } 465
466 CPDF_MeshVertex* vertex = FX_Alloc2D(CPDF_MeshVertex, row_verts, 2); 466 CPDF_MeshVertex* vertex = FX_Alloc2D(CPDF_MeshVertex, row_verts, 2);
467 if (!stream.GetVertexRow(vertex, row_verts, pObject2Bitmap)) { 467 if (!stream.GetVertexRow(vertex, row_verts, pObject2Bitmap)) {
468 FX_Free(vertex); 468 FX_Free(vertex);
469 return; 469 return;
470 } 470 }
471 int last_index = 0; 471 int last_index = 0;
472 while (1) { 472 while (1) {
473 CPDF_MeshVertex* last_row = vertex + last_index * row_verts; 473 CPDF_MeshVertex* last_row = vertex + last_index * row_verts;
474 CPDF_MeshVertex* this_row = vertex + (1 - last_index) * row_verts; 474 CPDF_MeshVertex* this_row = vertex + (1 - last_index) * row_verts;
475 if (!stream.GetVertexRow(this_row, row_verts, pObject2Bitmap)) { 475 if (!stream.GetVertexRow(this_row, row_verts, pObject2Bitmap)) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 static void _DrawCoonPatchMeshes(FX_BOOL bTensor, 751 static void _DrawCoonPatchMeshes(FX_BOOL bTensor,
752 CFX_DIBitmap* pBitmap, 752 CFX_DIBitmap* pBitmap,
753 CFX_AffineMatrix* pObject2Bitmap, 753 CFX_AffineMatrix* pObject2Bitmap,
754 CPDF_Stream* pShadingStream, 754 CPDF_Stream* pShadingStream,
755 CPDF_Function** pFuncs, 755 CPDF_Function** pFuncs,
756 int nFuncs, 756 int nFuncs,
757 CPDF_ColorSpace* pCS, 757 CPDF_ColorSpace* pCS,
758 int fill_mode, 758 int fill_mode,
759 int alpha) { 759 int alpha) {
760 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); 760 ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
761 if (pShadingStream->GetType() != PDFOBJ_STREAM) { 761 if (!pShadingStream->IsStream())
Tom Sepez 2015/10/22 17:16:45 ditto ditto
dsinclair 2015/10/22 17:42:56 Done.
762 return; 762 return;
763 } 763
764 CFX_FxgeDevice device; 764 CFX_FxgeDevice device;
765 device.Attach(pBitmap); 765 device.Attach(pBitmap);
766 CPDF_MeshStream stream; 766 CPDF_MeshStream stream;
767 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) { 767 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS))
768 return; 768 return;
769 } 769 if (!_CheckCoonTensorPara(stream))
770
771 if (!_CheckCoonTensorPara(stream)) {
772 return; 770 return;
773 }
774 771
775 CPDF_PatchDrawer patch; 772 CPDF_PatchDrawer patch;
776 patch.alpha = alpha; 773 patch.alpha = alpha;
777 patch.pDevice = &device; 774 patch.pDevice = &device;
778 patch.fill_mode = fill_mode; 775 patch.fill_mode = fill_mode;
779 patch.path.SetPointCount(13); 776 patch.path.SetPointCount(13);
780 FX_PATHPOINT* pPoints = patch.path.GetPoints(); 777 FX_PATHPOINT* pPoints = patch.path.GetPoints();
781 pPoints[0].m_Flag = FXPT_MOVETO; 778 pPoints[0].m_Flag = FXPT_MOVETO;
782 for (int i = 1; i < 13; i++) { 779 for (int i = 1; i < 13; i++) {
783 pPoints[i].m_Flag = FXPT_BEZIERTO; 780 pPoints[i].m_Flag = FXPT_BEZIERTO;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 case 2: 881 case 2:
885 _DrawAxialShading(pBitmap, &FinalMatrix, pDict, pFuncs, nFuncs, 882 _DrawAxialShading(pBitmap, &FinalMatrix, pDict, pFuncs, nFuncs,
886 pColorSpace, alpha); 883 pColorSpace, alpha);
887 break; 884 break;
888 case 3: 885 case 3:
889 _DrawRadialShading(pBitmap, &FinalMatrix, pDict, pFuncs, nFuncs, 886 _DrawRadialShading(pBitmap, &FinalMatrix, pDict, pFuncs, nFuncs,
890 pColorSpace, alpha); 887 pColorSpace, alpha);
891 break; 888 break;
892 case 4: { 889 case 4: {
893 _DrawFreeGouraudShading(pBitmap, &FinalMatrix, 890 _DrawFreeGouraudShading(pBitmap, &FinalMatrix,
894 (CPDF_Stream*)pPattern->m_pShadingObj, pFuncs, 891 ToStream(pPattern->m_pShadingObj), pFuncs, nFuncs,
895 nFuncs, pColorSpace, alpha); 892 pColorSpace, alpha);
896 } break; 893 } break;
897 case 5: { 894 case 5: {
898 _DrawLatticeGouraudShading(pBitmap, &FinalMatrix, 895 _DrawLatticeGouraudShading(pBitmap, &FinalMatrix,
899 (CPDF_Stream*)pPattern->m_pShadingObj, pFuncs, 896 ToStream(pPattern->m_pShadingObj), pFuncs,
900 nFuncs, pColorSpace, alpha); 897 nFuncs, pColorSpace, alpha);
901 } break; 898 } break;
902 case 6: 899 case 6:
903 case 7: { 900 case 7: {
904 _DrawCoonPatchMeshes(pPattern->m_ShadingType - 6, pBitmap, &FinalMatrix, 901 _DrawCoonPatchMeshes(pPattern->m_ShadingType - 6, pBitmap, &FinalMatrix,
905 (CPDF_Stream*)pPattern->m_pShadingObj, pFuncs, 902 ToStream(pPattern->m_pShadingObj), pFuncs, nFuncs,
906 nFuncs, pColorSpace, fill_mode, alpha); 903 pColorSpace, fill_mode, alpha);
907 } break; 904 } break;
908 } 905 }
909 if (bAlphaMode) { 906 if (bAlphaMode) {
910 pBitmap->LoadChannel(FXDIB_Red, pBitmap, FXDIB_Alpha); 907 pBitmap->LoadChannel(FXDIB_Red, pBitmap, FXDIB_Alpha);
911 } 908 }
912 if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) { 909 if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) {
913 pBitmap->ConvertColorScale(m_Options.m_ForeColor, m_Options.m_BackColor); 910 pBitmap->ConvertColorScale(m_Options.m_ForeColor, m_Options.m_BackColor);
914 } 911 }
915 buffer.OutputToDevice(); 912 buffer.OutputToDevice();
916 } 913 }
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 } 1209 }
1213 } 1210 }
1214 if (bStroke) { 1211 if (bStroke) {
1215 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); 1212 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor();
1216 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { 1213 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) {
1217 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); 1214 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE);
1218 bStroke = FALSE; 1215 bStroke = FALSE;
1219 } 1216 }
1220 } 1217 }
1221 } 1218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698