| 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/include/cfx_graphics.h" | 7 #include "xfa/fxgraphics/include/cfx_graphics.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(); |
| 634 m_infoStack.Add(new TInfo(m_info)); | 634 m_infoStack.Add(new TInfo(m_info)); |
| 635 return FWL_Error::Succeeded; | 635 return FWL_Error::Succeeded; |
| 636 } | 636 } |
| 637 return FWL_Error::PropertyInvalid; | 637 return FWL_Error::PropertyInvalid; |
| 638 } | 638 } |
| 639 | 639 |
| 640 FWL_Error CFX_Graphics::RestoreGraphState() { | 640 FWL_Error CFX_Graphics::RestoreGraphState() { |
| 641 if (m_type == FX_CONTEXT_Device && m_renderDevice) { | 641 if (m_type == FX_CONTEXT_Device && m_renderDevice) { |
| 642 m_renderDevice->RestoreState(); | 642 m_renderDevice->RestoreState(false); |
| 643 int32_t size = m_infoStack.GetSize(); | 643 int32_t size = m_infoStack.GetSize(); |
| 644 if (size <= 0) { | 644 if (size <= 0) { |
| 645 return FWL_Error::IntermediateValueInvalid; | 645 return FWL_Error::IntermediateValueInvalid; |
| 646 } | 646 } |
| 647 int32_t topIndex = size - 1; | 647 int32_t topIndex = size - 1; |
| 648 std::unique_ptr<TInfo> info(m_infoStack.GetAt(topIndex)); | 648 std::unique_ptr<TInfo> info(m_infoStack.GetAt(topIndex)); |
| 649 if (!info) | 649 if (!info) |
| 650 return FWL_Error::IntermediateValueInvalid; | 650 return FWL_Error::IntermediateValueInvalid; |
| 651 m_info = *info; | 651 m_info = *info; |
| 652 m_infoStack.RemoveAt(topIndex); | 652 m_infoStack.RemoveAt(topIndex); |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { | 1349 for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { |
| 1350 device.SetBitMask(&mask, i, j, | 1350 device.SetBitMask(&mask, i, j, |
| 1351 m_info.fillColor->m_info.pattern->m_foreArgb); | 1351 m_info.fillColor->m_info.pattern->m_foreArgb); |
| 1352 } | 1352 } |
| 1353 } | 1353 } |
| 1354 | 1354 |
| 1355 m_renderDevice->SaveState(); | 1355 m_renderDevice->SaveState(); |
| 1356 m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, | 1356 m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, |
| 1357 fillMode); | 1357 fillMode); |
| 1358 SetDIBitsWithMatrix(&bmp, &pattern->m_matrix); | 1358 SetDIBitsWithMatrix(&bmp, &pattern->m_matrix); |
| 1359 m_renderDevice->RestoreState(); | 1359 m_renderDevice->RestoreState(false); |
| 1360 return FWL_Error::Succeeded; | 1360 return FWL_Error::Succeeded; |
| 1361 } | 1361 } |
| 1362 | 1362 |
| 1363 FWL_Error CFX_Graphics::FillPathWithShading(CFX_Path* path, | 1363 FWL_Error CFX_Graphics::FillPathWithShading(CFX_Path* path, |
| 1364 FX_FillMode fillMode, | 1364 FX_FillMode fillMode, |
| 1365 CFX_Matrix* matrix) { | 1365 CFX_Matrix* matrix) { |
| 1366 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); | 1366 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); |
| 1367 int32_t width = bitmap->GetWidth(); | 1367 int32_t width = bitmap->GetWidth(); |
| 1368 int32_t height = bitmap->GetHeight(); | 1368 int32_t height = bitmap->GetHeight(); |
| 1369 FX_FLOAT start_x = m_info.fillColor->m_shading->m_beginPoint.x; | 1369 FX_FLOAT start_x = m_info.fillColor->m_shading->m_beginPoint.x; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 default: { | 1470 default: { |
| 1471 result = false; | 1471 result = false; |
| 1472 break; | 1472 break; |
| 1473 } | 1473 } |
| 1474 } | 1474 } |
| 1475 if (result) { | 1475 if (result) { |
| 1476 m_renderDevice->SaveState(); | 1476 m_renderDevice->SaveState(); |
| 1477 m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, | 1477 m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, |
| 1478 fillMode); | 1478 fillMode); |
| 1479 SetDIBitsWithMatrix(&bmp, matrix); | 1479 SetDIBitsWithMatrix(&bmp, matrix); |
| 1480 m_renderDevice->RestoreState(); | 1480 m_renderDevice->RestoreState(false); |
| 1481 } | 1481 } |
| 1482 return result ? FWL_Error::Succeeded : FWL_Error::PropertyInvalid; | 1482 return result ? FWL_Error::Succeeded : FWL_Error::PropertyInvalid; |
| 1483 } | 1483 } |
| 1484 | 1484 |
| 1485 FWL_Error CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, | 1485 FWL_Error CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, |
| 1486 CFX_Matrix* matrix) { | 1486 CFX_Matrix* matrix) { |
| 1487 if (matrix->IsIdentity()) { | 1487 if (matrix->IsIdentity()) { |
| 1488 m_renderDevice->SetDIBits(source, 0, 0); | 1488 m_renderDevice->SetDIBits(source, 0, 0); |
| 1489 } else { | 1489 } else { |
| 1490 CFX_Matrix m; | 1490 CFX_Matrix m; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 CTM = other.CTM; | 1565 CTM = other.CTM; |
| 1566 isActOnDash = other.isActOnDash; | 1566 isActOnDash = other.isActOnDash; |
| 1567 strokeColor = other.strokeColor; | 1567 strokeColor = other.strokeColor; |
| 1568 fillColor = other.fillColor; | 1568 fillColor = other.fillColor; |
| 1569 font = other.font; | 1569 font = other.font; |
| 1570 fontSize = other.fontSize; | 1570 fontSize = other.fontSize; |
| 1571 fontHScale = other.fontHScale; | 1571 fontHScale = other.fontHScale; |
| 1572 fontSpacing = other.fontSpacing; | 1572 fontSpacing = other.fontSpacing; |
| 1573 return *this; | 1573 return *this; |
| 1574 } | 1574 } |
| OLD | NEW |