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 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, | 1223 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, |
1224 m_info.CTM.f); | 1224 m_info.CTM.f); |
1225 if (matrix) { | 1225 if (matrix) { |
1226 m1.Concat(*matrix); | 1226 m1.Concat(*matrix); |
1227 } | 1227 } |
1228 CFX_Matrix m2; | 1228 CFX_Matrix m2; |
1229 m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), | 1229 m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), |
1230 point.x, point.y); | 1230 point.x, point.y); |
1231 m2.Concat(m1); | 1231 m2.Concat(m1); |
1232 int32_t left, top; | 1232 int32_t left, top; |
1233 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(false, true)); | 1233 std::unique_ptr<CFX_DIBitmap> bmp1 = source->FlipImage(false, true); |
1234 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->TransformTo(&m2, left, top)); | 1234 std::unique_ptr<CFX_DIBitmap> bmp2 = bmp1->TransformTo(&m2, left, top); |
1235 CFX_RectF r; | 1235 CFX_RectF r; |
1236 GetClipRect(r); | 1236 GetClipRect(r); |
1237 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); | 1237 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); |
1238 CFX_DIBitmap bmp; | 1238 CFX_DIBitmap bmp; |
1239 if (bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb) && | 1239 if (bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb) && |
1240 m_renderDevice->GetDIBits(&bmp, 0, 0) && | 1240 m_renderDevice->GetDIBits(&bmp, 0, 0) && |
1241 bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top), | 1241 bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top), |
1242 FXSYS_round(r.Width()), FXSYS_round(r.Height()), | 1242 FXSYS_round(r.Width()), FXSYS_round(r.Height()), |
1243 bmp2.get(), FXSYS_round(r.left - left), | 1243 bmp2.get(), FXSYS_round(r.left - left), |
1244 FXSYS_round(r.top - top)) && | 1244 FXSYS_round(r.top - top)) && |
1245 m_renderDevice->SetDIBits(&bmp, 0, 0)) { | 1245 m_renderDevice->SetDIBits(&bmp, 0, 0)) { |
1246 return FWL_Error::Succeeded; | 1246 return FWL_Error::Succeeded; |
1247 } | 1247 } |
1248 return FWL_Error::Indefinite; | 1248 return FWL_Error::Indefinite; |
1249 } | 1249 } |
1250 | 1250 |
1251 FWL_Error CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source, | 1251 FWL_Error CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source, |
1252 const CFX_RectF& rect, | 1252 const CFX_RectF& rect, |
1253 CFX_Matrix* matrix) { | 1253 CFX_Matrix* matrix) { |
1254 CFX_Matrix m1; | 1254 CFX_Matrix m1; |
1255 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, | 1255 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, |
1256 m_info.CTM.f); | 1256 m_info.CTM.f); |
1257 if (matrix) { | 1257 if (matrix) { |
1258 m1.Concat(*matrix); | 1258 m1.Concat(*matrix); |
1259 } | 1259 } |
1260 std::unique_ptr<CFX_DIBitmap> bmp1( | 1260 std::unique_ptr<CFX_DIBitmap> bmp1 = |
1261 source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height())); | 1261 source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height()); |
1262 CFX_Matrix m2; | 1262 CFX_Matrix m2; |
1263 m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); | 1263 m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); |
1264 m2.Concat(m1); | 1264 m2.Concat(m1); |
1265 int32_t left, top; | 1265 int32_t left, top; |
1266 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->FlipImage(false, true)); | 1266 std::unique_ptr<CFX_DIBitmap> bmp2 = bmp1->FlipImage(false, true); |
1267 std::unique_ptr<CFX_DIBitmap> bmp3(bmp2->TransformTo(&m2, left, top)); | 1267 std::unique_ptr<CFX_DIBitmap> bmp3 = bmp2->TransformTo(&m2, left, top); |
1268 CFX_RectF r; | 1268 CFX_RectF r; |
1269 GetClipRect(r); | 1269 GetClipRect(r); |
1270 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); | 1270 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); |
1271 if (bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), | 1271 if (bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), |
1272 FXSYS_round(r.Width()), FXSYS_round(r.Height()), | 1272 FXSYS_round(r.Width()), FXSYS_round(r.Height()), |
1273 bmp3.get(), FXSYS_round(r.left - left), | 1273 bmp3.get(), FXSYS_round(r.left - left), |
1274 FXSYS_round(r.top - top))) { | 1274 FXSYS_round(r.top - top))) { |
1275 return FWL_Error::Succeeded; | 1275 return FWL_Error::Succeeded; |
1276 } | 1276 } |
1277 return FWL_Error::Indefinite; | 1277 return FWL_Error::Indefinite; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 FWL_Error CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, | 1480 FWL_Error CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, |
1481 CFX_Matrix* matrix) { | 1481 CFX_Matrix* matrix) { |
1482 if (matrix->IsIdentity()) { | 1482 if (matrix->IsIdentity()) { |
1483 m_renderDevice->SetDIBits(source, 0, 0); | 1483 m_renderDevice->SetDIBits(source, 0, 0); |
1484 } else { | 1484 } else { |
1485 CFX_Matrix m; | 1485 CFX_Matrix m; |
1486 m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, | 1486 m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, |
1487 0); | 1487 0); |
1488 m.Concat(*matrix); | 1488 m.Concat(*matrix); |
1489 int32_t left, top; | 1489 int32_t left, top; |
1490 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(false, true)); | 1490 std::unique_ptr<CFX_DIBitmap> bmp1 = source->FlipImage(false, true); |
1491 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->TransformTo(&m, left, top)); | 1491 std::unique_ptr<CFX_DIBitmap> bmp2 = bmp1->TransformTo(&m, left, top); |
1492 m_renderDevice->SetDIBits(bmp2.get(), left, top); | 1492 m_renderDevice->SetDIBits(bmp2.get(), left, top); |
1493 } | 1493 } |
1494 return FWL_Error::Succeeded; | 1494 return FWL_Error::Succeeded; |
1495 } | 1495 } |
1496 | 1496 |
1497 FWL_Error CFX_Graphics::CalcTextInfo(const CFX_WideString& text, | 1497 FWL_Error CFX_Graphics::CalcTextInfo(const CFX_WideString& text, |
1498 uint32_t* charCodes, | 1498 uint32_t* charCodes, |
1499 FXTEXT_CHARPOS* charPos, | 1499 FXTEXT_CHARPOS* charPos, |
1500 CFX_RectF& rect) { | 1500 CFX_RectF& rect) { |
1501 std::unique_ptr<CFX_UnicodeEncoding> encoding( | 1501 std::unique_ptr<CFX_UnicodeEncoding> encoding( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 CTM = other.CTM; | 1570 CTM = other.CTM; |
1571 isActOnDash = other.isActOnDash; | 1571 isActOnDash = other.isActOnDash; |
1572 strokeColor = other.strokeColor; | 1572 strokeColor = other.strokeColor; |
1573 fillColor = other.fillColor; | 1573 fillColor = other.fillColor; |
1574 font = other.font; | 1574 font = other.font; |
1575 fontSize = other.fontSize; | 1575 fontSize = other.fontSize; |
1576 fontHScale = other.fontHScale; | 1576 fontHScale = other.fontHScale; |
1577 fontSpacing = other.fontSpacing; | 1577 fontSpacing = other.fontSpacing; |
1578 return *this; | 1578 return *this; |
1579 } | 1579 } |
OLD | NEW |