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

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

Issue 2303553002: Make CPDF_GeneralState have a CPDF_GeneralStateData (Closed)
Patch Set: Move functions .cpp file Created 4 years, 3 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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 return; 954 return;
955 } 955 }
956 FX_RECT rect; 956 FX_RECT rect;
957 if (GetObjectClippedRect(pPageObj, pObj2Device, FALSE, rect)) { 957 if (GetObjectClippedRect(pPageObj, pObj2Device, FALSE, rect)) {
958 m_pDevice->RestoreState(false); 958 m_pDevice->RestoreState(false);
959 return; 959 return;
960 } 960 }
961 CFX_Matrix matrix = *pattern->pattern_to_form(); 961 CFX_Matrix matrix = *pattern->pattern_to_form();
962 matrix.Concat(*pObj2Device); 962 matrix.Concat(*pObj2Device);
963 GetScaledMatrix(matrix); 963 GetScaledMatrix(matrix);
964 int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke); 964 int alpha =
965 FXSYS_round(255 * (bStroke ? pPageObj->m_GeneralState.GetStrokeAlpha()
dsinclair 2016/09/01 19:35:52 Why does this and the below change?
Tom Sepez 2016/09/01 20:01:48 They are inconsistent about whether the API to the
966 : pPageObj->m_GeneralState.GetFillAlpha()));
965 DrawShading(pattern, &matrix, rect, alpha, 967 DrawShading(pattern, &matrix, rect, alpha,
966 m_Options.m_ColorMode == RENDER_COLOR_ALPHA); 968 m_Options.m_ColorMode == RENDER_COLOR_ALPHA);
967 m_pDevice->RestoreState(false); 969 m_pDevice->RestoreState(false);
968 } 970 }
969 971
970 void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj, 972 void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj,
971 const CFX_Matrix* pObj2Device) { 973 const CFX_Matrix* pObj2Device) {
972 FX_RECT rect = pShadingObj->GetBBox(pObj2Device); 974 FX_RECT rect = pShadingObj->GetBBox(pObj2Device);
973 FX_RECT clip_box = m_pDevice->GetClipBox(); 975 FX_RECT clip_box = m_pDevice->GetClipBox();
974 rect.Intersect(clip_box); 976 rect.Intersect(clip_box);
975 if (rect.IsEmpty()) 977 if (rect.IsEmpty())
976 return; 978 return;
977 979
978 CFX_Matrix matrix = pShadingObj->m_Matrix; 980 CFX_Matrix matrix = pShadingObj->m_Matrix;
979 matrix.Concat(*pObj2Device); 981 matrix.Concat(*pObj2Device);
980 DrawShading(pShadingObj->m_pShading, &matrix, rect, 982 DrawShading(pShadingObj->m_pShading, &matrix, rect,
981 pShadingObj->m_GeneralState.GetAlpha(FALSE), 983 FXSYS_round(255 * pShadingObj->m_GeneralState.GetFillAlpha()),
982 m_Options.m_ColorMode == RENDER_COLOR_ALPHA); 984 m_Options.m_ColorMode == RENDER_COLOR_ALPHA);
983 } 985 }
984 986
985 void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, 987 void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
986 const CPDF_PageObject* pPageObj, 988 CPDF_PageObject* pPageObj,
987 const CFX_Matrix* pObj2Device, 989 const CFX_Matrix* pObj2Device,
988 FX_BOOL bStroke) { 990 FX_BOOL bStroke) {
989 if (!pPattern->Load()) { 991 if (!pPattern->Load()) {
990 return; 992 return;
991 } 993 }
992 m_pDevice->SaveState(); 994 m_pDevice->SaveState();
993 if (pPageObj->IsPath()) { 995 if (pPageObj->IsPath()) {
994 if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke)) { 996 if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke)) {
995 m_pDevice->RestoreState(false); 997 m_pDevice->RestoreState(false);
996 return; 998 return;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 pPatternBitmap.get(), fill_argb, 0, 0); 1162 pPatternBitmap.get(), fill_argb, 0, 0);
1161 } 1163 }
1162 } 1164 }
1163 } 1165 }
1164 } 1166 }
1165 CompositeDIBitmap(&screen, clip_box.left, clip_box.top, 0, 255, 1167 CompositeDIBitmap(&screen, clip_box.left, clip_box.top, 0, 255,
1166 FXDIB_BLEND_NORMAL, FALSE); 1168 FXDIB_BLEND_NORMAL, FALSE);
1167 m_pDevice->RestoreState(false); 1169 m_pDevice->RestoreState(false);
1168 } 1170 }
1169 1171
1170 void CPDF_RenderStatus::DrawPathWithPattern(const CPDF_PathObject* pPathObj, 1172 void CPDF_RenderStatus::DrawPathWithPattern(CPDF_PathObject* pPathObj,
1171 const CFX_Matrix* pObj2Device, 1173 const CFX_Matrix* pObj2Device,
1172 const CPDF_Color* pColor, 1174 const CPDF_Color* pColor,
1173 FX_BOOL bStroke) { 1175 FX_BOOL bStroke) {
1174 CPDF_Pattern* pattern = pColor->GetPattern(); 1176 CPDF_Pattern* pattern = pColor->GetPattern();
1175 if (!pattern) 1177 if (!pattern)
1176 return; 1178 return;
1177 1179
1178 if (CPDF_TilingPattern* pTilingPattern = pattern->AsTilingPattern()) 1180 if (CPDF_TilingPattern* pTilingPattern = pattern->AsTilingPattern())
1179 DrawTilingPattern(pTilingPattern, pPathObj, pObj2Device, bStroke); 1181 DrawTilingPattern(pTilingPattern, pPathObj, pObj2Device, bStroke);
1180 else if (CPDF_ShadingPattern* pShadingPattern = pattern->AsShadingPattern()) 1182 else if (CPDF_ShadingPattern* pShadingPattern = pattern->AsShadingPattern())
1181 DrawShadingPattern(pShadingPattern, pPathObj, pObj2Device, bStroke); 1183 DrawShadingPattern(pShadingPattern, pPathObj, pObj2Device, bStroke);
1182 } 1184 }
1183 1185
1184 void CPDF_RenderStatus::ProcessPathPattern(const CPDF_PathObject* pPathObj, 1186 void CPDF_RenderStatus::ProcessPathPattern(CPDF_PathObject* pPathObj,
1185 const CFX_Matrix* pObj2Device, 1187 const CFX_Matrix* pObj2Device,
1186 int& filltype, 1188 int& filltype,
1187 FX_BOOL& bStroke) { 1189 FX_BOOL& bStroke) {
1188 if (filltype) { 1190 if (filltype) {
1189 const CPDF_Color& FillColor = *pPathObj->m_ColorState.GetFillColor(); 1191 const CPDF_Color& FillColor = *pPathObj->m_ColorState.GetFillColor();
1190 if (FillColor.IsPattern()) { 1192 if (FillColor.IsPattern()) {
1191 DrawPathWithPattern(pPathObj, pObj2Device, &FillColor, FALSE); 1193 DrawPathWithPattern(pPathObj, pObj2Device, &FillColor, FALSE);
1192 filltype = 0; 1194 filltype = 0;
1193 } 1195 }
1194 } 1196 }
1195 if (bStroke) { 1197 if (bStroke) {
1196 const CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor(); 1198 const CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor();
1197 if (StrokeColor.IsPattern()) { 1199 if (StrokeColor.IsPattern()) {
1198 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE); 1200 DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE);
1199 bStroke = FALSE; 1201 bStroke = FALSE;
1200 } 1202 }
1201 } 1203 }
1202 } 1204 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_render/fpdf_render_image.cpp ('k') | core/fpdfapi/fpdf_render/fpdf_render_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698