summaryrefslogtreecommitdiff
path: root/core/fxge
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-14 10:08:55 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-14 15:11:27 +0000
commitd8b01ca3bd9c21e76443004907ea1bc02fb57b6e (patch)
tree59f80451f15fef9e4e1641e1aa3eb1b592c4010c /core/fxge
parentceb3ab55ca5ad1fae590f50a09f04b7ed47656b1 (diff)
downloadpdfium-d8b01ca3bd9c21e76443004907ea1bc02fb57b6e.tar.xz
Revert "Convert Origins to points"
This reverts commit da83d3a5cc09c4056310b3cf299dbbccd5c70d11. Reason for revert: Reverting chain to see if fixes Chrome roll. Original change's description: > Convert Origins to points > > This CL converts various OriginX, OriginY pairs into CFX_PointF objects. > > Change-Id: I9141f7fc713c710b2014d4fdcdec7dc93501f844 > Reviewed-on: https://pdfium-review.googlesource.com/2575 > Commit-Queue: dsinclair <dsinclair@chromium.org> > Reviewed-by: Nicolás Peña <npm@chromium.org> > TBR=tsepez@chromium.org,dsinclair@chromium.org,npm@chromium.org,pdfium-reviews@googlegroups.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= Change-Id: I949fb4ec712e2587e7d0ef0191c34db198b61dcc Reviewed-on: https://pdfium-review.googlesource.com/2696 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxge')
-rw-r--r--core/fxge/apple/fx_apple_platform.cpp11
-rw-r--r--core/fxge/cfx_renderdevice.h10
-rw-r--r--core/fxge/fx_font.h13
-rw-r--r--core/fxge/ge/cfx_renderdevice.cpp52
-rw-r--r--core/fxge/ge/fx_ge_text.cpp10
-rw-r--r--core/fxge/ifx_renderdevicedriver.h2
-rw-r--r--core/fxge/skia/fx_skia_device.cpp5
-rw-r--r--core/fxge/skia/fx_skia_device.h2
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp2
-rw-r--r--core/fxge/win32/cfx_psrenderer.h2
-rw-r--r--core/fxge/win32/fx_win32_print.cpp4
-rw-r--r--core/fxge/win32/win32_int.h2
12 files changed, 43 insertions, 72 deletions
diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp
index 3713450377..d6867384e6 100644
--- a/core/fxge/apple/fx_apple_platform.cpp
+++ b/core/fxge/apple/fx_apple_platform.cpp
@@ -39,7 +39,9 @@ bool CGDrawGlyphRun(CGContextRef pContext,
if (bNegSize)
font_size = -font_size;
+ FX_FLOAT ori_x = pCharPos[0].m_OriginX, ori_y = pCharPos[0].m_OriginY;
CFX_Matrix new_matrix;
+ new_matrix.TransformPoint(ori_x, ori_y);
if (pObject2Device)
new_matrix.Concat(*pObject2Device);
@@ -55,20 +57,17 @@ bool CGDrawGlyphRun(CGContextRef pContext,
if (!pFont->GetPlatformFont())
return false;
}
-
CFX_FixedBufGrow<uint16_t, 32> glyph_indices(nChars);
CFX_FixedBufGrow<CGPoint, 32> glyph_positions(nChars);
for (int i = 0; i < nChars; i++) {
glyph_indices[i] =
pCharPos[i].m_ExtGID ? pCharPos[i].m_ExtGID : pCharPos[i].m_GlyphIndex;
-
if (bNegSize)
- glyph_positions[i].x = -pCharPos[i].m_Origin.x;
+ glyph_positions[i].x = -pCharPos[i].m_OriginX;
else
- glyph_positions[i].x = pCharPos[i].m_Origin.x;
- glyph_positions[i].y = pCharPos[i].m_Origin.y;
+ glyph_positions[i].x = pCharPos[i].m_OriginX;
+ glyph_positions[i].y = pCharPos[i].m_OriginY;
}
-
if (bNegSize) {
new_matrix.a = -new_matrix.a;
new_matrix.c = -new_matrix.c;
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 2e9abf9963..2144206e19 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -62,14 +62,10 @@ class IFX_RenderDeviceDriver;
enum class FXPT_TYPE : uint8_t { LineTo, BezierTo, MoveTo };
-class FXTEXT_CHARPOS {
- public:
- FXTEXT_CHARPOS();
- FXTEXT_CHARPOS(const FXTEXT_CHARPOS&);
- ~FXTEXT_CHARPOS();
-
+struct FXTEXT_CHARPOS {
FX_FLOAT m_AdjustMatrix[4];
- CFX_PointF m_Origin;
+ FX_FLOAT m_OriginX;
+ FX_FLOAT m_OriginY;
uint32_t m_GlyphIndex;
int32_t m_FontCharWidth;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h
index 3c095d1976..224720fbc3 100644
--- a/core/fxge/fx_font.h
+++ b/core/fxge/fx_font.h
@@ -222,15 +222,12 @@ class CFX_GlyphBitmap {
CFX_DIBitmap m_Bitmap;
};
-class FXTEXT_GLYPHPOS {
- public:
- FXTEXT_GLYPHPOS();
- FXTEXT_GLYPHPOS(const FXTEXT_GLYPHPOS&);
- ~FXTEXT_GLYPHPOS();
-
+struct FXTEXT_GLYPHPOS {
const CFX_GlyphBitmap* m_pGlyph;
- CFX_Point m_Origin;
- CFX_PointF m_fOrigin;
+ int m_OriginX;
+ int m_OriginY;
+ FX_FLOAT m_fOriginX;
+ FX_FLOAT m_fOriginY;
};
FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs,
diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp
index 40a7b53a16..12a3dd480d 100644
--- a/core/fxge/ge/cfx_renderdevice.cpp
+++ b/core/fxge/ge/cfx_renderdevice.cpp
@@ -27,19 +27,19 @@ namespace {
void AdjustGlyphSpace(std::vector<FXTEXT_GLYPHPOS>* pGlyphAndPos) {
ASSERT(pGlyphAndPos->size() > 1);
std::vector<FXTEXT_GLYPHPOS>& glyphs = *pGlyphAndPos;
- bool bVertical = glyphs.back().m_Origin.x == glyphs.front().m_Origin.x;
- if (!bVertical && (glyphs.back().m_Origin.y != glyphs.front().m_Origin.y))
+ bool bVertical = glyphs.back().m_OriginX == glyphs.front().m_OriginX;
+ if (!bVertical && (glyphs.back().m_OriginY != glyphs.front().m_OriginY))
return;
for (size_t i = glyphs.size() - 1; i > 1; --i) {
FXTEXT_GLYPHPOS& next = glyphs[i];
- int next_origin = bVertical ? next.m_Origin.y : next.m_Origin.x;
- FX_FLOAT next_origin_f = bVertical ? next.m_fOrigin.y : next.m_fOrigin.x;
+ int next_origin = bVertical ? next.m_OriginY : next.m_OriginX;
+ FX_FLOAT next_origin_f = bVertical ? next.m_fOriginY : next.m_fOriginX;
FXTEXT_GLYPHPOS& current = glyphs[i - 1];
- int& current_origin = bVertical ? current.m_Origin.y : current.m_Origin.x;
+ int& current_origin = bVertical ? current.m_OriginY : current.m_OriginX;
FX_FLOAT current_origin_f =
- bVertical ? current.m_fOrigin.y : current.m_fOrigin.x;
+ bVertical ? current.m_fOriginY : current.m_fOriginX;
int space = next_origin - current_origin;
FX_FLOAT space_f = next_origin_f - current_origin_f;
@@ -346,21 +346,6 @@ bool ShouldDrawDeviceText(const CFX_Font* pFont, uint32_t text_flags) {
} // namespace
-FXTEXT_CHARPOS::FXTEXT_CHARPOS()
- : m_GlyphIndex(0),
- m_FontCharWidth(0),
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- m_ExtGID(0),
-#endif
- m_FallbackFontPosition(0),
- m_bGlyphAdjust(false),
- m_bFontStyle(false) {
-}
-
-FXTEXT_CHARPOS::FXTEXT_CHARPOS(const FXTEXT_CHARPOS&) = default;
-
-FXTEXT_CHARPOS::~FXTEXT_CHARPOS(){};
-
CFX_RenderDevice::CFX_RenderDevice()
: m_pBitmap(nullptr),
m_Width(0),
@@ -923,13 +908,14 @@ bool CFX_RenderDevice::DrawNormalText(int nChars,
for (size_t i = 0; i < glyphs.size(); ++i) {
FXTEXT_GLYPHPOS& glyph = glyphs[i];
const FXTEXT_CHARPOS& charpos = pCharPos[i];
-
- glyph.m_fOrigin = text2Device.Transform(charpos.m_Origin);
+ glyph.m_fOriginX = charpos.m_OriginX;
+ glyph.m_fOriginY = charpos.m_OriginY;
+ text2Device.TransformPoint(glyph.m_fOriginX, glyph.m_fOriginY);
if (anti_alias < FXFT_RENDER_MODE_LCD)
- glyph.m_Origin.x = FXSYS_round(glyph.m_fOrigin.x);
+ glyph.m_OriginX = FXSYS_round(glyph.m_fOriginX);
else
- glyph.m_Origin.x = static_cast<int>(FXSYS_floor(glyph.m_fOrigin.x));
- glyph.m_Origin.y = FXSYS_round(glyph.m_fOrigin.y);
+ glyph.m_OriginX = (int)FXSYS_floor(glyph.m_fOriginX);
+ glyph.m_OriginY = FXSYS_round(glyph.m_fOriginY);
if (charpos.m_bGlyphAdjust) {
CFX_Matrix new_matrix(
charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
@@ -975,8 +961,8 @@ bool CFX_RenderDevice::DrawNormalText(int nChars,
continue;
const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap;
bitmap.TransferBitmap(
- glyph.m_Origin.x + glyph.m_pGlyph->m_Left - pixel_left,
- glyph.m_Origin.y - glyph.m_pGlyph->m_Top - pixel_top,
+ glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left,
+ glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top,
pGlyph->GetWidth(), pGlyph->GetHeight(), pGlyph, 0, 0);
}
return SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color);
@@ -1010,13 +996,13 @@ bool CFX_RenderDevice::DrawNormalText(int nChars,
if (!glyph.m_pGlyph)
continue;
- pdfium::base::CheckedNumeric<int> left = glyph.m_Origin.x;
+ pdfium::base::CheckedNumeric<int> left = glyph.m_OriginX;
left += glyph.m_pGlyph->m_Left;
left -= pixel_left;
if (!left.IsValid())
return false;
- pdfium::base::CheckedNumeric<int> top = glyph.m_Origin.y;
+ pdfium::base::CheckedNumeric<int> top = glyph.m_OriginY;
top -= glyph.m_pGlyph->m_Top;
top -= pixel_top;
if (!top.IsValid())
@@ -1036,7 +1022,7 @@ bool CFX_RenderDevice::DrawNormalText(int nChars,
}
bool bBGRStripe = !!(text_flags & FXTEXT_BGR_STRIPE);
ncols /= 3;
- int x_subpixel = static_cast<int>(glyph.m_fOrigin.x * 3) % 3;
+ int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3;
int start_col =
pdfium::base::ValueOrDieForType<int>(pdfium::base::CheckMax(left, 0));
pdfium::base::CheckedNumeric<int> end_col_safe = left;
@@ -1079,8 +1065,8 @@ bool CFX_RenderDevice::DrawTextPath(int nChars,
charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3],
0, 0);
}
- matrix.Concat(CFX_Matrix(font_size, 0, 0, font_size, charpos.m_Origin.x,
- charpos.m_Origin.y));
+ matrix.Concat(CFX_Matrix(font_size, 0, 0, font_size, charpos.m_OriginX,
+ charpos.m_OriginY));
const CFX_PathData* pPath =
pFont->LoadGlyphPath(charpos.m_GlyphIndex, charpos.m_FontCharWidth);
if (!pPath)
diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp
index 669969db0b..cc7ef7c6d7 100644
--- a/core/fxge/ge/fx_ge_text.cpp
+++ b/core/fxge/ge/fx_ge_text.cpp
@@ -28,12 +28,6 @@ void ResetTransform(FT_Face face) {
} // namespace
-FXTEXT_GLYPHPOS::FXTEXT_GLYPHPOS() : m_pGlyph(nullptr) {}
-
-FXTEXT_GLYPHPOS::FXTEXT_GLYPHPOS(const FXTEXT_GLYPHPOS&) = default;
-
-FXTEXT_GLYPHPOS::~FXTEXT_GLYPHPOS(){};
-
ScopedFontTransform::ScopedFontTransform(FT_Face face, FXFT_Matrix* matrix)
: m_Face(face) {
FXFT_Set_Transform(m_Face, matrix, 0);
@@ -54,7 +48,7 @@ FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs,
if (!pGlyph)
continue;
- FX_SAFE_INT32 char_left = glyph.m_Origin.x;
+ FX_SAFE_INT32 char_left = glyph.m_OriginX;
char_left += pGlyph->m_Left;
if (!char_left.IsValid())
continue;
@@ -70,7 +64,7 @@ FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs,
if (!char_right.IsValid())
continue;
- FX_SAFE_INT32 char_top = glyph.m_Origin.y;
+ FX_SAFE_INT32 char_top = glyph.m_OriginY;
char_top -= pGlyph->m_Top;
if (!char_top.IsValid())
continue;
diff --git a/core/fxge/ifx_renderdevicedriver.h b/core/fxge/ifx_renderdevicedriver.h
index fd35149e42..6a5b63ba32 100644
--- a/core/fxge/ifx_renderdevicedriver.h
+++ b/core/fxge/ifx_renderdevicedriver.h
@@ -16,8 +16,8 @@ class CFX_GraphStateData;
class CFX_Matrix;
class CFX_PathData;
class CPDF_ShadingPattern;
-class FXTEXT_CHARPOS;
class IFX_Pause;
+struct FXTEXT_CHARPOS;
struct FX_RECT;
class IFX_RenderDeviceDriver {
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 3a7e22bb93..40bd321f56 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -809,8 +809,7 @@ class SkiaState {
vFlip *= -1;
for (int index = 0; index < nChars; ++index) {
const FXTEXT_CHARPOS& cp = pCharPos[index];
- m_positions[index + count] = {cp.m_Origin.x * flip,
- cp.m_Origin.y * vFlip};
+ m_positions[index + count] = {cp.m_OriginX * flip, cp.m_OriginY * vFlip};
m_glyphs[index + count] = (uint16_t)cp.m_GlyphIndex;
}
SkPoint delta;
@@ -1298,7 +1297,7 @@ bool CFX_SkiaDeviceDriver::DrawDeviceText(int nChars,
glyphs.setCount(nChars);
for (int index = 0; index < nChars; ++index) {
const FXTEXT_CHARPOS& cp = pCharPos[index];
- positions[index] = {cp.m_Origin.x * flip, cp.m_Origin.y * vFlip};
+ positions[index] = {cp.m_OriginX * flip, cp.m_OriginY * vFlip};
glyphs[index] = (uint16_t)cp.m_GlyphIndex;
}
#ifdef _SKIA_SUPPORT_PATHS_
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index ecb1104518..ff81daef46 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -13,13 +13,13 @@
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/ifx_renderdevicedriver.h"
-class FXTEXT_CHARPOS;
class SkCanvas;
class SkMatrix;
class SkPaint;
class SkPath;
class SkPictureRecorder;
class SkiaState;
+struct FXTEXT_CHARPOS;
struct SkIRect;
class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver {
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index 1cbfb6ad9a..7fc47b9a46 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -661,7 +661,7 @@ bool CFX_PSRenderer::DrawText(int nChars,
buf << "/X" << ps_fontnum << " Ff " << font_size << " Fs Sf ";
last_fontnum = ps_fontnum;
}
- buf << pCharPos[i].m_Origin.x << " " << pCharPos[i].m_Origin.y << " m";
+ buf << pCharPos[i].m_OriginX << " " << pCharPos[i].m_OriginY << " m";
CFX_ByteString hex;
hex.Format("<%02X>", ps_glyphindex);
buf << hex.AsStringC() << "Tj\n";
diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h
index 163c6180af..e941739f44 100644
--- a/core/fxge/win32/cfx_psrenderer.h
+++ b/core/fxge/win32/cfx_psrenderer.h
@@ -22,7 +22,7 @@ class CFX_FontCache;
class CFX_Matrix;
class CFX_PathData;
class CPSFont;
-class FXTEXT_CHARPOS;
+struct FXTEXT_CHARPOS;
class CFX_PSRenderer {
public:
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index fd9bc70e0e..a2ea82a94e 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -296,11 +296,11 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars,
ASSERT(charpos.m_AdjustMatrix[1] == 0);
ASSERT(charpos.m_AdjustMatrix[2] == 0);
ASSERT(charpos.m_AdjustMatrix[3] == 0);
- ASSERT(charpos.m_Origin.y == 0);
+ ASSERT(charpos.m_OriginY == 0);
// Round the spacing to the nearest integer, but keep track of the rounding
// error for calculating the next spacing value.
- FX_FLOAT fOriginX = charpos.m_Origin.x * kScaleFactor;
+ FX_FLOAT fOriginX = charpos.m_OriginX * kScaleFactor;
FX_FLOAT fPixelSpacing = fOriginX - fPreviousOriginX;
spacing[i] = FXSYS_round(fPixelSpacing);
fPreviousOriginX = fOriginX - (fPixelSpacing - spacing[i]);
diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h
index f8eae87308..974a1200e6 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -17,7 +17,7 @@
#include "core/fxge/win32/cpsoutput.h"
#include "core/fxge/win32/dwrite_int.h"
-class FXTEXT_CHARPOS;
+struct FXTEXT_CHARPOS;
struct WINDIB_Open_Args_;
typedef HANDLE(__stdcall* FuncType_GdiAddFontMemResourceEx)(PVOID pbFont,