Chromium Code Reviews| 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 #include "core/fxge/include/fx_ge.h" | 5 #include "core/fxge/include/fx_ge.h" |
| 6 | 6 |
| 7 #if defined(_SKIA_SUPPORT_) | 7 #if defined(_SKIA_SUPPORT_) |
| 8 #include "core/fxcodec/include/fx_codec.h" | 8 #include "core/fxcodec/include/fx_codec.h" |
| 9 | 9 |
| 10 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" | 10 #include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h" |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 SkRect::MakeLTRB(pRect->left, pRect->top, pRect->right, pRect->bottom), | 746 SkRect::MakeLTRB(pRect->left, pRect->top, pRect->right, pRect->bottom), |
| 747 spaint); | 747 spaint); |
| 748 return TRUE; | 748 return TRUE; |
| 749 } | 749 } |
| 750 | 750 |
| 751 FX_BOOL CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern, | 751 FX_BOOL CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern, |
| 752 const CFX_Matrix* pMatrix, | 752 const CFX_Matrix* pMatrix, |
| 753 const FX_RECT& clip_rect, | 753 const FX_RECT& clip_rect, |
| 754 int alpha, | 754 int alpha, |
| 755 FX_BOOL bAlphaMode) { | 755 FX_BOOL bAlphaMode) { |
| 756 if (kAxialShading != pPattern->m_ShadingType && | 756 if (kAxialShading != pPattern->GetShadingType() && |
| 757 kRadialShading != pPattern->m_ShadingType) { | 757 kRadialShading != pPattern->GetShadingType()) { |
| 758 // TODO(caryclark) more types | 758 // TODO(caryclark) more types |
| 759 return false; | 759 return false; |
| 760 } | 760 } |
| 761 CPDF_Function* const* pFuncs = pPattern->m_pFunctions; | 761 const std::vector<std::unique_ptr<CPDF_Function>>& pFuncs = |
| 762 int nFuncs = pPattern->m_nFuncs; | 762 pPattern->GetFuncs(); |
| 763 int nFuncs = pFuncs.size(); | |
|
Lei Zhang
2016/05/25 20:54:23
size_t, |j| on line 774 should be size_t as well.
| |
| 763 if (nFuncs != 1) // TODO(caryclark) remove this restriction | 764 if (nFuncs != 1) // TODO(caryclark) remove this restriction |
| 764 return false; | 765 return false; |
| 765 CPDF_Dictionary* pDict = pPattern->m_pShadingObj->GetDict(); | 766 CPDF_Dictionary* pDict = pPattern->GetShadingObject()->GetDict(); |
| 766 CPDF_Array* pCoords = pDict->GetArrayBy("Coords"); | 767 CPDF_Array* pCoords = pDict->GetArrayBy("Coords"); |
| 767 if (!pCoords) | 768 if (!pCoords) |
| 768 return true; | 769 return true; |
| 769 // TODO(caryclark) Respect Domain[0], Domain[1]. (Don't know what they do | 770 // TODO(caryclark) Respect Domain[0], Domain[1]. (Don't know what they do |
| 770 // yet.) | 771 // yet.) |
| 771 SkTDArray<SkColor> skColors; | 772 SkTDArray<SkColor> skColors; |
| 772 SkTDArray<SkScalar> skPos; | 773 SkTDArray<SkScalar> skPos; |
| 773 for (int j = 0; j < nFuncs; j++) { | 774 for (int j = 0; j < nFuncs; j++) { |
| 774 const CPDF_Function* pFunc = pFuncs[j]; | 775 if (!pFuncs[j]) |
| 775 if (!pFunc) | |
| 776 continue; | 776 continue; |
| 777 | 777 |
| 778 if (const CPDF_SampledFunc* pSampledFunc = pFunc->ToSampledFunc()) { | 778 if (const CPDF_SampledFunc* pSampledFunc = pFuncs[j]->ToSampledFunc()) { |
| 779 /* TODO(caryclark) | 779 /* TODO(caryclark) |
| 780 Type 0 Sampled Functions in PostScript can also have an Order integer | 780 Type 0 Sampled Functions in PostScript can also have an Order integer |
| 781 in the dictionary. PDFium doesn't appear to check for this anywhere. | 781 in the dictionary. PDFium doesn't appear to check for this anywhere. |
| 782 */ | 782 */ |
| 783 if (!AddSamples(pSampledFunc, &skColors, &skPos)) | 783 if (!AddSamples(pSampledFunc, &skColors, &skPos)) |
| 784 return false; | 784 return false; |
| 785 } else if (const CPDF_ExpIntFunc* pExpIntFuc = pFunc->ToExpIntFunc()) { | 785 } else if (const CPDF_ExpIntFunc* pExpIntFuc = pFuncs[j]->ToExpIntFunc()) { |
| 786 if (!AddColors(pExpIntFuc, &skColors)) | 786 if (!AddColors(pExpIntFuc, &skColors)) |
| 787 return false; | 787 return false; |
| 788 skPos.push(0); | 788 skPos.push(0); |
| 789 skPos.push(1); | 789 skPos.push(1); |
| 790 } else if (const CPDF_StitchFunc* pStitchFunc = pFunc->ToStitchFunc()) { | 790 } else if (const CPDF_StitchFunc* pStitchFunc = pFuncs[j]->ToStitchFunc()) { |
| 791 if (!AddStitching(pStitchFunc, &skColors, &skPos)) | 791 if (!AddStitching(pStitchFunc, &skColors, &skPos)) |
| 792 return false; | 792 return false; |
| 793 } else { | 793 } else { |
| 794 return false; | 794 return false; |
| 795 } | 795 } |
| 796 } | 796 } |
| 797 CPDF_Array* pArray = pDict->GetArrayBy("Extend"); | 797 CPDF_Array* pArray = pDict->GetArrayBy("Extend"); |
| 798 bool clipStart = !pArray || !pArray->GetIntegerAt(0); | 798 bool clipStart = !pArray || !pArray->GetIntegerAt(0); |
| 799 bool clipEnd = !pArray || !pArray->GetIntegerAt(1); | 799 bool clipEnd = !pArray || !pArray->GetIntegerAt(1); |
| 800 SkPaint paint; | 800 SkPaint paint; |
| 801 paint.setAntiAlias(true); | 801 paint.setAntiAlias(true); |
| 802 paint.setAlpha(alpha); | 802 paint.setAlpha(alpha); |
| 803 SkMatrix skMatrix = ToSkMatrix(*pMatrix); | 803 SkMatrix skMatrix = ToSkMatrix(*pMatrix); |
| 804 SkRect skRect = SkRect::MakeLTRB(clip_rect.left, clip_rect.top, | 804 SkRect skRect = SkRect::MakeLTRB(clip_rect.left, clip_rect.top, |
| 805 clip_rect.right, clip_rect.bottom); | 805 clip_rect.right, clip_rect.bottom); |
| 806 SkPath skClip; | 806 SkPath skClip; |
| 807 SkPath skPath; | 807 SkPath skPath; |
| 808 if (kAxialShading == pPattern->m_ShadingType) { | 808 if (kAxialShading == pPattern->GetShadingType()) { |
| 809 FX_FLOAT start_x = pCoords->GetNumberAt(0); | 809 FX_FLOAT start_x = pCoords->GetNumberAt(0); |
| 810 FX_FLOAT start_y = pCoords->GetNumberAt(1); | 810 FX_FLOAT start_y = pCoords->GetNumberAt(1); |
| 811 FX_FLOAT end_x = pCoords->GetNumberAt(2); | 811 FX_FLOAT end_x = pCoords->GetNumberAt(2); |
| 812 FX_FLOAT end_y = pCoords->GetNumberAt(3); | 812 FX_FLOAT end_y = pCoords->GetNumberAt(3); |
| 813 SkPoint pts[] = {{start_x, start_y}, {end_x, end_y}}; | 813 SkPoint pts[] = {{start_x, start_y}, {end_x, end_y}}; |
| 814 skMatrix.mapPoints(pts, SK_ARRAY_COUNT(pts)); | 814 skMatrix.mapPoints(pts, SK_ARRAY_COUNT(pts)); |
| 815 paint.setShader(SkGradientShader::MakeLinear( | 815 paint.setShader(SkGradientShader::MakeLinear( |
| 816 pts, skColors.begin(), skPos.begin(), skColors.count(), | 816 pts, skColors.begin(), skPos.begin(), skColors.count(), |
| 817 SkShader::kClamp_TileMode)); | 817 SkShader::kClamp_TileMode)); |
| 818 if (clipStart || clipEnd) { | 818 if (clipStart || clipEnd) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 839 SkPoint rectPts[4] = {{skRect.fLeft, skRect.fTop}, | 839 SkPoint rectPts[4] = {{skRect.fLeft, skRect.fTop}, |
| 840 {skRect.fRight, skRect.fTop}, | 840 {skRect.fRight, skRect.fTop}, |
| 841 {skRect.fRight, skRect.fBottom}, | 841 {skRect.fRight, skRect.fBottom}, |
| 842 {skRect.fLeft, skRect.fBottom}}; | 842 {skRect.fLeft, skRect.fBottom}}; |
| 843 ClipAngledGradient(pts, rectPts, clipStart, clipEnd, &skClip); | 843 ClipAngledGradient(pts, rectPts, clipStart, clipEnd, &skClip); |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 skPath.addRect(skRect); | 846 skPath.addRect(skRect); |
| 847 skMatrix.setIdentity(); | 847 skMatrix.setIdentity(); |
| 848 } else { | 848 } else { |
| 849 ASSERT(kRadialShading == pPattern->m_ShadingType); | 849 ASSERT(kRadialShading == pPattern->GetShadingType()); |
| 850 FX_FLOAT start_x = pCoords->GetNumberAt(0); | 850 FX_FLOAT start_x = pCoords->GetNumberAt(0); |
| 851 FX_FLOAT start_y = pCoords->GetNumberAt(1); | 851 FX_FLOAT start_y = pCoords->GetNumberAt(1); |
| 852 FX_FLOAT start_r = pCoords->GetNumberAt(2); | 852 FX_FLOAT start_r = pCoords->GetNumberAt(2); |
| 853 FX_FLOAT end_x = pCoords->GetNumberAt(3); | 853 FX_FLOAT end_x = pCoords->GetNumberAt(3); |
| 854 FX_FLOAT end_y = pCoords->GetNumberAt(4); | 854 FX_FLOAT end_y = pCoords->GetNumberAt(4); |
| 855 FX_FLOAT end_r = pCoords->GetNumberAt(5); | 855 FX_FLOAT end_r = pCoords->GetNumberAt(5); |
| 856 SkPoint pts[] = {{start_x, start_y}, {end_x, end_y}}; | 856 SkPoint pts[] = {{start_x, start_y}, {end_x, end_y}}; |
| 857 | 857 |
| 858 paint.setShader(SkGradientShader::MakeTwoPointConical( | 858 paint.setShader(SkGradientShader::MakeTwoPointConical( |
| 859 pts[0], start_r, pts[1], end_r, skColors.begin(), skPos.begin(), | 859 pts[0], start_r, pts[1], end_r, skColors.begin(), skPos.begin(), |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1137 SetDeviceDriver(pDriver); | 1137 SetDeviceDriver(pDriver); |
| 1138 return true; | 1138 return true; |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 CFX_FxgeDevice::~CFX_FxgeDevice() { | 1141 CFX_FxgeDevice::~CFX_FxgeDevice() { |
| 1142 if (m_bOwnedBitmap && GetBitmap()) | 1142 if (m_bOwnedBitmap && GetBitmap()) |
| 1143 delete GetBitmap(); | 1143 delete GetBitmap(); |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 #endif | 1146 #endif |
| OLD | NEW |