Commit da8210a9 authored by Ankit Kumar 🌪️'s avatar Ankit Kumar 🌪️ Committed by Commit Bot

Migrate all instances of pp::Point to gfx::Point/gfx::Vector2d

Update pdf/ to use gfx::Point/gfx::Vector2d instead of pp::Point based
on context. Apart from OutOfProcessInstance all other files in pdf/ now
use gfx::Point/gfx::Vector2d instead of pp::Point.

In the Pepper model, we have used pp::Point to denote a point as well as
a 2D vector. Based on the usage of the pp::Point migrate it to
gfx::Point or gfx::Vector2d. A position is represented by gfx::Point
while an offset is represented by gfx::Vector2d.

Bug: 1101101
Change-Id: I784fb886ff378cc7fd20722dfba6dd5ed3a55952
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2329105
Commit-Queue: Ankit Kumar 🌪️ <ankk@microsoft.com>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarK. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800028}
parent 90a173bc
......@@ -5,7 +5,6 @@
#include "pdf/draw_utils/coordinates.h"
#include "pdf/test/test_utils.h"
#include "ppapi/cpp/point.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
......
......@@ -2057,7 +2057,7 @@ void OutOfProcessInstance::OnGeometryChanged(double old_zoom,
available_area_.set_height(bottom_of_document);
CalculateBackgroundParts();
engine()->PageOffsetUpdated(PointFromPPPoint(available_area_.point()));
engine()->PageOffsetUpdated(VectorFromPPPoint(available_area_.point()));
engine()->PluginSizeUpdated(SizeFromPPSize(available_area_.size()));
if (document_size_.IsEmpty())
......
......@@ -324,7 +324,7 @@ class PDFEngine {
// Most of these functions are similar to the Pepper functions of the same
// name, so not repeating the description here unless it's different.
virtual bool New(const char* url, const char* headers) = 0;
virtual void PageOffsetUpdated(const gfx::Point& page_offset) = 0;
virtual void PageOffsetUpdated(const gfx::Vector2d& page_offset) = 0;
virtual void PluginSizeUpdated(const gfx::Size& size) = 0;
virtual void ScrolledToXPosition(int position) = 0;
virtual void ScrolledToYPosition(int position) = 0;
......
This diff is collapsed.
......@@ -29,7 +29,6 @@
#include "ppapi/c/private/ppp_pdf.h"
#include "ppapi/cpp/dev/buffer_dev.h"
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/point.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/var_array.h"
#include "third_party/pdfium/public/cpp/fpdf_scopers.h"
......@@ -39,6 +38,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d.h"
namespace chrome_pdf {
......@@ -84,7 +84,7 @@ class PDFiumEngine : public PDFEngine,
// PDFEngine:
bool New(const char* url, const char* headers) override;
void PageOffsetUpdated(const gfx::Point& page_offset) override;
void PageOffsetUpdated(const gfx::Vector2d& page_offset) override;
void PluginSizeUpdated(const gfx::Size& size) override;
void ScrolledToXPosition(int position) override;
void ScrolledToYPosition(int position) override;
......@@ -213,7 +213,7 @@ class PDFiumEngine : public PDFEngine,
PDFiumEngine* const engine_;
// The origin at the time this object was constructed.
const pp::Point previous_origin_;
const gfx::Point previous_origin_;
// Screen rectangles that were selected on construction.
std::vector<pp::Rect> old_selections_;
};
......@@ -360,7 +360,7 @@ class PDFiumEngine : public PDFEngine,
std::vector<pp::Rect> GetAllScreenRectsUnion(
const std::vector<PDFiumRange>& rect_range,
const pp::Point& offset_point) const;
const gfx::Point& point) const;
void UpdateTickMarks();
......@@ -420,7 +420,7 @@ class PDFiumEngine : public PDFEngine,
// Given |point|, returns which page and character location it's closest to,
// as well as extra information about objects at that point.
PDFiumPage::Area GetCharIndex(const pp::Point& point,
PDFiumPage::Area GetCharIndex(const gfx::Point& point,
int* page_index,
int* char_index,
int* form_type,
......@@ -506,7 +506,7 @@ class PDFiumEngine : public PDFEngine,
// Helper function to convert a device to page coordinates. If the page is
// not yet loaded, |page_x| and |page_y| will be set to 0.
void DeviceToPage(int page_index,
const pp::Point& device_point,
const gfx::Point& device_point,
double* page_x,
double* page_y);
......@@ -523,7 +523,7 @@ class PDFiumEngine : public PDFEngine,
const pp::Rect& clip_rect,
SkBitmap& image_data);
void GetRegion(const pp::Point& location,
void GetRegion(const gfx::Point& location,
SkBitmap& image_data,
void*& region,
int& stride) const;
......@@ -644,7 +644,7 @@ class PDFiumEngine : public PDFEngine,
// The scroll position in screen coordinates.
gfx::Point position_;
// The offset of the page into the viewport.
pp::Point page_offset_;
gfx::Vector2d page_offset_;
// The plugin size in screen coordinates.
gfx::Size plugin_size_;
double current_zoom_ = 1.0;
......@@ -707,7 +707,7 @@ class PDFiumEngine : public PDFEngine,
bool mouse_middle_button_down_ = false;
// Last known position while performing middle mouse button pan.
pp::Point mouse_middle_button_last_position_;
gfx::Point mouse_middle_button_last_position_;
// The current text used for searching.
std::string current_find_text_;
......@@ -828,7 +828,7 @@ class PDFiumEngine : public PDFEngine,
RangeSelectionDirection range_selection_direction_ =
RangeSelectionDirection::Right;
pp::Point range_selection_base_;
gfx::Point range_selection_base_;
bool edit_mode_ = false;
......
......@@ -13,6 +13,7 @@
#include "pdf/pdfium/pdfium_api_string_buffer_adapter.h"
#include "pdf/pdfium/pdfium_mem_buffer_file_write.h"
#include "pdf/pdfium/pdfium_print.h"
#include "pdf/ppapi_migration/geometry_conversions.h"
#include "printing/nup_parameters.h"
#include "printing/units.h"
#include "third_party/pdfium/public/cpp/fpdf_scopers.h"
......@@ -22,6 +23,7 @@
#include "third_party/pdfium/public/fpdfview.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d.h"
using printing::ConvertUnitDouble;
using printing::kPointsPerInch;
......@@ -92,10 +94,10 @@ int CalculatePosition(FPDF_PAGE page,
}
if (settings.center_in_bounds) {
pp::Point offset(
gfx::Vector2d offset(
(settings.bounds.width() * settings.dpi_x / dpi - dest->width()) / 2,
(settings.bounds.height() * settings.dpi_y / dpi - dest->height()) / 2);
dest->Offset(offset);
dest->Offset(PPPointFromVector(offset));
}
return rotate;
}
......
......@@ -13,7 +13,6 @@
#include "base/strings/utf_string_conversions.h"
#include "pdf/pdfium/pdfium_engine.h"
#include "pdf/ppapi_migration/geometry_conversions.h"
#include "ppapi/cpp/point.h"
#include "ppapi/cpp/rect.h"
#include "third_party/pdfium/public/fpdf_annot.h"
......
......@@ -11,6 +11,7 @@
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d.h"
namespace chrome_pdf {
......@@ -43,4 +44,12 @@ PP_Size PPSizeFromSize(const gfx::Size& size) {
return PP_MakeSize(size.width(), size.height());
}
gfx::Vector2d VectorFromPPPoint(const PP_Point& pp_point) {
return gfx::Vector2d(pp_point.x, pp_point.y);
}
PP_Point PPPointFromVector(const gfx::Vector2d& vector) {
return PP_MakePoint(vector.x(), vector.y());
}
} // namespace chrome_pdf
......@@ -15,6 +15,7 @@ class Point;
class PointF;
class Rect;
class Size;
class Vector2d;
} // namespace gfx
namespace chrome_pdf {
......@@ -30,6 +31,9 @@ PP_Rect PPRectFromRect(const gfx::Rect& rect);
gfx::Size SizeFromPPSize(const PP_Size& pp_size);
PP_Size PPSizeFromSize(const gfx::Size& size);
gfx::Vector2d VectorFromPPPoint(const PP_Point& pp_point);
PP_Point PPPointFromVector(const gfx::Vector2d& vector);
} // namespace chrome_pdf
#endif // PDF_PPAPI_MIGRATION_GEOMETRY_CONVERSIONS_H_
......@@ -15,6 +15,7 @@
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d.h"
namespace chrome_pdf {
......@@ -84,4 +85,22 @@ TEST(GeometryConversionsTest, PPSizeFromSize) {
EXPECT_EQ(pp_c_size.height, 3);
}
TEST(GeometryConversionsTest, VectorFromPPPoint) {
gfx::Vector2d point = VectorFromPPPoint(pp::Point(-1, 2));
EXPECT_EQ(point, gfx::Vector2d(-1, 2));
point = VectorFromPPPoint(PP_MakePoint(2, -1));
EXPECT_EQ(point, gfx::Vector2d(2, -1));
}
TEST(GeometryConversionsTest, PPPointFromVector) {
pp::Point pp_cpp_point = PPPointFromVector(gfx::Vector2d(-1, 2));
EXPECT_EQ(pp_cpp_point.x(), -1);
EXPECT_EQ(pp_cpp_point.y(), 2);
PP_Point pp_c_point = PPPointFromVector(gfx::Vector2d(2, -1));
EXPECT_EQ(pp_c_point.x, 2);
EXPECT_EQ(pp_c_point.y, -1);
}
} // namespace chrome_pdf
......@@ -23,16 +23,6 @@
namespace chrome_pdf {
namespace {
// Not part of ppapi_migration because `gfx::Vector2d` only needs to be
// converted to `pp::Point` at the boundary with `pp::Graphics2D`.
pp::Point ToPepperPoint(const gfx::Vector2d& vector) {
return pp::Point(vector.x(), vector.y());
}
} // namespace
Graphics::Graphics(const gfx::Size& size) : size_(size) {}
PepperGraphics::PepperGraphics(const pp::InstanceHandle& instance,
......@@ -67,7 +57,7 @@ void PepperGraphics::PaintImage(const Image& image, const gfx::Rect& src_rect) {
void PepperGraphics::Scroll(const gfx::Rect& clip,
const gfx::Vector2d& amount) {
pepper_graphics_.Scroll(PPRectFromRect(clip), ToPepperPoint(amount));
pepper_graphics_.Scroll(PPRectFromRect(clip), PPPointFromVector(amount));
}
void PepperGraphics::SetScale(float scale) {
......@@ -79,7 +69,7 @@ void PepperGraphics::SetLayerTransform(float scale,
const gfx::Point& origin,
const gfx::Vector2d& translate) {
bool result = pepper_graphics_.SetLayerTransform(
scale, PPPointFromPoint(origin), ToPepperPoint(translate));
scale, PPPointFromPoint(origin), PPPointFromVector(translate));
DCHECK(result);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment