summaryrefslogtreecommitdiff
path: root/xfa/fxgraphics
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-14 14:43:42 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-14 19:05:58 +0000
commit05df075154a832fcb476e1dfcfb865722d0ea898 (patch)
treeb8b771b62adae74d5d5ee561db75d10de3a848bf /xfa/fxgraphics
parent6b94f01d1c8ad386d497428c7397b1a99614aeba (diff)
downloadpdfium-05df075154a832fcb476e1dfcfb865722d0ea898.tar.xz
Replace FX_FLOAT with underlying float type.
Change-Id: I158b7d80b0ec28b742a9f2d5a96f3dde7fb3ab56 Reviewed-on: https://pdfium-review.googlesource.com/3031 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'xfa/fxgraphics')
-rw-r--r--xfa/fxgraphics/cfx_graphics.cpp77
-rw-r--r--xfa/fxgraphics/cfx_graphics.h4
-rw-r--r--xfa/fxgraphics/cfx_path.cpp37
-rw-r--r--xfa/fxgraphics/cfx_path.h17
-rw-r--r--xfa/fxgraphics/cfx_shading.cpp14
-rw-r--r--xfa/fxgraphics/cfx_shading.h8
6 files changed, 75 insertions, 82 deletions
diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp
index d2f2151d91..48d8f6f80f 100644
--- a/xfa/fxgraphics/cfx_graphics.cpp
+++ b/xfa/fxgraphics/cfx_graphics.cpp
@@ -134,15 +134,15 @@ void CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) {
}
}
-void CFX_Graphics::SetLineDash(FX_FLOAT dashPhase,
- FX_FLOAT* dashArray,
+void CFX_Graphics::SetLineDash(float dashPhase,
+ float* dashArray,
int32_t dashCount) {
if (dashCount > 0 && !dashArray)
return;
dashCount = dashCount < 0 ? 0 : dashCount;
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
- FX_FLOAT scale = 1.0;
+ float scale = 1.0;
if (m_info.isActOnDash) {
scale = m_info.graphState.m_LineWidth;
}
@@ -159,7 +159,7 @@ void CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) {
RenderDeviceSetLineDash(dashStyle);
}
-void CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, bool isActOnDash) {
+void CFX_Graphics::SetLineWidth(float lineWidth, bool isActOnDash) {
if (m_type == FX_CONTEXT_Device && m_renderDevice) {
m_info.graphState.m_LineWidth = lineWidth;
m_info.isActOnDash = isActOnDash;
@@ -226,7 +226,7 @@ CFX_RectF CFX_Graphics::GetClipRect() const {
return CFX_RectF();
FX_RECT r = m_renderDevice->GetClipBox();
- return CFX_Rect(r.left, r.top, r.Width(), r.Height()).As<FX_FLOAT>();
+ return CFX_Rect(r.left, r.top, r.Width(), r.Height()).As<float>();
}
void CFX_Graphics::SetClipRect(const CFX_RectF& rect) {
@@ -248,22 +248,22 @@ void CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) {
return;
}
case FX_DASHSTYLE_Dash: {
- FX_FLOAT dashArray[] = {3, 1};
+ float dashArray[] = {3, 1};
SetLineDash(0, dashArray, 2);
return;
}
case FX_DASHSTYLE_Dot: {
- FX_FLOAT dashArray[] = {1, 1};
+ float dashArray[] = {1, 1};
SetLineDash(0, dashArray, 2);
return;
}
case FX_DASHSTYLE_DashDot: {
- FX_FLOAT dashArray[] = {3, 1, 1, 1};
+ float dashArray[] = {3, 1, 1, 1};
SetLineDash(0, dashArray, 4);
return;
}
case FX_DASHSTYLE_DashDotDot: {
- FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1};
+ float dashArray[] = {4, 1, 2, 1, 2, 1};
SetLineDash(0, dashArray, 6);
return;
}
@@ -388,10 +388,10 @@ void CFX_Graphics::FillPathWithShading(CFX_Path* path,
CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
int32_t width = bitmap->GetWidth();
int32_t height = bitmap->GetHeight();
- FX_FLOAT start_x = m_info.fillColor->m_shading->m_beginPoint.x;
- FX_FLOAT start_y = m_info.fillColor->m_shading->m_beginPoint.y;
- FX_FLOAT end_x = m_info.fillColor->m_shading->m_endPoint.x;
- FX_FLOAT end_y = m_info.fillColor->m_shading->m_endPoint.y;
+ float start_x = m_info.fillColor->m_shading->m_beginPoint.x;
+ float start_y = m_info.fillColor->m_shading->m_beginPoint.y;
+ float end_x = m_info.fillColor->m_shading->m_endPoint.x;
+ float end_y = m_info.fillColor->m_shading->m_endPoint.y;
CFX_DIBitmap bmp;
bmp.Create(width, height, FXDIB_Argb);
m_renderDevice->GetDIBits(&bmp, 0, 0);
@@ -399,17 +399,16 @@ void CFX_Graphics::FillPathWithShading(CFX_Path* path,
bool result = false;
switch (m_info.fillColor->m_shading->m_type) {
case FX_SHADING_Axial: {
- FX_FLOAT x_span = end_x - start_x;
- FX_FLOAT y_span = end_y - start_y;
- FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span);
+ float x_span = end_x - start_x;
+ float y_span = end_y - start_y;
+ float axis_len_square = (x_span * x_span) + (y_span * y_span);
for (int32_t row = 0; row < height; row++) {
uint32_t* dib_buf = (uint32_t*)(bmp.GetBuffer() + row * pitch);
for (int32_t column = 0; column < width; column++) {
- FX_FLOAT x = (FX_FLOAT)(column);
- FX_FLOAT y = (FX_FLOAT)(row);
- FX_FLOAT scale =
- (((x - start_x) * x_span) + ((y - start_y) * y_span)) /
- axis_len_square;
+ float x = (float)(column);
+ float y = (float)(row);
+ float scale = (((x - start_x) * x_span) + ((y - start_y) * y_span)) /
+ axis_len_square;
if (scale < 0) {
if (!m_info.fillColor->m_shading->m_isExtendedBegin) {
continue;
@@ -429,31 +428,31 @@ void CFX_Graphics::FillPathWithShading(CFX_Path* path,
break;
}
case FX_SHADING_Radial: {
- FX_FLOAT start_r = m_info.fillColor->m_shading->m_beginRadius;
- FX_FLOAT end_r = m_info.fillColor->m_shading->m_endRadius;
- FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) +
- ((start_y - end_y) * (start_y - end_y)) -
- ((start_r - end_r) * (start_r - end_r));
+ float start_r = m_info.fillColor->m_shading->m_beginRadius;
+ float end_r = m_info.fillColor->m_shading->m_endRadius;
+ float a = ((start_x - end_x) * (start_x - end_x)) +
+ ((start_y - end_y) * (start_y - end_y)) -
+ ((start_r - end_r) * (start_r - end_r));
for (int32_t row = 0; row < height; row++) {
uint32_t* dib_buf = (uint32_t*)(bmp.GetBuffer() + row * pitch);
for (int32_t column = 0; column < width; column++) {
- FX_FLOAT x = (FX_FLOAT)(column);
- FX_FLOAT y = (FX_FLOAT)(row);
- FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) +
- ((y - start_y) * (end_y - start_y)) +
- (start_r * (end_r - start_r)));
- FX_FLOAT c = ((x - start_x) * (x - start_x)) +
- ((y - start_y) * (y - start_y)) - (start_r * start_r);
- FX_FLOAT s;
+ float x = (float)(column);
+ float y = (float)(row);
+ float b = -2 * (((x - start_x) * (end_x - start_x)) +
+ ((y - start_y) * (end_y - start_y)) +
+ (start_r * (end_r - start_r)));
+ float c = ((x - start_x) * (x - start_x)) +
+ ((y - start_y) * (y - start_y)) - (start_r * start_r);
+ float s;
if (a == 0) {
s = -c / b;
} else {
- FX_FLOAT b2_4ac = (b * b) - 4 * (a * c);
+ float b2_4ac = (b * b) - 4 * (a * c);
if (b2_4ac < 0) {
continue;
}
- FX_FLOAT root = (FXSYS_sqrt(b2_4ac));
- FX_FLOAT s1, s2;
+ float root = (FXSYS_sqrt(b2_4ac));
+ float s1, s2;
if (a > 0) {
s1 = (-b - root) / (2 * a);
s2 = (-b + root) / (2 * a);
@@ -507,8 +506,8 @@ void CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source,
if (matrix->IsIdentity()) {
m_renderDevice->SetDIBits(source, 0, 0);
} else {
- CFX_Matrix m((FX_FLOAT)source->GetWidth(), 0, 0,
- (FX_FLOAT)source->GetHeight(), 0, 0);
+ CFX_Matrix m((float)source->GetWidth(), 0, 0, (float)source->GetHeight(), 0,
+ 0);
m.Concat(*matrix);
int32_t left;
int32_t top;
diff --git a/xfa/fxgraphics/cfx_graphics.h b/xfa/fxgraphics/cfx_graphics.h
index c18f8eb4c9..c360813401 100644
--- a/xfa/fxgraphics/cfx_graphics.h
+++ b/xfa/fxgraphics/cfx_graphics.h
@@ -54,9 +54,9 @@ class CFX_Graphics {
CFX_RenderDevice* GetRenderDevice();
void SetLineCap(CFX_GraphStateData::LineCap lineCap);
- void SetLineDash(FX_FLOAT dashPhase, FX_FLOAT* dashArray, int32_t dashCount);
+ void SetLineDash(float dashPhase, float* dashArray, int32_t dashCount);
void SetLineDash(FX_DashStyle dashStyle);
- void SetLineWidth(FX_FLOAT lineWidth, bool isActOnDash = false);
+ void SetLineWidth(float lineWidth, bool isActOnDash = false);
void SetStrokeColor(CFX_Color* color);
void SetFillColor(CFX_Color* color);
void SetClipRect(const CFX_RectF& rect);
diff --git a/xfa/fxgraphics/cfx_path.cpp b/xfa/fxgraphics/cfx_path.cpp
index d56eb13f67..5ff9bffb07 100644
--- a/xfa/fxgraphics/cfx_path.cpp
+++ b/xfa/fxgraphics/cfx_path.cpp
@@ -39,8 +39,8 @@ void CFX_Path::BezierTo(const CFX_PointF& c1,
void CFX_Path::ArcTo(const CFX_PointF& pos,
const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle) {
+ float start_angle,
+ float sweep_angle) {
CFX_SizeF new_size = size / 2.0f;
ArcToInternal(CFX_PointF(pos.x + new_size.width, pos.y + new_size.height),
new_size, start_angle, sweep_angle);
@@ -48,16 +48,16 @@ void CFX_Path::ArcTo(const CFX_PointF& pos,
void CFX_Path::ArcToInternal(const CFX_PointF& pos,
const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle) {
- FX_FLOAT x0 = FXSYS_cos(sweep_angle / 2);
- FX_FLOAT y0 = FXSYS_sin(sweep_angle / 2);
- FX_FLOAT tx = ((1.0f - x0) * 4) / (3 * 1.0f);
- FX_FLOAT ty = y0 - ((tx * x0) / y0);
+ float start_angle,
+ float sweep_angle) {
+ float x0 = FXSYS_cos(sweep_angle / 2);
+ float y0 = FXSYS_sin(sweep_angle / 2);
+ float tx = ((1.0f - x0) * 4) / (3 * 1.0f);
+ float ty = y0 - ((tx * x0) / y0);
CFX_PointF points[] = {CFX_PointF(x0 + tx, -ty), CFX_PointF(x0 + tx, ty)};
- FX_FLOAT sn = FXSYS_sin(start_angle + sweep_angle / 2);
- FX_FLOAT cs = FXSYS_cos(start_angle + sweep_angle / 2);
+ float sn = FXSYS_sin(start_angle + sweep_angle / 2);
+ float cs = FXSYS_cos(start_angle + sweep_angle / 2);
CFX_PointF bezier;
bezier.x = pos.x + (size.width * ((points[0].x * cs) - (points[0].y * sn)));
@@ -78,10 +78,7 @@ void CFX_Path::AddLine(const CFX_PointF& p1, const CFX_PointF& p2) {
data_.AppendPoint(p2, FXPT_TYPE::LineTo, false);
}
-void CFX_Path::AddRectangle(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height) {
+void CFX_Path::AddRectangle(float left, float top, float width, float height) {
data_.AppendRect(left, top, left + width, top + height);
}
@@ -91,12 +88,12 @@ void CFX_Path::AddEllipse(const CFX_RectF& rect) {
void CFX_Path::AddArc(const CFX_PointF& original_pos,
const CFX_SizeF& original_size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle) {
+ float start_angle,
+ float sweep_angle) {
if (sweep_angle == 0)
return;
- const FX_FLOAT bezier_arc_angle_epsilon = 0.01f;
+ const float bezier_arc_angle_epsilon = 0.01f;
while (start_angle > FX_PI * 2)
start_angle -= FX_PI * 2;
while (start_angle < 0)
@@ -112,9 +109,9 @@ void CFX_Path::AddArc(const CFX_PointF& original_pos,
size.height * FXSYS_sin(start_angle)),
FXPT_TYPE::MoveTo, false);
- FX_FLOAT total_sweep = 0;
- FX_FLOAT local_sweep = 0;
- FX_FLOAT prev_sweep = 0;
+ float total_sweep = 0;
+ float local_sweep = 0;
+ float prev_sweep = 0;
bool done = false;
do {
if (sweep_angle < 0) {
diff --git a/xfa/fxgraphics/cfx_path.h b/xfa/fxgraphics/cfx_path.h
index 267831603a..186465f810 100644
--- a/xfa/fxgraphics/cfx_path.h
+++ b/xfa/fxgraphics/cfx_path.h
@@ -30,27 +30,24 @@ class CFX_Path final {
const CFX_PointF& to);
void ArcTo(const CFX_PointF& pos,
const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
+ float startAngle,
+ float sweepAngle);
void AddLine(const CFX_PointF& p1, const CFX_PointF& p2);
- void AddRectangle(FX_FLOAT left,
- FX_FLOAT top,
- FX_FLOAT width,
- FX_FLOAT height);
+ void AddRectangle(float left, float top, float width, float height);
void AddEllipse(const CFX_RectF& rect);
void AddArc(const CFX_PointF& pos,
const CFX_SizeF& size,
- FX_FLOAT startAngle,
- FX_FLOAT sweepAngle);
+ float startAngle,
+ float sweepAngle);
void AddSubpath(CFX_Path* path);
private:
void ArcToInternal(const CFX_PointF& pos,
const CFX_SizeF& size,
- FX_FLOAT start_angle,
- FX_FLOAT sweep_angle);
+ float start_angle,
+ float sweep_angle);
CFX_PathData data_;
};
diff --git a/xfa/fxgraphics/cfx_shading.cpp b/xfa/fxgraphics/cfx_shading.cpp
index 07936302c9..7dc8ce3412 100644
--- a/xfa/fxgraphics/cfx_shading.cpp
+++ b/xfa/fxgraphics/cfx_shading.cpp
@@ -26,8 +26,8 @@ CFX_Shading::CFX_Shading(const CFX_PointF& beginPoint,
CFX_Shading::CFX_Shading(const CFX_PointF& beginPoint,
const CFX_PointF& endPoint,
- const FX_FLOAT beginRadius,
- const FX_FLOAT endRadius,
+ const float beginRadius,
+ const float endRadius,
bool isExtendedBegin,
bool isExtendedEnd,
const FX_ARGB beginArgb,
@@ -59,11 +59,11 @@ void CFX_Shading::InitArgbArray() {
int32_t b2;
ArgbDecode(m_endArgb, a2, r2, g2, b2);
- FX_FLOAT f = (FX_FLOAT)(FX_SHADING_Steps - 1);
- FX_FLOAT aScale = 1.0 * (a2 - a1) / f;
- FX_FLOAT rScale = 1.0 * (r2 - r1) / f;
- FX_FLOAT gScale = 1.0 * (g2 - g1) / f;
- FX_FLOAT bScale = 1.0 * (b2 - b1) / f;
+ float f = (float)(FX_SHADING_Steps - 1);
+ float aScale = 1.0 * (a2 - a1) / f;
+ float rScale = 1.0 * (r2 - r1) / f;
+ float gScale = 1.0 * (g2 - g1) / f;
+ float bScale = 1.0 * (b2 - b1) / f;
for (int32_t i = 0; i < FX_SHADING_Steps; i++) {
int32_t a3 = static_cast<int32_t>(i * aScale);
diff --git a/xfa/fxgraphics/cfx_shading.h b/xfa/fxgraphics/cfx_shading.h
index 4189581895..1fb34d2b07 100644
--- a/xfa/fxgraphics/cfx_shading.h
+++ b/xfa/fxgraphics/cfx_shading.h
@@ -28,8 +28,8 @@ class CFX_Shading {
// Radial shading.
CFX_Shading(const CFX_PointF& beginPoint,
const CFX_PointF& endPoint,
- const FX_FLOAT beginRadius,
- const FX_FLOAT endRadius,
+ const float beginRadius,
+ const float endRadius,
bool isExtendedBegin,
bool isExtendedEnd,
const FX_ARGB beginArgb,
@@ -44,8 +44,8 @@ class CFX_Shading {
const CFX_Shading_Type m_type;
const CFX_PointF m_beginPoint;
const CFX_PointF m_endPoint;
- const FX_FLOAT m_beginRadius;
- const FX_FLOAT m_endRadius;
+ const float m_beginRadius;
+ const float m_endRadius;
const bool m_isExtendedBegin;
const bool m_isExtendedEnd;
const FX_ARGB m_beginArgb;