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

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

Issue 1709393002: Remove PageObject's m_Type and add As<Type> functions (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments 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 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 } 905 }
906 if (bAlphaMode) { 906 if (bAlphaMode) {
907 pBitmap->LoadChannel(FXDIB_Red, pBitmap, FXDIB_Alpha); 907 pBitmap->LoadChannel(FXDIB_Red, pBitmap, FXDIB_Alpha);
908 } 908 }
909 if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) { 909 if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) {
910 pBitmap->ConvertColorScale(m_Options.m_ForeColor, m_Options.m_BackColor); 910 pBitmap->ConvertColorScale(m_Options.m_ForeColor, m_Options.m_BackColor);
911 } 911 }
912 buffer.OutputToDevice(); 912 buffer.OutputToDevice();
913 } 913 }
914 void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern, 914 void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern,
915 CPDF_PageObject* pPageObj, 915 const CPDF_PageObject* pPageObj,
916 const CFX_Matrix* pObj2Device, 916 const CFX_Matrix* pObj2Device,
917 FX_BOOL bStroke) { 917 FX_BOOL bStroke) {
918 if (!pattern->Load()) { 918 if (!pattern->Load()) {
919 return; 919 return;
920 } 920 }
921 m_pDevice->SaveState(); 921 m_pDevice->SaveState();
922 if (pPageObj->m_Type == CPDF_PageObject::PATH) { 922 if (pPageObj->IsPath()) {
923 if (!SelectClipPath((CPDF_PathObject*)pPageObj, pObj2Device, bStroke)) { 923 if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke)) {
924 m_pDevice->RestoreState(); 924 m_pDevice->RestoreState();
925 return; 925 return;
926 } 926 }
927 } else if (pPageObj->m_Type == CPDF_PageObject::IMAGE) { 927 } else if (pPageObj->IsImage()) {
928 FX_RECT rect = pPageObj->GetBBox(pObj2Device); 928 FX_RECT rect = pPageObj->GetBBox(pObj2Device);
929 m_pDevice->SetClip_Rect(&rect); 929 m_pDevice->SetClip_Rect(&rect);
930 } else { 930 } else {
931 return; 931 return;
932 } 932 }
933 FX_RECT rect; 933 FX_RECT rect;
934 if (GetObjectClippedRect(pPageObj, pObj2Device, FALSE, rect)) { 934 if (GetObjectClippedRect(pPageObj, pObj2Device, FALSE, rect)) {
935 m_pDevice->RestoreState(); 935 m_pDevice->RestoreState();
936 return; 936 return;
937 } 937 }
938 CFX_Matrix matrix = pattern->m_Pattern2Form; 938 CFX_Matrix matrix = pattern->m_Pattern2Form;
939 matrix.Concat(*pObj2Device); 939 matrix.Concat(*pObj2Device);
940 GetScaledMatrix(matrix); 940 GetScaledMatrix(matrix);
941 int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke); 941 int alpha = pPageObj->m_GeneralState.GetAlpha(bStroke);
942 DrawShading(pattern, &matrix, rect, alpha, 942 DrawShading(pattern, &matrix, rect, alpha,
943 m_Options.m_ColorMode == RENDER_COLOR_ALPHA); 943 m_Options.m_ColorMode == RENDER_COLOR_ALPHA);
944 m_pDevice->RestoreState(); 944 m_pDevice->RestoreState();
945 } 945 }
946 FX_BOOL CPDF_RenderStatus::ProcessShading(CPDF_ShadingObject* pShadingObj, 946 FX_BOOL CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj,
947 const CFX_Matrix* pObj2Device) { 947 const CFX_Matrix* pObj2Device) {
948 FX_RECT rect = pShadingObj->GetBBox(pObj2Device); 948 FX_RECT rect = pShadingObj->GetBBox(pObj2Device);
949 FX_RECT clip_box = m_pDevice->GetClipBox(); 949 FX_RECT clip_box = m_pDevice->GetClipBox();
950 rect.Intersect(clip_box); 950 rect.Intersect(clip_box);
951 if (rect.IsEmpty()) { 951 if (rect.IsEmpty()) {
952 return TRUE; 952 return TRUE;
953 } 953 }
954 CFX_Matrix matrix = pShadingObj->m_Matrix; 954 CFX_Matrix matrix = pShadingObj->m_Matrix;
955 matrix.Concat(*pObj2Device); 955 matrix.Concat(*pObj2Device);
956 DrawShading(pShadingObj->m_pShading, &matrix, rect, 956 DrawShading(pShadingObj->m_pShading, &matrix, rect,
(...skipping 30 matching lines...) Expand all
987 options.m_ColorMode = RENDER_COLOR_ALPHA; 987 options.m_ColorMode = RENDER_COLOR_ALPHA;
988 } 988 }
989 flags |= RENDER_FORCE_HALFTONE; 989 flags |= RENDER_FORCE_HALFTONE;
990 options.m_Flags = flags; 990 options.m_Flags = flags;
991 CPDF_RenderContext context(pDoc, pCache); 991 CPDF_RenderContext context(pDoc, pCache);
992 context.AppendLayer(pPattern->m_pForm, &mtPattern2Bitmap); 992 context.AppendLayer(pPattern->m_pForm, &mtPattern2Bitmap);
993 context.Render(&bitmap_device, &options, nullptr); 993 context.Render(&bitmap_device, &options, nullptr);
994 return pBitmap; 994 return pBitmap;
995 } 995 }
996 void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, 996 void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
997 CPDF_PageObject* pPageObj, 997 const CPDF_PageObject* pPageObj,
998 const CFX_Matrix* pObj2Device, 998 const CFX_Matrix* pObj2Device,
999 FX_BOOL bStroke) { 999 FX_BOOL bStroke) {
1000 if (!pPattern->Load()) { 1000 if (!pPattern->Load()) {
1001 return; 1001 return;
1002 } 1002 }
1003 m_pDevice->SaveState(); 1003 m_pDevice->SaveState();
1004 if (pPageObj->m_Type == CPDF_PageObject::PATH) { 1004 if (pPageObj->IsPath()) {
1005 if (!SelectClipPath((CPDF_PathObject*)pPageObj, pObj2Device, bStroke)) { 1005 if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke)) {
1006 m_pDevice->RestoreState(); 1006 m_pDevice->RestoreState();
1007 return; 1007 return;
1008 } 1008 }
1009 } else if (pPageObj->m_Type == CPDF_PageObject::IMAGE) { 1009 } else if (pPageObj->IsImage()) {
1010 FX_RECT rect = pPageObj->GetBBox(pObj2Device); 1010 FX_RECT rect = pPageObj->GetBBox(pObj2Device);
1011 m_pDevice->SetClip_Rect(&rect); 1011 m_pDevice->SetClip_Rect(&rect);
1012 } else { 1012 } else {
1013 return; 1013 return;
1014 } 1014 }
1015 FX_RECT clip_box = m_pDevice->GetClipBox(); 1015 FX_RECT clip_box = m_pDevice->GetClipBox();
1016 if (clip_box.IsEmpty()) { 1016 if (clip_box.IsEmpty()) {
1017 m_pDevice->RestoreState(); 1017 m_pDevice->RestoreState();
1018 return; 1018 return;
1019 } 1019 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 fill_argb, 0, 0); 1172 fill_argb, 0, 0);
1173 } 1173 }
1174 } 1174 }
1175 } 1175 }
1176 } 1176 }
1177 CompositeDIBitmap(&screen, clip_box.left, clip_box.top, 0, 255, 1177 CompositeDIBitmap(&screen, clip_box.left, clip_box.top, 0, 255,
1178 FXDIB_BLEND_NORMAL, FALSE); 1178 FXDIB_BLEND_NORMAL, FALSE);
1179 m_pDevice->RestoreState(); 1179 m_pDevice->RestoreState();
1180 delete pPatternBitmap; 1180 delete pPatternBitmap;
1181 } 1181 }
1182 void CPDF_RenderStatus::DrawPathWithPattern(CPDF_PathObject* pPathObj, 1182 void CPDF_RenderStatus::DrawPathWithPattern(const CPDF_PathObject* pPathObj,
1183 const CFX_Matrix* pObj2Device, 1183 const CFX_Matrix* pObj2Device,
1184 CPDF_Color* pColor, 1184 CPDF_Color* pColor,
1185 FX_BOOL bStroke) { 1185 FX_BOOL bStroke) {
1186 CPDF_Pattern* pattern = pColor->GetPattern(); 1186 CPDF_Pattern* pattern = pColor->GetPattern();
1187 if (!pattern) { 1187 if (!pattern) {
1188 return; 1188 return;
1189 } 1189 }
1190 if (pattern->m_PatternType == CPDF_Pattern::TILING) { 1190 if (pattern->m_PatternType == CPDF_Pattern::TILING) {
1191 DrawTilingPattern(static_cast<CPDF_TilingPattern*>(pattern), pPathObj, 1191 DrawTilingPattern(static_cast<CPDF_TilingPattern*>(pattern), pPathObj,
1192 pObj2Device, bStroke); 1192 pObj2Device, bStroke);
1193 } else { 1193 } else {
1194 DrawShadingPattern(static_cast<CPDF_ShadingPattern*>(pattern), pPathObj, 1194 DrawShadingPattern(static_cast<CPDF_ShadingPattern*>(pattern), pPathObj,
1195 pObj2Device, bStroke); 1195 pObj2Device, bStroke);
1196 } 1196 }
1197 } 1197 }
1198 void CPDF_RenderStatus::ProcessPathPattern(CPDF_PathObject* pPathObj, 1198 void CPDF_RenderStatus::ProcessPathPattern(const CPDF_PathObject* pPathObj,
1199 const CFX_Matrix* pObj2Device, 1199 const CFX_Matrix* pObj2Device,
1200 int& filltype, 1200 int& filltype,
1201 FX_BOOL& bStroke) { 1201 FX_BOOL& bStroke) {
1202 if (filltype) { 1202 if (filltype) {
1203 CPDF_Color& FillColor = *pPathObj->m_ColorState.GetFillColor(); 1203 CPDF_Color& FillColor = *pPathObj->m_ColorState.GetFillColor();
1204 if (FillColor.m_pCS && FillColor.m_pCS->GetFamily() == PDFCS_PATTERN) { 1204 if (FillColor.m_pCS && FillColor.m_pCS->GetFamily() == PDFCS_PATTERN) {
1205 DrawPathWithPattern(pPathObj, pObj2Device, &FillColor, FALSE); 1205 DrawPathWithPattern(pPathObj, pObj2Device, &FillColor, FALSE);
1206 filltype = 0; 1206 filltype = 0;
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.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) { 1211 if (StrokeColor.m_pCS && StrokeColor.m_pCS->GetFamily() == PDFCS_PATTERN) {
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
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp ('k') | core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698