7#include "xfa/fxfa/parser/cxfa_rectangle.h"
13#include "fxjs/xfa/cjx_node.h"
14#include "third_party/base/check.h"
15#include "third_party/base/notreached.h"
16#include "xfa/fgas/graphics/cfgas_gegraphics.h"
17#include "xfa/fxfa/parser/cxfa_corner.h"
18#include "xfa/fxfa/parser/cxfa_document.h"
19#include "xfa/fxfa/parser/cxfa_stroke.h"
79 CFGAS_GEPath* fillPath) {
80 bool bSameStyles =
true;
82 for (int32_t i = 1; i < 8; i++) {
93 for (int32_t i = 2; i < 8; i += 2) {
104 stroke1 = strokes[0];
117 for (int32_t i = 0; i < 8; i += 2) {
137 cp1 = rtWidget.TopLeft();
138 cp2 = rtWidget.TopRight();
151 cp1 = rtWidget.TopRight();
152 cp2 = rtWidget.BottomRight();
165 cp1 = rtWidget.BottomRight();
166 cp2 = rtWidget.BottomLeft();
172 sx = bInverted ?
FXSYS_PI * 3 / 2 : 0;
179 cp1 = rtWidget.BottomLeft();
180 cp2 = rtWidget.TopLeft();
194 fillPath
->MoveTo(CFX_PointF(cp1.x, cp1.y + fRadius1)
);
202 CFX_RectF rtRadius(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy);
205 rtRadius
.Offset(-fRadius1 * vx
, -fRadius1 * vy
);
207 fillPath
->ArcTo(rtRadius.TopLeft()
, rtRadius.Size()
, sx
, sy
);
211 cp.x = cp1.x + fRadius1 * vx;
212 cp.y = cp1.y + fRadius1 * vy;
218 CFX_PointF(cp1.x + fRadius1 * sx, cp1.y + fRadius1 * sy)
);
220 fillPath
->LineTo(CFX_PointF(cp2.x + fRadius2 * nx, cp2.y + fRadius2 * ny)
);
228 bool bVisible =
false;
229 for (int32_t j = 0; j < 4; j++) {
230 if (strokes[j * 2 + 1]->IsVisible()) {
238 for (int32_t i = 1; i < 8; i += 2) {
239 float fThickness = fmax(0.0, strokes[i]->GetThickness());
240 float fHalf = fThickness / 2;
245 rtWidget
.top -= fHalf;
248 rtWidget
.top += fHalf;
268 rtWidget
.left -= fHalf;
271 rtWidget
.left += fHalf;
277 Stroke(strokes, pGS, rtWidget, matrix);
289 if (!bVisible || fThickness < 0.001f)
306 NOTREACHED_NORETURN();
312 bool bSameStyles =
true;
314 for (int32_t i = 1; i < 8; i++) {
323 stroke1 = strokes[0];
325 for (int32_t i = 2; i < 8; i += 2) {
336 stroke1 = strokes[0];
346 for (int32_t i = 0; i < 8; i++) {
358 GetPath(strokes, rtWidget, path, i, bStart, !bSameStyles);
373 strokes[7]->Stroke(pGS, path, matrix);
382 FX_ARGB argbBottomRight) {
389 pathLT
.LineTo(CFX_PointF(fRight - fLineWidth, rt
.top + fLineWidth)
);
391 pathLT
.LineTo(CFX_PointF(rt
.left + fLineWidth, fBottom - fLineWidth)
);
398 pathRB
.LineTo(CFX_PointF(fRight, fBottom)
);
400 pathRB
.LineTo(CFX_PointF(rt
.left + fLineWidth, fBottom - fLineWidth)
);
401 pathRB
.LineTo(CFX_PointF(fRight - fLineWidth, fBottom - fLineWidth)
);
402 pathRB
.LineTo(CFX_PointF(fRight - fLineWidth, rt
.top + fLineWidth)
);
412 float fHalfWidth = fThickness / 2.0f;
428 float fHalfWidth = fThickness / 2.0f;
444 float fHalfWidth = fThickness / 2.0f;
456 float fHalfWidth = fThickness / 2.0f;
473 int32_t n = (nIndex & 1) ? nIndex - 1 : nIndex;
479 float offsetY = 0.0f;
480 float offsetX = 0.0f;
482 float halfAfter = 0.0f;
483 float halfBefore = 0.0f;
487 CXFA_Stroke* strokeBefore = strokes[(nIndex + 1 * 8 - 1) % 8];
496 CXFA_Stroke* strokeBefore = strokes[(nIndex + 8 - 2) % 8];
497 CXFA_Stroke* strokeAfter = strokes[(nIndex + 2) % 8];
498 if (!bRound && !bInverted) {
504 float offsetEX = 0.0f;
505 float offsetEY = 0.0f;
521 cp1 = rtWidget.TopLeft();
522 cp2 = rtWidget.TopRight();
524 cpStart.x = cp1.x - halfBefore;
525 cpStart.y = cp1.y + fRadius1;
526 offsetY = -halfAfter;
528 cpStart.x = cp1.x + fRadius1 - halfBefore;
530 offsetEX = halfAfter;
545 cp1 = rtWidget.TopRight();
546 cp2 = rtWidget.BottomRight();
548 cpStart.x = cp1.x - fRadius1;
549 cpStart.y = cp1.y - halfBefore;
553 cpStart.y = cp1.y + fRadius1 - halfBefore;
554 offsetEY = halfAfter;
569 cp1 = rtWidget.BottomRight();
570 cp2 = rtWidget.BottomLeft();
572 cpStart.x = cp1.x + halfBefore;
573 cpStart.y = cp1.y - fRadius1;
576 cpStart.x = cp1.x - fRadius1 + halfBefore;
578 offsetEX = -halfAfter;
585 sx = bInverted ?
FXSYS_PI * 3 / 2 : 0;
593 cp1 = rtWidget.BottomLeft();
594 cp2 = rtWidget.TopLeft();
596 cpStart.x = cp1.x + fRadius1;
597 cpStart.y = cp1.y + halfBefore;
598 offsetX = -halfAfter;
601 cpStart.y = cp1.y - fRadius1 + halfBefore;
602 offsetEY = -halfAfter;
620 path
.LineTo(CFX_PointF(cp2.x + fRadius2 * nx + offsetEX,
621 cp2.y + fRadius2 * ny + offsetEY)
);
630 CFX_RectF rtRadius(cp1.x + offsetX * 2, cp1.y + offsetY * 2,
631 fRadius1 * 2 * vx - offsetX * 2,
632 fRadius1 * 2 * vy - offsetY * 2);
635 rtRadius
.Offset(-fRadius1 * vx
, -fRadius1 * vy
);
637 path
.ArcTo(rtRadius.TopLeft()
, rtRadius.Size()
, sx
, sy
);
641 cp.x = cp1.x + fRadius1 * vx;
642 cp.y = cp1.y + fRadius1 * vy;
647 path
.LineTo(CFX_PointF(cp1.x + fRadius1 * sx + offsetX,
648 cp1.y + fRadius1 * sy + offsetY)
);
CFGAS_GEColor(const FX_ARGB argb)
void FillPath(const CFGAS_GEPath &path, CFX_FillRenderOptions::FillType fill_type, const CFX_Matrix &matrix)
void SetFillColor(const CFGAS_GEColor &color)
void MoveTo(const CFX_PointF &point)
void ArcTo(const CFX_PointF &pos, const CFX_SizeF &size, float startAngle, float sweepAngle)
void AddRectangle(float left, float top, float width, float height)
void LineTo(const CFX_PointF &point)
CFX_RectF(const CFX_RectF &other)=default
void Offset(float dx, float dy)
void Deflate(float x, float y)
std::tuple< XFA_AttributeValue, bool, float > Get3DStyle()
XFA_AttributeValue GetHand()
XFA_Element GetElementType() const
void GetFillPath(const std::vector< CXFA_Stroke * > &strokes, const CFX_RectF &rtWidget, CFGAS_GEPath *fillPath)
void StrokeLowered(CFGAS_GEGraphics *pGS, CFX_RectF rt, float fThickness, const CFX_Matrix &matrix)
CXFA_Rectangle(CXFA_Document *pDoc, XFA_PacketType ePacket, Mask< XFA_XDPPACKET > validPackets, XFA_ObjectType oType, XFA_Element eType, pdfium::span< const PropertyData > properties, pdfium::span< const AttributeData > attributes, CJX_Object *js_node)
~CXFA_Rectangle() override
void GetPath(const std::vector< CXFA_Stroke * > &strokes, CFX_RectF rtWidget, CFGAS_GEPath &path, int32_t nIndex, bool bStart, bool bCorner)
static CXFA_Rectangle * FromNode(CXFA_Node *pNode)
void Stroke(const std::vector< CXFA_Stroke * > &strokes, CFGAS_GEGraphics *pGS, CFX_RectF rtWidget, const CFX_Matrix &matrix)
void StrokeRaised(CFGAS_GEGraphics *pGS, CFX_RectF rt, float fThickness, const CFX_Matrix &matrix)
void Draw(const std::vector< CXFA_Stroke * > &strokes, CFGAS_GEGraphics *pGS, CFX_RectF rtWidget, const CFX_Matrix &matrix)
void StrokeEtched(CFGAS_GEGraphics *pGS, CFX_RectF rt, float fThickness, const CFX_Matrix &matrix)
void StrokeEmbossed(CFGAS_GEGraphics *pGS, CFX_RectF rt, float fThickness, const CFX_Matrix &matrix)
CXFA_Rectangle(CXFA_Document *doc, XFA_PacketType packet)
void StrokeRect(CFGAS_GEGraphics *pGraphic, const CFX_RectF &rt, float fLineWidth, const CFX_Matrix &matrix, FX_ARGB argbTopLeft, FX_ARGB argbBottomRight)
XFA_AttributeValue GetJoinType()
void Stroke(CFGAS_GEGraphics *pGS, const CFGAS_GEPath &pPath, const CFX_Matrix &matrix)
bool SameStyles(CXFA_Stroke *stroke, Mask< SameStyleOption > dwFlags)
float GetThickness() const