summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-26 13:09:42 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-26 13:09:42 -0800
commit3b8fdd34bdf57ec45291b77008a43249f838efcb (patch)
treeb65090a7c1fbedcda6499c3be4ffcaf8453e9e11 /core/src/fpdfapi
parent8ba5b59356d506d3b9e976e7422e69bbd5bec8d6 (diff)
downloadpdfium-3b8fdd34bdf57ec45291b77008a43249f838efcb.tar.xz
Replace CPDF_Rect and CPDF_Point with CFX types.
Too many rectangle types. Remove CPDF_Rect #define, and make an equivalent point type in CFX, but stop short of consolidating the N different forms of rectangles in CFX. Also banish PDF_ClipFloat to the one .cpp file that needs it, since it was in the vicinity of the .h file changes. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1740923003 .
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp28
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp10
3 files changed, 20 insertions, 20 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
index de3a6572f2..44492b1a54 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
@@ -6,6 +6,8 @@
#include "core/src/fpdfapi/fpdf_page/pageint.h"
+#include <algorithm>
+
#include "core/include/fpdfapi/fpdf_module.h"
#include "core/include/fpdfapi/fpdf_page.h"
#include "core/include/fpdfapi/fpdf_pageobj.h"
@@ -13,6 +15,14 @@
#include "core/src/fpdfapi/fpdf_render/render_int.h"
#include "third_party/base/stl_util.h"
+namespace {
+
+FX_FLOAT ClipFloat(FX_FLOAT f) {
+ return std::max(0.0f, std::min(1.0f, f));
+}
+
+} // namespace
+
void CPDF_GraphicStates::DefaultStates() {
m_ColorState.New()->Default();
}
@@ -85,21 +95,21 @@ void CPDF_ClipPathData::SetCount(int path_count, int text_count) {
m_pTextList = FX_Alloc(CPDF_TextObject*, text_count);
}
}
-CPDF_Rect CPDF_ClipPath::GetClipBox() const {
- CPDF_Rect rect;
+CFX_FloatRect CPDF_ClipPath::GetClipBox() const {
+ CFX_FloatRect rect;
FX_BOOL bStarted = FALSE;
int count = GetPathCount();
if (count) {
rect = GetPath(0).GetBoundingBox();
for (int i = 1; i < count; i++) {
- CPDF_Rect path_rect = GetPath(i).GetBoundingBox();
+ CFX_FloatRect path_rect = GetPath(i).GetBoundingBox();
rect.Intersect(path_rect);
}
bStarted = TRUE;
}
count = GetTextCount();
if (count) {
- CPDF_Rect layer_rect;
+ CFX_FloatRect layer_rect;
FX_BOOL bLayerStarted = FALSE;
for (int i = 0; i < count; i++) {
CPDF_TextObject* pTextObj = GetText(i);
@@ -128,9 +138,9 @@ void CPDF_ClipPath::AppendPath(CPDF_Path path, int type, FX_BOOL bAutoMerge) {
if (pData->m_PathCount && bAutoMerge) {
CPDF_Path old_path = pData->m_pPathList[pData->m_PathCount - 1];
if (old_path.IsRect()) {
- CPDF_Rect old_rect(old_path.GetPointX(0), old_path.GetPointY(0),
- old_path.GetPointX(2), old_path.GetPointY(2));
- CPDF_Rect new_rect = path.GetBoundingBox();
+ CFX_FloatRect old_rect(old_path.GetPointX(0), old_path.GetPointY(0),
+ old_path.GetPointX(2), old_path.GetPointY(2));
+ CFX_FloatRect new_rect = path.GetBoundingBox();
if (old_rect.Contains(new_rect)) {
pData->m_PathCount--;
pData->m_pPathList[pData->m_PathCount].SetNull();
@@ -534,10 +544,10 @@ void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
}
break;
case FXBSTR_ID('C', 'A', 0, 0):
- pGeneralState->m_StrokeAlpha = PDF_ClipFloat(pObject->GetNumber());
+ pGeneralState->m_StrokeAlpha = ClipFloat(pObject->GetNumber());
break;
case FXBSTR_ID('c', 'a', 0, 0):
- pGeneralState->m_FillAlpha = PDF_ClipFloat(pObject->GetNumber());
+ pGeneralState->m_FillAlpha = ClipFloat(pObject->GetNumber());
break;
case FXBSTR_ID('O', 'P', 0, 0):
pGeneralState->m_StrokeOP = pObject->GetInteger();
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index c47fe8bd73..1df4f3db37 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -116,7 +116,7 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
CFX_Matrix* pmtContentToUser,
CPDF_PageObjectHolder* pObjHolder,
CPDF_Dictionary* pResources,
- CPDF_Rect* pBBox,
+ CFX_FloatRect* pBBox,
CPDF_ParseOptions* pOptions,
CPDF_AllStates* pStates,
int level)
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
index d1a7231d45..37b82dd564 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -363,16 +363,6 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
return buf;
}
-FX_FLOAT PDF_ClipFloat(FX_FLOAT f) {
- if (f < 0) {
- return 0;
- }
- if (f > 1.0f) {
- return 1.0f;
- }
- return f;
-}
-
static CPDF_Object* SearchNumberNode(CPDF_Dictionary* pNode, int num) {
CPDF_Array* pLimits = pNode->GetArrayBy("Limits");
if (pLimits &&