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

Unified Diff: core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp

Issue 1418623011: Give names to the shading types (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
index 7b04d8cd3375139136db8654b8e5e67a247964c5..7a314062f6048c6232a3001ae5b8a8c55c0016dc 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
@@ -78,7 +78,7 @@ CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc,
} else {
m_pShadingObj = pPatternObj;
}
- m_ShadingType = 0;
+ m_ShadingType = kInvalidShading;
m_pCS = NULL;
m_nFuncs = 0;
for (int i = 0; i < 4; i++) {
@@ -98,15 +98,37 @@ void CPDF_ShadingPattern::Clear() {
if (pCS && m_pDocument) {
m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
}
- m_ShadingType = 0;
+ m_ShadingType = kInvalidShading;
m_pCS = NULL;
m_pCountedCS = NULL;
m_nFuncs = 0;
}
+
+static ShadingType ToShadingType(int type) {
Tom Sepez 2015/10/27 00:43:16 Can we avoid this?
dsinclair 2015/10/27 02:11:30 Done.
+ switch (type) {
+ case 1:
+ return kFunctionBasedShading;
+ case 2:
+ return kAxialShading;
+ case 3:
+ return kRadialShading;
+ case 4:
+ return kFreeFormGouraudTriangleMeshShading;
+ case 5:
+ return kLatticeFormGouraudTriangleMeshShading;
+ case 6:
+ return kCoonsPatchMeshShading;
+ case 7:
+ return kTensorProductPatchMeshShading;
+ default:
+ return kInvalidShading;
+ }
+}
+
FX_BOOL CPDF_ShadingPattern::Load() {
- if (m_ShadingType != 0) {
+ if (m_ShadingType != kInvalidShading)
return TRUE;
- }
+
CPDF_Dictionary* pShadingDict =
m_pShadingObj ? m_pShadingObj->GetDict() : NULL;
if (pShadingDict == NULL) {
@@ -139,7 +161,9 @@ FX_BOOL CPDF_ShadingPattern::Load() {
if (m_pCS) {
m_pCountedCS = pDocPageData->FindColorSpacePtr(m_pCS->GetArray());
}
- m_ShadingType = pShadingDict->GetInteger(FX_BSTRC("ShadingType"));
+ m_ShadingType =
+ ToShadingType(pShadingDict->GetInteger(FX_BSTRC("ShadingType")));
+
return TRUE;
}
FX_BOOL CPDF_ShadingPattern::Reload() {
@@ -248,12 +272,12 @@ FX_BOOL CPDF_MeshStream::GetVertexRow(CPDF_MeshVertex* vertex,
}
return TRUE;
}
-CFX_FloatRect _GetShadingBBox(CPDF_Stream* pStream,
- int type,
- const CFX_AffineMatrix* pMatrix,
- CPDF_Function** pFuncs,
- int nFuncs,
- CPDF_ColorSpace* pCS) {
+CFX_FloatRect GetShadingBBox(CPDF_Stream* pStream,
+ ShadingType type,
+ const CFX_AffineMatrix* pMatrix,
+ CPDF_Function** pFuncs,
+ int nFuncs,
+ CPDF_ColorSpace* pCS) {
if (!pStream || !pStream->IsStream() || !pFuncs || !pCS)
return CFX_FloatRect(0, 0, 0, 0);
@@ -263,14 +287,20 @@ CFX_FloatRect _GetShadingBBox(CPDF_Stream* pStream,
CFX_FloatRect rect;
FX_BOOL bStarted = FALSE;
- FX_BOOL bGouraud = type == 4 || type == 5;
- int full_point_count = type == 7 ? 16 : (type == 6 ? 12 : 1);
- int full_color_count = (type == 6 || type == 7) ? 4 : 1;
+ FX_BOOL bGouraud = type == kFreeFormGouraudTriangleMeshShading ||
+ type == kLatticeFormGouraudTriangleMeshShading;
+ int full_point_count = type == kTensorProductPatchMeshShading
+ ? 16
+ : (type == kCoonsPatchMeshShading ? 12 : 1);
+ int full_color_count =
+ (type == kCoonsPatchMeshShading || type == kTensorProductPatchMeshShading)
+ ? 4
+ : 1;
while (!stream.m_BitStream.IsEOF()) {
FX_DWORD flag = 0;
- if (type != 5) {
+ if (type != kLatticeFormGouraudTriangleMeshShading)
flag = stream.GetFlag();
- }
+
int point_count = full_point_count, color_count = full_color_count;
if (!bGouraud && flag) {
point_count -= 4;

Powered by Google App Engine
This is Rietveld 408576698