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

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

Issue 2009803003: Remove default argument from RestoreState() methods. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 6 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/fpdfapi/fpdf_render/render_int.h" 7 #include "core/fpdfapi/fpdf_render/render_int.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern, 952 void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern,
953 const CPDF_PageObject* pPageObj, 953 const CPDF_PageObject* pPageObj,
954 const CFX_Matrix* pObj2Device, 954 const CFX_Matrix* pObj2Device,
955 FX_BOOL bStroke) { 955 FX_BOOL bStroke) {
956 if (!pattern->Load()) 956 if (!pattern->Load())
957 return; 957 return;
958 958
959 m_pDevice->SaveState(); 959 m_pDevice->SaveState();
960 if (pPageObj->IsPath()) { 960 if (pPageObj->IsPath()) {
961 if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke)) { 961 if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke)) {
962 m_pDevice->RestoreState(); 962 m_pDevice->RestoreState(false);
963 return; 963 return;
964 } 964 }
965 } else if (pPageObj->IsImage()) { 965 } else if (pPageObj->IsImage()) {
966 m_pDevice->SetClip_Rect(pPageObj->GetBBox(pObj2Device)); 966 m_pDevice->SetClip_Rect(pPageObj->GetBBox(pObj2Device));
967 } else { 967 } else {
968 return; 968 return;
969 } 969 }
970 FX_RECT rect; 970 FX_RECT rect;
971 if (GetObjectClippedRect(pPageObj, pObj2Device, FALSE, rect)) { 971 if (GetObjectClippedRect(pPageObj, pObj2Device, FALSE, rect)) {
972 m_pDevice->RestoreState(); 972 m_pDevice->RestoreState(false);
973 return; 973 return;
974 } 974 }
975 CFX_Matrix matrix = *pattern->pattern_to_form(); 975 CFX_Matrix matrix = *pattern->pattern_to_form();
976 matrix.Concat(*pObj2Device); 976 matrix.Concat(*pObj2Device);
977 GetScaledMatrix(matrix); 977 GetScaledMatrix(matrix);
978 int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke); 978 int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke);
979 DrawShading(pattern, &matrix, rect, alpha, 979 DrawShading(pattern, &matrix, rect, alpha,
980 m_Options.m_ColorMode == RENDER_COLOR_ALPHA); 980 m_Options.m_ColorMode == RENDER_COLOR_ALPHA);
981 m_pDevice->RestoreState(); 981 m_pDevice->RestoreState(false);
982 } 982 }
983 983
984 void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj, 984 void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj,
985 const CFX_Matrix* pObj2Device) { 985 const CFX_Matrix* pObj2Device) {
986 FX_RECT rect = pShadingObj->GetBBox(pObj2Device); 986 FX_RECT rect = pShadingObj->GetBBox(pObj2Device);
987 FX_RECT clip_box = m_pDevice->GetClipBox(); 987 FX_RECT clip_box = m_pDevice->GetClipBox();
988 rect.Intersect(clip_box); 988 rect.Intersect(clip_box);
989 if (rect.IsEmpty()) 989 if (rect.IsEmpty())
990 return; 990 return;
991 991
992 CFX_Matrix matrix = pShadingObj->m_Matrix; 992 CFX_Matrix matrix = pShadingObj->m_Matrix;
993 matrix.Concat(*pObj2Device); 993 matrix.Concat(*pObj2Device);
994 DrawShading(pShadingObj->m_pShading, &matrix, rect, 994 DrawShading(pShadingObj->m_pShading, &matrix, rect,
995 pShadingObj->m_GeneralState.GetAlpha(FALSE), 995 pShadingObj->m_GeneralState.GetAlpha(FALSE),
996 m_Options.m_ColorMode == RENDER_COLOR_ALPHA); 996 m_Options.m_ColorMode == RENDER_COLOR_ALPHA);
997 } 997 }
998 998
999 void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, 999 void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
1000 const CPDF_PageObject* pPageObj, 1000 const CPDF_PageObject* pPageObj,
1001 const CFX_Matrix* pObj2Device, 1001 const CFX_Matrix* pObj2Device,
1002 FX_BOOL bStroke) { 1002 FX_BOOL bStroke) {
1003 if (!pPattern->Load()) { 1003 if (!pPattern->Load()) {
1004 return; 1004 return;
1005 } 1005 }
1006 m_pDevice->SaveState(); 1006 m_pDevice->SaveState();
1007 if (pPageObj->IsPath()) { 1007 if (pPageObj->IsPath()) {
1008 if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke)) { 1008 if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke)) {
1009 m_pDevice->RestoreState(); 1009 m_pDevice->RestoreState(false);
1010 return; 1010 return;
1011 } 1011 }
1012 } else if (pPageObj->IsImage()) { 1012 } else if (pPageObj->IsImage()) {
1013 m_pDevice->SetClip_Rect(pPageObj->GetBBox(pObj2Device)); 1013 m_pDevice->SetClip_Rect(pPageObj->GetBBox(pObj2Device));
1014 } else { 1014 } else {
1015 return; 1015 return;
1016 } 1016 }
1017 FX_RECT clip_box = m_pDevice->GetClipBox(); 1017 FX_RECT clip_box = m_pDevice->GetClipBox();
1018 if (clip_box.IsEmpty()) { 1018 if (clip_box.IsEmpty()) {
1019 m_pDevice->RestoreState(); 1019 m_pDevice->RestoreState(false);
1020 return; 1020 return;
1021 } 1021 }
1022 CFX_Matrix dCTM = m_pDevice->GetCTM(); 1022 CFX_Matrix dCTM = m_pDevice->GetCTM();
1023 FX_FLOAT sa = FXSYS_fabs(dCTM.a); 1023 FX_FLOAT sa = FXSYS_fabs(dCTM.a);
1024 FX_FLOAT sd = FXSYS_fabs(dCTM.d); 1024 FX_FLOAT sd = FXSYS_fabs(dCTM.d);
1025 clip_box.right = clip_box.left + (int32_t)FXSYS_ceil(clip_box.Width() * sa); 1025 clip_box.right = clip_box.left + (int32_t)FXSYS_ceil(clip_box.Width() * sa);
1026 clip_box.bottom = clip_box.top + (int32_t)FXSYS_ceil(clip_box.Height() * sd); 1026 clip_box.bottom = clip_box.top + (int32_t)FXSYS_ceil(clip_box.Height() * sd);
1027 CFX_Matrix mtPattern2Device = *pPattern->pattern_to_form(); 1027 CFX_Matrix mtPattern2Device = *pPattern->pattern_to_form();
1028 mtPattern2Device.Concat(*pObj2Device); 1028 mtPattern2Device.Concat(*pObj2Device);
1029 GetScaledMatrix(mtPattern2Device); 1029 GetScaledMatrix(mtPattern2Device);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 mtPattern2Device.Transform(orig_x, orig_y); 1077 mtPattern2Device.Transform(orig_x, orig_y);
1078 CFX_Matrix matrix = *pObj2Device; 1078 CFX_Matrix matrix = *pObj2Device;
1079 matrix.Translate(orig_x - mtPattern2Device.e, 1079 matrix.Translate(orig_x - mtPattern2Device.e,
1080 orig_y - mtPattern2Device.f); 1080 orig_y - mtPattern2Device.f);
1081 m_pDevice->SaveState(); 1081 m_pDevice->SaveState();
1082 CPDF_RenderStatus status; 1082 CPDF_RenderStatus status;
1083 status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this, 1083 status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this,
1084 pStates, &m_Options, pPattern->form()->m_Transparency, 1084 pStates, &m_Options, pPattern->form()->m_Transparency,
1085 m_bDropObjects, pFormResource); 1085 m_bDropObjects, pFormResource);
1086 status.RenderObjectList(pPattern->form(), &matrix); 1086 status.RenderObjectList(pPattern->form(), &matrix);
1087 m_pDevice->RestoreState(); 1087 m_pDevice->RestoreState(false);
1088 } 1088 }
1089 m_pDevice->RestoreState(); 1089 m_pDevice->RestoreState(false);
1090 delete pStates; 1090 delete pStates;
1091 return; 1091 return;
1092 } 1092 }
1093 if (bAligned) { 1093 if (bAligned) {
1094 int orig_x = FXSYS_round(mtPattern2Device.e); 1094 int orig_x = FXSYS_round(mtPattern2Device.e);
1095 int orig_y = FXSYS_round(mtPattern2Device.f); 1095 int orig_y = FXSYS_round(mtPattern2Device.f);
1096 min_col = (clip_box.left - orig_x) / width; 1096 min_col = (clip_box.left - orig_x) / width;
1097 if (clip_box.left < orig_x) { 1097 if (clip_box.left < orig_x) {
1098 min_col--; 1098 min_col--;
1099 } 1099 }
(...skipping 17 matching lines...) Expand all
1117 std::unique_ptr<CFX_DIBitmap> pEnlargedBitmap = 1117 std::unique_ptr<CFX_DIBitmap> pEnlargedBitmap =
1118 DrawPatternBitmap(m_pContext->GetDocument(), m_pContext->GetPageCache(), 1118 DrawPatternBitmap(m_pContext->GetDocument(), m_pContext->GetPageCache(),
1119 pPattern, pObj2Device, 8, 8, m_Options.m_Flags); 1119 pPattern, pObj2Device, 8, 8, m_Options.m_Flags);
1120 pPatternBitmap.reset(pEnlargedBitmap->StretchTo(width, height)); 1120 pPatternBitmap.reset(pEnlargedBitmap->StretchTo(width, height));
1121 } else { 1121 } else {
1122 pPatternBitmap = DrawPatternBitmap( 1122 pPatternBitmap = DrawPatternBitmap(
1123 m_pContext->GetDocument(), m_pContext->GetPageCache(), pPattern, 1123 m_pContext->GetDocument(), m_pContext->GetPageCache(), pPattern,
1124 pObj2Device, width, height, m_Options.m_Flags); 1124 pObj2Device, width, height, m_Options.m_Flags);
1125 } 1125 }
1126 if (!pPatternBitmap) { 1126 if (!pPatternBitmap) {
1127 m_pDevice->RestoreState(); 1127 m_pDevice->RestoreState(false);
1128 return; 1128 return;
1129 } 1129 }
1130 if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) { 1130 if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) {
1131 pPatternBitmap->ConvertColorScale(m_Options.m_ForeColor, 1131 pPatternBitmap->ConvertColorScale(m_Options.m_ForeColor,
1132 m_Options.m_BackColor); 1132 m_Options.m_BackColor);
1133 } 1133 }
1134 FX_ARGB fill_argb = GetFillArgb(pPageObj); 1134 FX_ARGB fill_argb = GetFillArgb(pPageObj);
1135 int clip_width = clip_box.right - clip_box.left; 1135 int clip_width = clip_box.right - clip_box.left;
1136 int clip_height = clip_box.bottom - clip_box.top; 1136 int clip_height = clip_box.bottom - clip_box.top;
1137 CFX_DIBitmap screen; 1137 CFX_DIBitmap screen;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 pPatternBitmap.get(), 0, 0); 1171 pPatternBitmap.get(), 0, 0);
1172 } else { 1172 } else {
1173 screen.CompositeMask(start_x, start_y, width, height, 1173 screen.CompositeMask(start_x, start_y, width, height,
1174 pPatternBitmap.get(), fill_argb, 0, 0); 1174 pPatternBitmap.get(), fill_argb, 0, 0);
1175 } 1175 }
1176 } 1176 }
1177 } 1177 }
1178 } 1178 }
1179 CompositeDIBitmap(&screen, clip_box.left, clip_box.top, 0, 255, 1179 CompositeDIBitmap(&screen, clip_box.left, clip_box.top, 0, 255,
1180 FXDIB_BLEND_NORMAL, FALSE); 1180 FXDIB_BLEND_NORMAL, FALSE);
1181 m_pDevice->RestoreState(); 1181 m_pDevice->RestoreState(false);
1182 } 1182 }
1183 1183
1184 void CPDF_RenderStatus::DrawPathWithPattern(const CPDF_PathObject* pPathObj, 1184 void CPDF_RenderStatus::DrawPathWithPattern(const CPDF_PathObject* pPathObj,
1185 const CFX_Matrix* pObj2Device, 1185 const CFX_Matrix* pObj2Device,
1186 CPDF_Color* pColor, 1186 CPDF_Color* pColor,
1187 FX_BOOL bStroke) { 1187 FX_BOOL bStroke) {
1188 CPDF_Pattern* pattern = pColor->GetPattern(); 1188 CPDF_Pattern* pattern = pColor->GetPattern();
1189 if (!pattern) 1189 if (!pattern)
1190 return; 1190 return;
1191 1191
(...skipping 15 matching lines...) Expand all
1207 } 1207 }
1208 } 1208 }
1209 if (bStroke) { 1209 if (bStroke) {
1210 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); 1210 CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor();
1211 if (StrokeColor.IsPattern()) { 1211 if (StrokeColor.IsPattern()) {
1212 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); 1212 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE);
1213 bStroke = FALSE; 1213 bStroke = FALSE;
1214 } 1214 }
1215 } 1215 }
1216 } 1216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698