summaryrefslogtreecommitdiff
path: root/core/fpdfapi/edit
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/edit')
-rw-r--r--core/fpdfapi/edit/DEPS3
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp9
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp11
3 files changed, 17 insertions, 6 deletions
diff --git a/core/fpdfapi/edit/DEPS b/core/fpdfapi/edit/DEPS
new file mode 100644
index 0000000000..8a4c38c44b
--- /dev/null
+++ b/core/fpdfapi/edit/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ '+third_party/skia_shared',
+]
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index 8a08a849cc..a2d4d4f125 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -25,6 +25,7 @@
#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
+#include "third_party/skia_shared/SkFloatToDecimal.h"
namespace {
@@ -221,7 +222,13 @@ void CPDF_PageContentGenerator::ProcessPath(std::ostringstream* buf,
for (size_t i = 0; i < pPoints.size(); i++) {
if (i > 0)
*buf << " ";
- *buf << pPoints[i].m_Point.x << " " << pPoints[i].m_Point.y;
+
+ char buffer[kMaximumSkFloatToDecimalLength];
+ unsigned size = SkFloatToDecimal(pPoints[i].m_Point.x, buffer);
+ buf->write(buffer, size) << " ";
+ size = SkFloatToDecimal(pPoints[i].m_Point.y, buffer);
+ buf->write(buffer, size);
+
FXPT_TYPE pointType = pPoints[i].m_Type;
if (pointType == FXPT_TYPE::MoveTo) {
*buf << " m";
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
index a0db869410..403bd6ab03 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -103,8 +103,9 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) {
std::ostringstream buf;
TestProcessPath(&generator, &buf, pPathObj.get());
EXPECT_EQ(
- "q 1 0 0 1 0 0 cm 3.102 4.67 m 5.45 0.29 l 4.24 3.15 4.65 2.98 3.456 0.24"
- " c 10.6 11.15 l 11 12.5 l 11.46 12.67 11.84 12.96 12 13.64 c h f Q\n",
+ "q 1 0 0 1 0 0 cm 3.102 4.6700001 m 5.4499998 .28999999 l 4.2399998 "
+ "3.1500001 4.65 2.98 3.456 0.24 c 10.6000004 11.1499996 l 11 12.5 "
+ "l 11.46 12.6700001 11.84 12.96 12 13.64 c h f Q\n",
ByteString(buf));
}
@@ -312,8 +313,8 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessFormWithPath) {
pDoc->CreateNewDoc();
auto pDict = pdfium::MakeUnique<CPDF_Dictionary>();
const char content[] =
- "q 1 0 0 1 0 0 cm 3.102 4.67 m 5.45 0.29 l 4.24 3.15 4.65 2.98 3.456 "
- "0.24 c 3.102 4.67 l h f Q\n";
+ "q 1 0 0 1 0 0 cm 3.102 4.6700001 m 5.4500012 .28999999 "
+ "l 4.2399998 3.1499999 4.65 2.98 3.456 0.24 c 3.102 4.6700001 l h f Q\n";
size_t buf_len = FX_ArraySize(content);
std::unique_ptr<uint8_t, FxFreeDeleter> buf(FX_Alloc(uint8_t, buf_len));
memcpy(buf.get(), content, buf_len);
@@ -329,5 +330,5 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessFormWithPath) {
CPDF_PageContentGenerator generator(pTestForm.get());
std::ostringstream process_buf;
generator.ProcessPageObjects(&process_buf);
- EXPECT_EQ(content, ByteString(process_buf));
+ EXPECT_STREQ(content, ByteString(process_buf).c_str());
}