[PDF Ink Signatures] Perform tessellation inside pdfium_ink_reader.cc
When code in pdfium_ink_reader.cc reads PDF paths, add the missing tessellation step by calling ink::CreateMeshFromPolyline() as appropriate. Then update PDFiumInkReaderTest.Basic test expectations, now that ReadV2InkPathsFromPageAsModeledShapes() can create real ink::ModeledShape objects. Bug: 353942910 Change-Id: I89ffff34c1fd4c10e8506439bc0acdefad212747 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5984439 Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Alan Screen <awscreen@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/main@{#1378649}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
a1549c0d70
commit
a6583bd2f0
@ -18,6 +18,7 @@
|
||||
#include "third_party/ink/src/ink/geometry/mesh.h"
|
||||
#include "third_party/ink/src/ink/geometry/modeled_shape.h"
|
||||
#include "third_party/ink/src/ink/geometry/point.h"
|
||||
#include "third_party/ink/src/ink/geometry/tessellator.h"
|
||||
#include "third_party/pdfium/public/fpdf_edit.h"
|
||||
#include "third_party/pdfium/public/fpdfview.h"
|
||||
#include "ui/gfx/geometry/axis_transform2d.h"
|
||||
@ -65,11 +66,10 @@ ink::Point GetTransformedInkPoint(const gfx::AxisTransform2d& transform,
|
||||
// Creates an ink::Mesh from `polyline`. If it is valid, append it to `meshes`.
|
||||
void AppendPolylineToMeshesList(std::vector<ink::Mesh>& meshes,
|
||||
const std::vector<ink::Point>& polyline) {
|
||||
// TODO(crbug.com/353942910): Save `polyline` into an `ink::Mesh` once
|
||||
// ink::CreateMeshFromPolyline() is available to do tessellation.
|
||||
//
|
||||
// For now, just append an empty mesh.
|
||||
meshes.emplace_back();
|
||||
auto mesh = ink::CreateMeshFromPolyline(polyline);
|
||||
if (mesh.ok()) {
|
||||
meshes.push_back(*mesh);
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<ink::ModeledShape> ReadV2InkModeledShapeFromPath(
|
||||
@ -128,8 +128,7 @@ std::optional<ink::ModeledShape> ReadV2InkModeledShapeFromPath(
|
||||
}
|
||||
|
||||
// After the loop is done, take care of the remaining values.
|
||||
// TODO(crbug.com/353942910): Actually add the call. Leave it out
|
||||
// intentionally to make the unit test pass without a working tessellator.
|
||||
AppendPolylineToMeshesList(meshes, current_polyline);
|
||||
|
||||
// Note that `shape` only has enough data for use with ink::Intersects(). It
|
||||
// has no outline.
|
||||
|
@ -55,10 +55,8 @@ TEST_P(PDFiumInkReaderTest, Basic) {
|
||||
EXPECT_FALSE(ink::Intersects(ink::Point{194, 204}, shape, no_transform));
|
||||
|
||||
// Points that do intersect.
|
||||
// TODO(crbug.com/353942910): These should return true once a tessellator is
|
||||
// available.
|
||||
EXPECT_FALSE(ink::Intersects(ink::Point{133, 212}, shape, no_transform));
|
||||
EXPECT_FALSE(ink::Intersects(ink::Point{194, 203}, shape, no_transform));
|
||||
EXPECT_TRUE(ink::Intersects(ink::Point{133, 212}, shape, no_transform));
|
||||
EXPECT_TRUE(ink::Intersects(ink::Point{194, 203}, shape, no_transform));
|
||||
}
|
||||
|
||||
TEST_P(PDFiumInkReaderTest, NoPage) {
|
||||
|
Reference in New Issue
Block a user