| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxgraphics/cfx_graphics.h" | 7 #include "xfa/fxgraphics/cfx_graphics.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 0x00, 0x00, 0x00, 0x00, | 566 0x00, 0x00, 0x00, 0x00, |
| 567 }}, | 567 }}, |
| 568 }; | 568 }; |
| 569 | 569 |
| 570 } // namespace | 570 } // namespace |
| 571 | 571 |
| 572 CFX_Graphics::CFX_Graphics() | 572 CFX_Graphics::CFX_Graphics() |
| 573 : m_type(FX_CONTEXT_None), m_renderDevice(nullptr) {} | 573 : m_type(FX_CONTEXT_None), m_renderDevice(nullptr) {} |
| 574 | 574 |
| 575 FWL_Error CFX_Graphics::Create(CFX_RenderDevice* renderDevice, | 575 FWL_Error CFX_Graphics::Create(CFX_RenderDevice* renderDevice, |
| 576 FX_BOOL isAntialiasing) { | 576 bool isAntialiasing) { |
| 577 if (!renderDevice) | 577 if (!renderDevice) |
| 578 return FWL_Error::ParameterInvalid; | 578 return FWL_Error::ParameterInvalid; |
| 579 if (m_type != FX_CONTEXT_None) | 579 if (m_type != FX_CONTEXT_None) |
| 580 return FWL_Error::PropertyInvalid; | 580 return FWL_Error::PropertyInvalid; |
| 581 | 581 |
| 582 m_type = FX_CONTEXT_Device; | 582 m_type = FX_CONTEXT_Device; |
| 583 m_info.isAntialiasing = isAntialiasing; | 583 m_info.isAntialiasing = isAntialiasing; |
| 584 m_renderDevice = renderDevice; | 584 m_renderDevice = renderDevice; |
| 585 if (m_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP) | 585 if (m_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP) |
| 586 return FWL_Error::Succeeded; | 586 return FWL_Error::Succeeded; |
| 587 return FWL_Error::Indefinite; | 587 return FWL_Error::Indefinite; |
| 588 } | 588 } |
| 589 | 589 |
| 590 FWL_Error CFX_Graphics::Create(int32_t width, | 590 FWL_Error CFX_Graphics::Create(int32_t width, |
| 591 int32_t height, | 591 int32_t height, |
| 592 FXDIB_Format format, | 592 FXDIB_Format format, |
| 593 FX_BOOL isNative, | 593 bool isNative, |
| 594 FX_BOOL isAntialiasing) { | 594 bool isAntialiasing) { |
| 595 if (m_type != FX_CONTEXT_None) | 595 if (m_type != FX_CONTEXT_None) |
| 596 return FWL_Error::PropertyInvalid; | 596 return FWL_Error::PropertyInvalid; |
| 597 | 597 |
| 598 m_type = FX_CONTEXT_Device; | 598 m_type = FX_CONTEXT_Device; |
| 599 m_info.isAntialiasing = isAntialiasing; | 599 m_info.isAntialiasing = isAntialiasing; |
| 600 m_aggGraphics.reset(new CAGG_Graphics); | 600 m_aggGraphics.reset(new CAGG_Graphics); |
| 601 return m_aggGraphics->Create(this, width, height, format); | 601 return m_aggGraphics->Create(this, width, height, format); |
| 602 } | 602 } |
| 603 | 603 |
| 604 CFX_Graphics::~CFX_Graphics() {} | 604 CFX_Graphics::~CFX_Graphics() {} |
| 605 | 605 |
| 606 FWL_Error CFX_Graphics::GetDeviceCap(const int32_t capID, | 606 FWL_Error CFX_Graphics::GetDeviceCap(const int32_t capID, |
| 607 FX_DeviceCap& capVal) { | 607 FX_DeviceCap& capVal) { |
| 608 if (m_type == FX_CONTEXT_Device && m_renderDevice) { | 608 if (m_type == FX_CONTEXT_Device && m_renderDevice) { |
| 609 capVal = m_renderDevice->GetDeviceCaps(capID); | 609 capVal = m_renderDevice->GetDeviceCaps(capID); |
| 610 return FWL_Error::Succeeded; | 610 return FWL_Error::Succeeded; |
| 611 } | 611 } |
| 612 return FWL_Error::PropertyInvalid; | 612 return FWL_Error::PropertyInvalid; |
| 613 } | 613 } |
| 614 | 614 |
| 615 FWL_Error CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) { | 615 FWL_Error CFX_Graphics::IsPrinterDevice(bool& isPrinter) { |
| 616 if (m_type == FX_CONTEXT_Device && m_renderDevice) { | 616 if (m_type == FX_CONTEXT_Device && m_renderDevice) { |
| 617 isPrinter = m_renderDevice->GetDeviceClass() == FXDC_PRINTER; | 617 isPrinter = m_renderDevice->GetDeviceClass() == FXDC_PRINTER; |
| 618 return FWL_Error::Succeeded; | 618 return FWL_Error::Succeeded; |
| 619 } | 619 } |
| 620 return FWL_Error::PropertyInvalid; | 620 return FWL_Error::PropertyInvalid; |
| 621 } | 621 } |
| 622 | 622 |
| 623 FWL_Error CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) { | 623 FWL_Error CFX_Graphics::EnableAntialiasing(bool isAntialiasing) { |
| 624 if (m_type == FX_CONTEXT_Device && m_renderDevice) { | 624 if (m_type == FX_CONTEXT_Device && m_renderDevice) { |
| 625 m_info.isAntialiasing = isAntialiasing; | 625 m_info.isAntialiasing = isAntialiasing; |
| 626 return FWL_Error::Succeeded; | 626 return FWL_Error::Succeeded; |
| 627 } | 627 } |
| 628 return FWL_Error::PropertyInvalid; | 628 return FWL_Error::PropertyInvalid; |
| 629 } | 629 } |
| 630 | 630 |
| 631 FWL_Error CFX_Graphics::SaveGraphState() { | 631 FWL_Error CFX_Graphics::SaveGraphState() { |
| 632 if (m_type == FX_CONTEXT_Device && m_renderDevice) { | 632 if (m_type == FX_CONTEXT_Device && m_renderDevice) { |
| 633 m_renderDevice->SaveState(); | 633 m_renderDevice->SaveState(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 } | 754 } |
| 755 | 755 |
| 756 FWL_Error CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) const { | 756 FWL_Error CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) const { |
| 757 if (m_type == FX_CONTEXT_Device && m_renderDevice) { | 757 if (m_type == FX_CONTEXT_Device && m_renderDevice) { |
| 758 lineWidth = m_info.graphState.m_LineWidth; | 758 lineWidth = m_info.graphState.m_LineWidth; |
| 759 return FWL_Error::Succeeded; | 759 return FWL_Error::Succeeded; |
| 760 } | 760 } |
| 761 return FWL_Error::PropertyInvalid; | 761 return FWL_Error::PropertyInvalid; |
| 762 } | 762 } |
| 763 | 763 |
| 764 FWL_Error CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) { | 764 FWL_Error CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, bool isActOnDash) { |
| 765 if (m_type == FX_CONTEXT_Device && m_renderDevice) { | 765 if (m_type == FX_CONTEXT_Device && m_renderDevice) { |
| 766 m_info.graphState.m_LineWidth = lineWidth; | 766 m_info.graphState.m_LineWidth = lineWidth; |
| 767 m_info.isActOnDash = isActOnDash; | 767 m_info.isActOnDash = isActOnDash; |
| 768 return FWL_Error::Succeeded; | 768 return FWL_Error::Succeeded; |
| 769 } | 769 } |
| 770 return FWL_Error::PropertyInvalid; | 770 return FWL_Error::PropertyInvalid; |
| 771 } | 771 } |
| 772 | 772 |
| 773 FWL_Error CFX_Graphics::GetStrokeAlignment( | 773 FWL_Error CFX_Graphics::GetStrokeAlignment( |
| 774 FX_StrokeAlignment& strokeAlignment) const { | 774 FX_StrokeAlignment& strokeAlignment) const { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 return RenderDeviceFillPath(path, fillMode, matrix); | 824 return RenderDeviceFillPath(path, fillMode, matrix); |
| 825 return FWL_Error::PropertyInvalid; | 825 return FWL_Error::PropertyInvalid; |
| 826 } | 826 } |
| 827 | 827 |
| 828 FWL_Error CFX_Graphics::ClipPath(CFX_Path* path, | 828 FWL_Error CFX_Graphics::ClipPath(CFX_Path* path, |
| 829 FX_FillMode fillMode, | 829 FX_FillMode fillMode, |
| 830 CFX_Matrix* matrix) { | 830 CFX_Matrix* matrix) { |
| 831 if (!path) | 831 if (!path) |
| 832 return FWL_Error::ParameterInvalid; | 832 return FWL_Error::ParameterInvalid; |
| 833 if (m_type == FX_CONTEXT_Device && m_renderDevice) { | 833 if (m_type == FX_CONTEXT_Device && m_renderDevice) { |
| 834 FX_BOOL result = | 834 bool result = |
| 835 m_renderDevice->SetClip_PathFill(path->GetPathData(), matrix, fillMode); | 835 m_renderDevice->SetClip_PathFill(path->GetPathData(), matrix, fillMode); |
| 836 if (!result) | 836 if (!result) |
| 837 return FWL_Error::Indefinite; | 837 return FWL_Error::Indefinite; |
| 838 return FWL_Error::Succeeded; | 838 return FWL_Error::Succeeded; |
| 839 } | 839 } |
| 840 return FWL_Error::PropertyInvalid; | 840 return FWL_Error::PropertyInvalid; |
| 841 } | 841 } |
| 842 | 842 |
| 843 FWL_Error CFX_Graphics::DrawImage(CFX_DIBSource* source, | 843 FWL_Error CFX_Graphics::DrawImage(CFX_DIBSource* source, |
| 844 const CFX_PointF& point, | 844 const CFX_PointF& point, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 FWL_Error CFX_Graphics::ShowText(const CFX_PointF& point, | 949 FWL_Error CFX_Graphics::ShowText(const CFX_PointF& point, |
| 950 const CFX_WideString& text, | 950 const CFX_WideString& text, |
| 951 CFX_Matrix* matrix) { | 951 CFX_Matrix* matrix) { |
| 952 if (m_type == FX_CONTEXT_Device && m_renderDevice) | 952 if (m_type == FX_CONTEXT_Device && m_renderDevice) |
| 953 return RenderDeviceShowText(point, text, matrix); | 953 return RenderDeviceShowText(point, text, matrix); |
| 954 return FWL_Error::PropertyInvalid; | 954 return FWL_Error::PropertyInvalid; |
| 955 } | 955 } |
| 956 | 956 |
| 957 void CFX_Graphics::CalcTextRect(CFX_RectF& rect, | 957 void CFX_Graphics::CalcTextRect(CFX_RectF& rect, |
| 958 const CFX_WideString& text, | 958 const CFX_WideString& text, |
| 959 FX_BOOL isMultiline, | 959 bool isMultiline, |
| 960 CFX_Matrix* matrix) { | 960 CFX_Matrix* matrix) { |
| 961 if (m_type != FX_CONTEXT_Device || !m_renderDevice) | 961 if (m_type != FX_CONTEXT_Device || !m_renderDevice) |
| 962 return; | 962 return; |
| 963 | 963 |
| 964 int32_t length = text.GetLength(); | 964 int32_t length = text.GetLength(); |
| 965 uint32_t* charCodes = FX_Alloc(uint32_t, length); | 965 uint32_t* charCodes = FX_Alloc(uint32_t, length); |
| 966 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); | 966 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); |
| 967 CalcTextInfo(text, charCodes, charPos, rect); | 967 CalcTextInfo(text, charCodes, charPos, rect); |
| 968 FX_Free(charPos); | 968 FX_Free(charPos); |
| 969 FX_Free(charCodes); | 969 FX_Free(charCodes); |
| 970 } | 970 } |
| 971 | 971 |
| 972 FWL_Error CFX_Graphics::Transfer(CFX_Graphics* graphics, | 972 FWL_Error CFX_Graphics::Transfer(CFX_Graphics* graphics, |
| 973 const CFX_Matrix* matrix) { | 973 const CFX_Matrix* matrix) { |
| 974 if (!graphics || !graphics->m_renderDevice) | 974 if (!graphics || !graphics->m_renderDevice) |
| 975 return FWL_Error::ParameterInvalid; | 975 return FWL_Error::ParameterInvalid; |
| 976 CFX_Matrix m; | 976 CFX_Matrix m; |
| 977 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, | 977 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, |
| 978 m_info.CTM.f); | 978 m_info.CTM.f); |
| 979 if (matrix) { | 979 if (matrix) { |
| 980 m.Concat(*matrix); | 980 m.Concat(*matrix); |
| 981 } | 981 } |
| 982 if (m_type == FX_CONTEXT_Device && m_renderDevice) { | 982 if (m_type == FX_CONTEXT_Device && m_renderDevice) { |
| 983 CFX_DIBitmap* bitmap = graphics->m_renderDevice->GetBitmap(); | 983 CFX_DIBitmap* bitmap = graphics->m_renderDevice->GetBitmap(); |
| 984 FX_BOOL result = m_renderDevice->SetDIBits(bitmap, 0, 0); | 984 bool result = m_renderDevice->SetDIBits(bitmap, 0, 0); |
| 985 if (!result) | 985 if (!result) |
| 986 return FWL_Error::MethodNotSupported; | 986 return FWL_Error::MethodNotSupported; |
| 987 return FWL_Error::Succeeded; | 987 return FWL_Error::Succeeded; |
| 988 } | 988 } |
| 989 return FWL_Error::PropertyInvalid; | 989 return FWL_Error::PropertyInvalid; |
| 990 } | 990 } |
| 991 | 991 |
| 992 FWL_Error CFX_Graphics::Transfer(CFX_Graphics* graphics, | 992 FWL_Error CFX_Graphics::Transfer(CFX_Graphics* graphics, |
| 993 FX_FLOAT srcLeft, | 993 FX_FLOAT srcLeft, |
| 994 FX_FLOAT srcTop, | 994 FX_FLOAT srcTop, |
| 995 const CFX_RectF& dstRect, | 995 const CFX_RectF& dstRect, |
| 996 const CFX_Matrix* matrix) { | 996 const CFX_Matrix* matrix) { |
| 997 if (!graphics || !graphics->m_renderDevice) | 997 if (!graphics || !graphics->m_renderDevice) |
| 998 return FWL_Error::ParameterInvalid; | 998 return FWL_Error::ParameterInvalid; |
| 999 CFX_Matrix m; | 999 CFX_Matrix m; |
| 1000 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, | 1000 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, |
| 1001 m_info.CTM.f); | 1001 m_info.CTM.f); |
| 1002 if (matrix) { | 1002 if (matrix) { |
| 1003 m.Concat(*matrix); | 1003 m.Concat(*matrix); |
| 1004 } | 1004 } |
| 1005 if (m_type == FX_CONTEXT_Device && m_renderDevice) { | 1005 if (m_type == FX_CONTEXT_Device && m_renderDevice) { |
| 1006 CFX_DIBitmap bmp; | 1006 CFX_DIBitmap bmp; |
| 1007 FX_BOOL result = | 1007 bool result = |
| 1008 bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height, | 1008 bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height, |
| 1009 graphics->m_renderDevice->GetBitmap()->GetFormat()); | 1009 graphics->m_renderDevice->GetBitmap()->GetFormat()); |
| 1010 if (!result) | 1010 if (!result) |
| 1011 return FWL_Error::IntermediateValueInvalid; | 1011 return FWL_Error::IntermediateValueInvalid; |
| 1012 result = graphics->m_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft, | 1012 result = graphics->m_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft, |
| 1013 (int32_t)srcTop); | 1013 (int32_t)srcTop); |
| 1014 if (!result) | 1014 if (!result) |
| 1015 return FWL_Error::MethodNotSupported; | 1015 return FWL_Error::MethodNotSupported; |
| 1016 result = m_renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left, | 1016 result = m_renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left, |
| 1017 (int32_t)dstRect.top); | 1017 (int32_t)dstRect.top); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 if (!m_info.strokeColor) | 1163 if (!m_info.strokeColor) |
| 1164 return FWL_Error::PropertyInvalid; | 1164 return FWL_Error::PropertyInvalid; |
| 1165 CFX_Matrix m; | 1165 CFX_Matrix m; |
| 1166 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, | 1166 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, |
| 1167 m_info.CTM.f); | 1167 m_info.CTM.f); |
| 1168 if (matrix) { | 1168 if (matrix) { |
| 1169 m.Concat(*matrix); | 1169 m.Concat(*matrix); |
| 1170 } | 1170 } |
| 1171 switch (m_info.strokeColor->m_type) { | 1171 switch (m_info.strokeColor->m_type) { |
| 1172 case FX_COLOR_Solid: { | 1172 case FX_COLOR_Solid: { |
| 1173 FX_BOOL result = | 1173 bool result = |
| 1174 m_renderDevice->DrawPath(path->GetPathData(), &m, &m_info.graphState, | 1174 m_renderDevice->DrawPath(path->GetPathData(), &m, &m_info.graphState, |
| 1175 0x0, m_info.strokeColor->m_info.argb, 0); | 1175 0x0, m_info.strokeColor->m_info.argb, 0); |
| 1176 if (!result) | 1176 if (!result) |
| 1177 return FWL_Error::Indefinite; | 1177 return FWL_Error::Indefinite; |
| 1178 return FWL_Error::Succeeded; | 1178 return FWL_Error::Succeeded; |
| 1179 } | 1179 } |
| 1180 case FX_COLOR_Pattern: | 1180 case FX_COLOR_Pattern: |
| 1181 return StrokePathWithPattern(path, &m); | 1181 return StrokePathWithPattern(path, &m); |
| 1182 case FX_COLOR_Shading: | 1182 case FX_COLOR_Shading: |
| 1183 return StrokePathWithShading(path, &m); | 1183 return StrokePathWithShading(path, &m); |
| 1184 default: | 1184 default: |
| 1185 return FWL_Error::PropertyInvalid; | 1185 return FWL_Error::PropertyInvalid; |
| 1186 } | 1186 } |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 FWL_Error CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, | 1189 FWL_Error CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, |
| 1190 FX_FillMode fillMode, | 1190 FX_FillMode fillMode, |
| 1191 CFX_Matrix* matrix) { | 1191 CFX_Matrix* matrix) { |
| 1192 if (!m_info.fillColor) | 1192 if (!m_info.fillColor) |
| 1193 return FWL_Error::PropertyInvalid; | 1193 return FWL_Error::PropertyInvalid; |
| 1194 CFX_Matrix m; | 1194 CFX_Matrix m; |
| 1195 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, | 1195 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, |
| 1196 m_info.CTM.f); | 1196 m_info.CTM.f); |
| 1197 if (matrix) { | 1197 if (matrix) { |
| 1198 m.Concat(*matrix); | 1198 m.Concat(*matrix); |
| 1199 } | 1199 } |
| 1200 switch (m_info.fillColor->m_type) { | 1200 switch (m_info.fillColor->m_type) { |
| 1201 case FX_COLOR_Solid: { | 1201 case FX_COLOR_Solid: { |
| 1202 FX_BOOL result = m_renderDevice->DrawPath( | 1202 bool result = m_renderDevice->DrawPath( |
| 1203 path->GetPathData(), &m, &m_info.graphState, | 1203 path->GetPathData(), &m, &m_info.graphState, |
| 1204 m_info.fillColor->m_info.argb, 0x0, fillMode); | 1204 m_info.fillColor->m_info.argb, 0x0, fillMode); |
| 1205 if (!result) | 1205 if (!result) |
| 1206 return FWL_Error::Indefinite; | 1206 return FWL_Error::Indefinite; |
| 1207 return FWL_Error::Succeeded; | 1207 return FWL_Error::Succeeded; |
| 1208 } | 1208 } |
| 1209 case FX_COLOR_Pattern: | 1209 case FX_COLOR_Pattern: |
| 1210 return FillPathWithPattern(path, fillMode, &m); | 1210 return FillPathWithPattern(path, fillMode, &m); |
| 1211 case FX_COLOR_Shading: | 1211 case FX_COLOR_Shading: |
| 1212 return FillPathWithShading(path, fillMode, &m); | 1212 return FillPathWithShading(path, fillMode, &m); |
| 1213 default: | 1213 default: |
| 1214 return FWL_Error::PropertyInvalid; | 1214 return FWL_Error::PropertyInvalid; |
| 1215 } | 1215 } |
| 1216 } | 1216 } |
| 1217 | 1217 |
| 1218 FWL_Error CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source, | 1218 FWL_Error CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source, |
| 1219 const CFX_PointF& point, | 1219 const CFX_PointF& point, |
| 1220 CFX_Matrix* matrix) { | 1220 CFX_Matrix* matrix) { |
| 1221 CFX_Matrix m1; | 1221 CFX_Matrix m1; |
| 1222 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, | 1222 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, |
| 1223 m_info.CTM.f); | 1223 m_info.CTM.f); |
| 1224 if (matrix) { | 1224 if (matrix) { |
| 1225 m1.Concat(*matrix); | 1225 m1.Concat(*matrix); |
| 1226 } | 1226 } |
| 1227 CFX_Matrix m2; | 1227 CFX_Matrix m2; |
| 1228 m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), | 1228 m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), |
| 1229 point.x, point.y); | 1229 point.x, point.y); |
| 1230 m2.Concat(m1); | 1230 m2.Concat(m1); |
| 1231 int32_t left, top; | 1231 int32_t left, top; |
| 1232 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(FALSE, TRUE)); | 1232 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(false, true)); |
| 1233 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->TransformTo(&m2, left, top)); | 1233 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->TransformTo(&m2, left, top)); |
| 1234 CFX_RectF r; | 1234 CFX_RectF r; |
| 1235 GetClipRect(r); | 1235 GetClipRect(r); |
| 1236 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); | 1236 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); |
| 1237 CFX_DIBitmap bmp; | 1237 CFX_DIBitmap bmp; |
| 1238 if (bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb) && | 1238 if (bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb) && |
| 1239 m_renderDevice->GetDIBits(&bmp, 0, 0) && | 1239 m_renderDevice->GetDIBits(&bmp, 0, 0) && |
| 1240 bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top), | 1240 bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top), |
| 1241 FXSYS_round(r.Width()), FXSYS_round(r.Height()), | 1241 FXSYS_round(r.Width()), FXSYS_round(r.Height()), |
| 1242 bmp2.get(), FXSYS_round(r.left - left), | 1242 bmp2.get(), FXSYS_round(r.left - left), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1255 m_info.CTM.f); | 1255 m_info.CTM.f); |
| 1256 if (matrix) { | 1256 if (matrix) { |
| 1257 m1.Concat(*matrix); | 1257 m1.Concat(*matrix); |
| 1258 } | 1258 } |
| 1259 std::unique_ptr<CFX_DIBitmap> bmp1( | 1259 std::unique_ptr<CFX_DIBitmap> bmp1( |
| 1260 source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height())); | 1260 source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height())); |
| 1261 CFX_Matrix m2; | 1261 CFX_Matrix m2; |
| 1262 m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); | 1262 m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); |
| 1263 m2.Concat(m1); | 1263 m2.Concat(m1); |
| 1264 int32_t left, top; | 1264 int32_t left, top; |
| 1265 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->FlipImage(FALSE, TRUE)); | 1265 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->FlipImage(false, true)); |
| 1266 std::unique_ptr<CFX_DIBitmap> bmp3(bmp2->TransformTo(&m2, left, top)); | 1266 std::unique_ptr<CFX_DIBitmap> bmp3(bmp2->TransformTo(&m2, left, top)); |
| 1267 CFX_RectF r; | 1267 CFX_RectF r; |
| 1268 GetClipRect(r); | 1268 GetClipRect(r); |
| 1269 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); | 1269 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); |
| 1270 if (bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), | 1270 if (bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), |
| 1271 FXSYS_round(r.Width()), FXSYS_round(r.Height()), | 1271 FXSYS_round(r.Width()), FXSYS_round(r.Height()), |
| 1272 bmp3.get(), FXSYS_round(r.left - left), | 1272 bmp3.get(), FXSYS_round(r.left - left), |
| 1273 FXSYS_round(r.top - top))) { | 1273 FXSYS_round(r.top - top))) { |
| 1274 return FWL_Error::Succeeded; | 1274 return FWL_Error::Succeeded; |
| 1275 } | 1275 } |
| 1276 return FWL_Error::Indefinite; | 1276 return FWL_Error::Indefinite; |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 FWL_Error CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point, | 1279 FWL_Error CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point, |
| 1280 const CFX_WideString& text, | 1280 const CFX_WideString& text, |
| 1281 CFX_Matrix* matrix) { | 1281 CFX_Matrix* matrix) { |
| 1282 int32_t length = text.GetLength(); | 1282 int32_t length = text.GetLength(); |
| 1283 uint32_t* charCodes = FX_Alloc(uint32_t, length); | 1283 uint32_t* charCodes = FX_Alloc(uint32_t, length); |
| 1284 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); | 1284 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); |
| 1285 CFX_RectF rect; | 1285 CFX_RectF rect; |
| 1286 rect.Set(point.x, point.y, 0, 0); | 1286 rect.Set(point.x, point.y, 0, 0); |
| 1287 CalcTextInfo(text, charCodes, charPos, rect); | 1287 CalcTextInfo(text, charCodes, charPos, rect); |
| 1288 CFX_Matrix m; | 1288 CFX_Matrix m; |
| 1289 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, | 1289 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, |
| 1290 m_info.CTM.f); | 1290 m_info.CTM.f); |
| 1291 m.Translate(0, m_info.fontSize * m_info.fontHScale); | 1291 m.Translate(0, m_info.fontSize * m_info.fontHScale); |
| 1292 if (matrix) { | 1292 if (matrix) { |
| 1293 m.Concat(*matrix); | 1293 m.Concat(*matrix); |
| 1294 } | 1294 } |
| 1295 FX_BOOL result = m_renderDevice->DrawNormalText( | 1295 bool result = m_renderDevice->DrawNormalText( |
| 1296 length, charPos, m_info.font, -m_info.fontSize * m_info.fontHScale, &m, | 1296 length, charPos, m_info.font, -m_info.fontSize * m_info.fontHScale, &m, |
| 1297 m_info.fillColor->m_info.argb, FXTEXT_CLEARTYPE); | 1297 m_info.fillColor->m_info.argb, FXTEXT_CLEARTYPE); |
| 1298 if (!result) | 1298 if (!result) |
| 1299 return FWL_Error::Indefinite; | 1299 return FWL_Error::Indefinite; |
| 1300 FX_Free(charPos); | 1300 FX_Free(charPos); |
| 1301 FX_Free(charCodes); | 1301 FX_Free(charCodes); |
| 1302 return FWL_Error::Succeeded; | 1302 return FWL_Error::Succeeded; |
| 1303 } | 1303 } |
| 1304 | 1304 |
| 1305 FWL_Error CFX_Graphics::StrokePathWithPattern(CFX_Path* path, | 1305 FWL_Error CFX_Graphics::StrokePathWithPattern(CFX_Path* path, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 FWL_Error CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, | 1479 FWL_Error CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, |
| 1480 CFX_Matrix* matrix) { | 1480 CFX_Matrix* matrix) { |
| 1481 if (matrix->IsIdentity()) { | 1481 if (matrix->IsIdentity()) { |
| 1482 m_renderDevice->SetDIBits(source, 0, 0); | 1482 m_renderDevice->SetDIBits(source, 0, 0); |
| 1483 } else { | 1483 } else { |
| 1484 CFX_Matrix m; | 1484 CFX_Matrix m; |
| 1485 m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, | 1485 m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, |
| 1486 0); | 1486 0); |
| 1487 m.Concat(*matrix); | 1487 m.Concat(*matrix); |
| 1488 int32_t left, top; | 1488 int32_t left, top; |
| 1489 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(FALSE, TRUE)); | 1489 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(false, true)); |
| 1490 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->TransformTo(&m, left, top)); | 1490 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->TransformTo(&m, left, top)); |
| 1491 m_renderDevice->SetDIBits(bmp2.get(), left, top); | 1491 m_renderDevice->SetDIBits(bmp2.get(), left, top); |
| 1492 } | 1492 } |
| 1493 return FWL_Error::Succeeded; | 1493 return FWL_Error::Succeeded; |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 FWL_Error CFX_Graphics::CalcTextInfo(const CFX_WideString& text, | 1496 FWL_Error CFX_Graphics::CalcTextInfo(const CFX_WideString& text, |
| 1497 uint32_t* charCodes, | 1497 uint32_t* charCodes, |
| 1498 FXTEXT_CHARPOS* charPos, | 1498 FXTEXT_CHARPOS* charPos, |
| 1499 CFX_RectF& rect) { | 1499 CFX_RectF& rect) { |
| 1500 std::unique_ptr<CFX_UnicodeEncoding> encoding( | 1500 std::unique_ptr<CFX_UnicodeEncoding> encoding( |
| 1501 new CFX_UnicodeEncoding(m_info.font)); | 1501 new CFX_UnicodeEncoding(m_info.font)); |
| 1502 int32_t length = text.GetLength(); | 1502 int32_t length = text.GetLength(); |
| 1503 FX_FLOAT penX = (FX_FLOAT)rect.left; | 1503 FX_FLOAT penX = (FX_FLOAT)rect.left; |
| 1504 FX_FLOAT penY = (FX_FLOAT)rect.top; | 1504 FX_FLOAT penY = (FX_FLOAT)rect.top; |
| 1505 FX_FLOAT left = (FX_FLOAT)(0); | 1505 FX_FLOAT left = (FX_FLOAT)(0); |
| 1506 FX_FLOAT top = (FX_FLOAT)(0); | 1506 FX_FLOAT top = (FX_FLOAT)(0); |
| 1507 charCodes[0] = text.GetAt(0); | 1507 charCodes[0] = text.GetAt(0); |
| 1508 charPos[0].m_OriginX = penX + left; | 1508 charPos[0].m_OriginX = penX + left; |
| 1509 charPos[0].m_OriginY = penY + top; | 1509 charPos[0].m_OriginY = penY + top; |
| 1510 charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[0]); | 1510 charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[0]); |
| 1511 charPos[0].m_FontCharWidth = FXSYS_round( | 1511 charPos[0].m_FontCharWidth = FXSYS_round( |
| 1512 m_info.font->GetGlyphWidth(charPos[0].m_GlyphIndex) * m_info.fontHScale); | 1512 m_info.font->GetGlyphWidth(charPos[0].m_GlyphIndex) * m_info.fontHScale); |
| 1513 charPos[0].m_bGlyphAdjust = TRUE; | 1513 charPos[0].m_bGlyphAdjust = true; |
| 1514 charPos[0].m_AdjustMatrix[0] = -1; | 1514 charPos[0].m_AdjustMatrix[0] = -1; |
| 1515 charPos[0].m_AdjustMatrix[1] = 0; | 1515 charPos[0].m_AdjustMatrix[1] = 0; |
| 1516 charPos[0].m_AdjustMatrix[2] = 0; | 1516 charPos[0].m_AdjustMatrix[2] = 0; |
| 1517 charPos[0].m_AdjustMatrix[3] = 1; | 1517 charPos[0].m_AdjustMatrix[3] = 1; |
| 1518 penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * m_info.fontSize / 1000 + | 1518 penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * m_info.fontSize / 1000 + |
| 1519 m_info.fontSpacing; | 1519 m_info.fontSpacing; |
| 1520 for (int32_t i = 1; i < length; i++) { | 1520 for (int32_t i = 1; i < length; i++) { |
| 1521 charCodes[i] = text.GetAt(i); | 1521 charCodes[i] = text.GetAt(i); |
| 1522 charPos[i].m_OriginX = penX + left; | 1522 charPos[i].m_OriginX = penX + left; |
| 1523 charPos[i].m_OriginY = penY + top; | 1523 charPos[i].m_OriginY = penY + top; |
| 1524 charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[i]); | 1524 charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[i]); |
| 1525 charPos[i].m_FontCharWidth = | 1525 charPos[i].m_FontCharWidth = |
| 1526 FXSYS_round(m_info.font->GetGlyphWidth(charPos[i].m_GlyphIndex) * | 1526 FXSYS_round(m_info.font->GetGlyphWidth(charPos[i].m_GlyphIndex) * |
| 1527 m_info.fontHScale); | 1527 m_info.fontHScale); |
| 1528 charPos[i].m_bGlyphAdjust = TRUE; | 1528 charPos[i].m_bGlyphAdjust = true; |
| 1529 charPos[i].m_AdjustMatrix[0] = -1; | 1529 charPos[i].m_AdjustMatrix[0] = -1; |
| 1530 charPos[i].m_AdjustMatrix[1] = 0; | 1530 charPos[i].m_AdjustMatrix[1] = 0; |
| 1531 charPos[i].m_AdjustMatrix[2] = 0; | 1531 charPos[i].m_AdjustMatrix[2] = 0; |
| 1532 charPos[i].m_AdjustMatrix[3] = 1; | 1532 charPos[i].m_AdjustMatrix[3] = 1; |
| 1533 penX += (FX_FLOAT)(charPos[i].m_FontCharWidth) * m_info.fontSize / 1000 + | 1533 penX += (FX_FLOAT)(charPos[i].m_FontCharWidth) * m_info.fontSize / 1000 + |
| 1534 m_info.fontSpacing; | 1534 m_info.fontSpacing; |
| 1535 } | 1535 } |
| 1536 rect.width = (FX_FLOAT)penX - rect.left; | 1536 rect.width = (FX_FLOAT)penX - rect.left; |
| 1537 rect.height = rect.top + m_info.fontSize * m_info.fontHScale - rect.top; | 1537 rect.height = rect.top + m_info.fontSize * m_info.fontHScale - rect.top; |
| 1538 return FWL_Error::Succeeded; | 1538 return FWL_Error::Succeeded; |
| 1539 } | 1539 } |
| 1540 | 1540 |
| 1541 CFX_Graphics::TInfo::TInfo() | 1541 CFX_Graphics::TInfo::TInfo() |
| 1542 : isAntialiasing(TRUE), | 1542 : isAntialiasing(true), |
| 1543 strokeAlignment(FX_STROKEALIGNMENT_Center), | 1543 strokeAlignment(FX_STROKEALIGNMENT_Center), |
| 1544 isActOnDash(FALSE), | 1544 isActOnDash(false), |
| 1545 strokeColor(nullptr), | 1545 strokeColor(nullptr), |
| 1546 fillColor(nullptr), | 1546 fillColor(nullptr), |
| 1547 font(nullptr), | 1547 font(nullptr), |
| 1548 fontSize(40.0), | 1548 fontSize(40.0), |
| 1549 fontHScale(1.0), | 1549 fontHScale(1.0), |
| 1550 fontSpacing(0.0) {} | 1550 fontSpacing(0.0) {} |
| 1551 | 1551 |
| 1552 CFX_Graphics::TInfo::TInfo(const TInfo& info) | 1552 CFX_Graphics::TInfo::TInfo(const TInfo& info) |
| 1553 : graphState(info.graphState), | 1553 : graphState(info.graphState), |
| 1554 isAntialiasing(info.isAntialiasing), | 1554 isAntialiasing(info.isAntialiasing), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1569 CTM = other.CTM; | 1569 CTM = other.CTM; |
| 1570 isActOnDash = other.isActOnDash; | 1570 isActOnDash = other.isActOnDash; |
| 1571 strokeColor = other.strokeColor; | 1571 strokeColor = other.strokeColor; |
| 1572 fillColor = other.fillColor; | 1572 fillColor = other.fillColor; |
| 1573 font = other.font; | 1573 font = other.font; |
| 1574 fontSize = other.fontSize; | 1574 fontSize = other.fontSize; |
| 1575 fontHScale = other.fontHScale; | 1575 fontHScale = other.fontHScale; |
| 1576 fontSpacing = other.fontSpacing; | 1576 fontSpacing = other.fontSpacing; |
| 1577 return *this; | 1577 return *this; |
| 1578 } | 1578 } |
| OLD | NEW |