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

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

Issue 1737593006: Re-land "Replace CPDF_Rect and CPDF_Point with CFX types." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Ooops. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/include/fxcrt/fx_coordinates.h ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
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 de3a6572f25d41d0a5ec86b99229df3618b6c419..44492b1a54e31f4a7613d554c28d341135355a99 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();
« no previous file with comments | « core/include/fxcrt/fx_coordinates.h ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698