0

Roll src/third_party/ink/src/ d21aa587b..e5673a4ff (1 commit)

d21aa587ba..e5673a4ff2

$ git log d21aa587b..e5673a4ff --date=short --no-merges --format='%ad %ae %s'
2024-11-12 sfreilich Rename ModeledShape to PartitionedMesh

Created with:
  roll-dep src/third_party/ink/src

Then update Chromium build rules, includes, and type references to match
the Ink rename. Variables still keep their "shape" names, as they do in
Ink.

Change-Id: I2f390013590d505c1c9dcc5f5c5cdfa35a4a327b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6112871
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1399420}
This commit is contained in:
Lei Zhang
2024-12-20 15:53:20 -08:00
committed by Chromium LUCI CQ
parent 65a1a26701
commit 687012f46b
19 changed files with 60 additions and 57 deletions

2
DEPS

@ -404,7 +404,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling ink
# and whatever else without interference from each other.
'ink_revision': 'd21aa587baa20f9db3dba2007e314f1c29351d10',
'ink_revision': 'e5673a4ff2d82f29b22f7bec114161cbc1ff8cf8',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling ink_stroke_modeler
# and whatever else without interference from each other.

@ -14,7 +14,7 @@
namespace chrome_pdf {
// Identifies ink::ModeledShape objects.
// Identifies ink::PartitionedMesh objects.
using InkModeledShapeId = base::StrongAlias<class InkModeledShapeIdTag, size_t>;
// Identifies ink::Stroke objects.

@ -40,7 +40,7 @@
#include "third_party/ink/src/ink/brush/brush.h"
#include "third_party/ink/src/ink/geometry/affine_transform.h"
#include "third_party/ink/src/ink/geometry/intersects.h"
#include "third_party/ink/src/ink/geometry/modeled_shape.h"
#include "third_party/ink/src/ink/geometry/partitioned_mesh.h"
#include "third_party/ink/src/ink/geometry/rect.h"
#include "third_party/ink/src/ink/rendering/skia/native/skia_renderer.h"
#include "third_party/ink/src/ink/strokes/in_progress_stroke.h"
@ -689,7 +689,7 @@ bool PdfInkModule::EraseHelper(const gfx::PointF& position, int page_index) {
// No transform needed, as `eraser_rect` is already using transformed
// coordinates from `canonical_position`.
const ink::ModeledShape& shape = stroke.stroke.GetShape();
const ink::PartitionedMesh& shape = stroke.stroke.GetShape();
if (!ink::Intersects(eraser_rect, shape, kIdentityTransform)) {
continue;
}
@ -1209,7 +1209,7 @@ PdfInkModule::FinishedStrokeState& PdfInkModule::FinishedStrokeState::operator=(
PdfInkModule::FinishedStrokeState::~FinishedStrokeState() = default;
PdfInkModule::LoadedV2ShapeState::LoadedV2ShapeState(ink::ModeledShape shape,
PdfInkModule::LoadedV2ShapeState::LoadedV2ShapeState(ink::PartitionedMesh shape,
InkModeledShapeId id)
: shape(std::move(shape)), id(id) {}

@ -21,7 +21,7 @@
#include "pdf/pdf_ink_ids.h"
#include "pdf/pdf_ink_undo_redo_model.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "third_party/ink/src/ink/geometry/modeled_shape.h"
#include "third_party/ink/src/ink/geometry/partitioned_mesh.h"
#include "third_party/ink/src/ink/strokes/in_progress_stroke.h"
#include "third_party/ink/src/ink/strokes/input/stroke_input.h"
#include "third_party/ink/src/ink/strokes/input/stroke_input_batch.h"
@ -183,7 +183,7 @@ class PdfInkModule {
// A shape that was loaded from a "V2" path from the PDF itself, its ID, and
// whether it should be drawn or not.
struct LoadedV2ShapeState {
LoadedV2ShapeState(ink::ModeledShape shape, InkModeledShapeId id);
LoadedV2ShapeState(ink::PartitionedMesh shape, InkModeledShapeId id);
LoadedV2ShapeState(const LoadedV2ShapeState&) = delete;
LoadedV2ShapeState& operator=(const LoadedV2ShapeState&) = delete;
LoadedV2ShapeState(LoadedV2ShapeState&&) noexcept;
@ -192,7 +192,7 @@ class PdfInkModule {
// Coordinates for each shape are stored in a canonical format specified in
// pdf_ink_transform.h.
ink::ModeledShape shape;
ink::PartitionedMesh shape;
// A unique ID to identify this shape.
InkModeledShapeId id;

@ -10,7 +10,7 @@
#include "pdf/buildflags.h"
#include "pdf/page_orientation.h"
#include "pdf/pdf_ink_ids.h"
#include "third_party/ink/src/ink/geometry/modeled_shape.h"
#include "third_party/ink/src/ink/geometry/partitioned_mesh.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/vector2d.h"
@ -31,7 +31,8 @@ class PdfInkModuleClient {
public:
// Key: ID to identify a shape.
// Value: The Ink shape.
using PageV2InkPathShapesMap = std::map<InkModeledShapeId, ink::ModeledShape>;
using PageV2InkPathShapesMap =
std::map<InkModeledShapeId, ink::PartitionedMesh>;
// Key: 0-based page index.
// Value: Map of shapes on the page.

@ -578,11 +578,11 @@ TEST_F(PdfInkModuleTest, HandleSetAnnotationModeMessage) {
.WillOnce(Return(PdfInkModuleClient::DocumentV2InkPathShapesMap{
{0,
PdfInkModuleClient::PageV2InkPathShapesMap{
{InkModeledShapeId(0), ink::ModeledShape()},
{InkModeledShapeId(1), ink::ModeledShape()}}},
{InkModeledShapeId(0), ink::PartitionedMesh()},
{InkModeledShapeId(1), ink::PartitionedMesh()}}},
{3,
PdfInkModuleClient::PageV2InkPathShapesMap{
{InkModeledShapeId(2), ink::ModeledShape()}}},
{InkModeledShapeId(2), ink::PartitionedMesh()}}},
}));
const auto kShapeMapMatcher = ElementsAre(
@ -2253,7 +2253,7 @@ TEST_F(PdfInkModuleUndoRedoTest, UndoRedoEraseLoadedV2Shapes) {
CreateInkMeshFromPolylineForTesting(ink_points);
ASSERT_TRUE(mesh0.has_value());
auto shape0 =
ink::ModeledShape::FromMeshes(base::span_from_ref(mesh0.value()));
ink::PartitionedMesh::FromMeshes(base::span_from_ref(mesh0.value()));
ASSERT_TRUE(shape0.ok());
constexpr ink::Point kCornerPoints[] = {
@ -2265,7 +2265,7 @@ TEST_F(PdfInkModuleUndoRedoTest, UndoRedoEraseLoadedV2Shapes) {
CreateInkMeshFromPolylineForTesting(kCornerPoints);
ASSERT_TRUE(mesh1.has_value());
auto shape1 =
ink::ModeledShape::FromMeshes(base::span_from_ref(mesh1.value()));
ink::PartitionedMesh::FromMeshes(base::span_from_ref(mesh1.value()));
ASSERT_TRUE(shape1.ok());
EXPECT_CALL(client(), LoadV2InkPathsFromPdf())

@ -2619,18 +2619,18 @@ TEST_F(PdfViewWebPluginInkTest, Invalidate) {
}
TEST_F(PdfViewWebPluginInkTest, LoadV2InkPathsForPageAndUpdateShapeActive) {
const std::map<InkModeledShapeId, ink::ModeledShape> kEmptyMap;
const std::map<InkModeledShapeId, ink::ModeledShape> kMap0{
{InkModeledShapeId(0), ink::ModeledShape()},
const std::map<InkModeledShapeId, ink::PartitionedMesh> kEmptyMap;
const std::map<InkModeledShapeId, ink::PartitionedMesh> kMap0{
{InkModeledShapeId(0), ink::PartitionedMesh()},
};
const std::map<InkModeledShapeId, ink::ModeledShape> kMap1{
{InkModeledShapeId(1), ink::ModeledShape()},
{InkModeledShapeId(2), ink::ModeledShape()},
const std::map<InkModeledShapeId, ink::PartitionedMesh> kMap1{
{InkModeledShapeId(1), ink::PartitionedMesh()},
{InkModeledShapeId(2), ink::PartitionedMesh()},
};
const std::map<InkModeledShapeId, ink::ModeledShape> kMap2{
{InkModeledShapeId(3), ink::ModeledShape()},
{InkModeledShapeId(4), ink::ModeledShape()},
{InkModeledShapeId(5), ink::ModeledShape()},
const std::map<InkModeledShapeId, ink::PartitionedMesh> kMap2{
{InkModeledShapeId(3), ink::PartitionedMesh()},
{InkModeledShapeId(4), ink::PartitionedMesh()},
{InkModeledShapeId(5), ink::PartitionedMesh()},
};
EXPECT_CALL(*engine_ptr_, LoadV2InkPathsForPage(testing::Lt(12)))

@ -4449,7 +4449,7 @@ void PDFiumEngine::DiscardStroke(int page_index, InkStrokeId id) {
ink_stroke_objects_map_.erase(it);
}
std::map<InkModeledShapeId, ink::ModeledShape>
std::map<InkModeledShapeId, ink::PartitionedMesh>
PDFiumEngine::LoadV2InkPathsForPage(int page_index) {
CHECK(PageIndexInBounds(page_index));
@ -4459,7 +4459,7 @@ PDFiumEngine::LoadV2InkPathsForPage(int page_index) {
CHECK(inserted);
#endif // DCHECK_IS_ON()
std::map<InkModeledShapeId, ink::ModeledShape> page_shape_map;
std::map<InkModeledShapeId, ink::PartitionedMesh> page_shape_map;
std::vector<ReadV2InkPathResult> read_results =
ReadV2InkPathsFromPageAsModeledShapes(pages_[page_index]->GetPage());

@ -62,7 +62,7 @@
#if BUILDFLAG(ENABLE_PDF_INK2)
#include "pdf/pdf_ink_ids.h"
#include "third_party/ink/src/ink/geometry/modeled_shape.h"
#include "third_party/ink/src/ink/geometry/partitioned_mesh.h"
#endif
#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
@ -408,8 +408,8 @@ class PDFiumEngine : public DocumentLoader::Client, public IFSDK_PAUSE {
// PDFium page object.
//
// Virtual to support testing.
virtual std::map<InkModeledShapeId, ink::ModeledShape> LoadV2InkPathsForPage(
int page_index);
virtual std::map<InkModeledShapeId, ink::PartitionedMesh>
LoadV2InkPathsForPage(int page_index);
// Modifies an existing shape identified by `id` on the page at `page_index`
// to become either active or inactive. The caller must pass the same

@ -2054,7 +2054,7 @@ TEST_P(PDFiumEngineInkTest, LoadV2InkPathsForPage) {
ASSERT_EQ(1, engine->GetNumberOfPages());
EXPECT_TRUE(engine->ink_modeled_shape_map_for_testing().empty());
std::map<InkModeledShapeId, ink::ModeledShape> ink_shapes =
std::map<InkModeledShapeId, ink::PartitionedMesh> ink_shapes =
engine->LoadV2InkPathsForPage(/*page_index=*/0);
ASSERT_EQ(1u, ink_shapes.size());
const auto ink_shapes_it = ink_shapes.begin();
@ -2275,7 +2275,7 @@ TEST_P(PDFiumEngineInkDrawTest, LoadedV2InkPathsAndUpdateShapeActive) {
1);
// Check the LoadV2InkPathsForPage() call does not change the rendering.
std::map<InkModeledShapeId, ink::ModeledShape> ink_shapes =
std::map<InkModeledShapeId, ink::PartitionedMesh> ink_shapes =
engine->LoadV2InkPathsForPage(kPageIndex);
ASSERT_EQ(1u, ink_shapes.size());
CheckPdfRendering(page.GetPage(), kPageSizeInPoints, kInkV2PngPath);

@ -18,7 +18,7 @@
#include "pdf/pdfium/pdfium_api_wrappers.h"
#include "printing/units.h"
#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/partitioned_mesh.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"
@ -89,7 +89,7 @@ std::optional<ink::Mesh> CreateInkMeshFromPolyline(
return *mesh;
}
std::optional<ink::ModeledShape> ReadV2InkModeledShapeFromPath(
std::optional<ink::PartitionedMesh> ReadV2InkModeledShapeFromPath(
FPDF_PAGEOBJECT path,
const gfx::AxisTransform2d& transform) {
CHECK_EQ(FPDFPageObj_GetType(path), FPDF_PAGEOBJ_PATH);
@ -138,8 +138,9 @@ std::optional<ink::ModeledShape> ReadV2InkModeledShapeFromPath(
// Note that `shape` only has enough data for use with ink::Intersects(). It
// has no outline.
auto shape = ink::ModeledShape::FromMeshes(base::span_from_ref(mesh.value()),
/*outlines=*/{});
auto shape =
ink::PartitionedMesh::FromMeshes(base::span_from_ref(mesh.value()),
/*outlines=*/{});
if (!shape.ok()) {
return std::nullopt;
}
@ -167,7 +168,7 @@ std::vector<ReadV2InkPathResult> ReadV2InkPathsFromPageAsModeledShapes(
continue;
}
std::optional<ink::ModeledShape> shape =
std::optional<ink::PartitionedMesh> shape =
ReadV2InkModeledShapeFromPath(page_object, transform);
if (!shape.has_value()) {
continue;

@ -11,7 +11,7 @@
#include "base/containers/span.h"
#include "pdf/buildflags.h"
#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/partitioned_mesh.h"
#include "third_party/ink/src/ink/geometry/point.h"
#include "third_party/pdfium/public/fpdfview.h"
@ -21,11 +21,11 @@ namespace chrome_pdf {
struct ReadV2InkPathResult {
FPDF_PAGEOBJECT page_object;
ink::ModeledShape shape;
ink::PartitionedMesh shape;
};
// For the given `page`, iterate through all page objects and import "V2" paths
// created by Ink as ink::ModeledShapes. For each shape, also return its
// created by Ink as ink::PartitionedMeshs. For each shape, also return its
// associated page object. The shapes do not have outlines and are only suitable
// for use with ink::Intersects().
//

@ -16,7 +16,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/ink/src/ink/geometry/affine_transform.h"
#include "third_party/ink/src/ink/geometry/intersects.h"
#include "third_party/ink/src/ink/geometry/modeled_shape.h"
#include "third_party/ink/src/ink/geometry/partitioned_mesh.h"
#include "third_party/ink/src/ink/geometry/point.h"
namespace chrome_pdf {

@ -17,7 +17,7 @@
#include "third_party/ink/src/ink/brush/brush_coat.h"
#include "third_party/ink/src/ink/brush/brush_tip.h"
#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/partitioned_mesh.h"
#include "third_party/ink/src/ink/geometry/point.h"
#include "third_party/ink/src/ink/strokes/stroke.h"
#include "third_party/pdfium/public/cpp/fpdf_scopers.h"
@ -29,7 +29,7 @@ namespace chrome_pdf {
namespace {
// Wrapper around an `ink::ModeledShape` to iterate through all the outlines
// Wrapper around an `ink::PartitionedMesh` to iterate through all the outlines
// that make up the shape.
class ModeledShapeOutlinesIterator {
public:
@ -37,11 +37,11 @@ class ModeledShapeOutlinesIterator {
uint32_t group_index;
// Guaranteeded to be non-empty.
// TODO(367764863) Rewrite to base::raw_span.
RAW_PTR_EXCLUSION base::span<const ink::ModeledShape::VertexIndexPair>
RAW_PTR_EXCLUSION base::span<const ink::PartitionedMesh::VertexIndexPair>
outline;
};
explicit ModeledShapeOutlinesIterator(const ink::ModeledShape& shape)
explicit ModeledShapeOutlinesIterator(const ink::PartitionedMesh& shape)
: shape_(shape) {}
std::optional<OutlineData> GetAndAdvance() {
@ -62,14 +62,14 @@ class ModeledShapeOutlinesIterator {
}
private:
const raw_ref<const ink::ModeledShape> shape_;
const raw_ref<const ink::PartitionedMesh> shape_;
uint32_t group_index_ = 0;
uint32_t outline_index_ = 0;
};
gfx::PointF GetVertexPosition(
base::span<const ink::Mesh> meshes,
const ink::ModeledShape::VertexIndexPair& vertex_index_pair) {
const ink::PartitionedMesh::VertexIndexPair& vertex_index_pair) {
ink::Point vertex_position =
meshes[vertex_index_pair.mesh_index].VertexPosition(
vertex_index_pair.vertex_index);
@ -83,7 +83,7 @@ gfx::PointF GetVertexPosition(
// The returned page object is always a `FPDF_PAGEOBJ_PATH` and never null.
ScopedFPDFPageObject CreatePathFromOutlineData(
FPDF_PAGE page,
const ink::ModeledShape& shape,
const ink::PartitionedMesh& shape,
const ModeledShapeOutlinesIterator::OutlineData& outline_data,
const gfx::AxisTransform2d& transform) {
CHECK(page);
@ -119,7 +119,7 @@ ScopedFPDFPageObject CreatePathFromOutlineData(
}
std::vector<ScopedFPDFPageObject> WriteShapeToNewPathsOnPage(
const ink::ModeledShape& shape,
const ink::PartitionedMesh& shape,
FPDF_PAGE page) {
CHECK(page);

@ -23,7 +23,7 @@
#include "pdf/test/test_helpers.h"
#include "third_party/ink/src/ink/geometry/affine_transform.h"
#include "third_party/ink/src/ink/geometry/intersects.h"
#include "third_party/ink/src/ink/geometry/modeled_shape.h"
#include "third_party/ink/src/ink/geometry/partitioned_mesh.h"
#include "third_party/ink/src/ink/geometry/point.h"
#include "third_party/ink/src/ink/strokes/input/stroke_input.h"
#include "third_party/ink/src/ink/strokes/input/stroke_input_batch.h"
@ -124,8 +124,9 @@ TEST_P(PDFiumInkWriterTest, BasicWriteAndRead) {
ASSERT_TRUE(saved_page);
// Complete the round trip and read the written PDF data back into memory as
// an ink::ModeledShape. ReadV2InkPathsFromPageAsModeledShapes() is known to
// be good because its unit tests reads from a real, known to be good Ink PDF.
// an ink::PartitionedMesh. ReadV2InkPathsFromPageAsModeledShapes() is known
// to be good because its unit tests reads from a real, known to be good Ink
// PDF.
std::vector<ReadV2InkPathResult> saved_results =
ReadV2InkPathsFromPageAsModeledShapes(saved_page);
ASSERT_EQ(saved_results.size(), 1u);

@ -109,7 +109,7 @@ class TestPDFiumEngine : public PDFiumEngine {
MOCK_METHOD(void, DiscardStroke, (int, InkStrokeId), (override));
MOCK_METHOD((std::map<InkModeledShapeId, ink::ModeledShape>),
MOCK_METHOD((std::map<InkModeledShapeId, ink::PartitionedMesh>),
LoadV2InkPathsForPage,
(int),
(override));

@ -58,10 +58,10 @@ source_set("ink") {
"src/ink/geometry/mesh_format.cc",
"src/ink/geometry/mesh_format.h",
"src/ink/geometry/mesh_packing_types.h",
"src/ink/geometry/modeled_shape.cc",
"src/ink/geometry/modeled_shape.h",
"src/ink/geometry/mutable_mesh.cc",
"src/ink/geometry/mutable_mesh.h",
"src/ink/geometry/partitioned_mesh.cc",
"src/ink/geometry/partitioned_mesh.h",
"src/ink/geometry/point.cc",
"src/ink/geometry/point.h",
"src/ink/geometry/quad.cc",

@ -1,7 +1,7 @@
Name: Ink
URL: https://github.com/google/ink.git
Version: N/A
Revision: 4300dc7402a257b85fc5bf2559137edacb050227
Revision: e5673a4ff2d82f29b22f7bec114161cbc1ff8cf8
License: Apache-2.0
License File: LICENSE
Shipped: yes