diff options
author | Nicolas Pena <npm@chromium.org> | 2018-05-17 18:34:42 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-17 18:34:42 +0000 |
commit | c647ed6de2732970309b17c4c132e2848b1dcfe5 (patch) | |
tree | b8d7040f910c454dd454ddbf078a10a381b0e5b6 /fpdfsdk | |
parent | 30f739c81db8d6fb4cb68347eae6b2a785cd6414 (diff) | |
download | pdfium-c647ed6de2732970309b17c4c132e2848b1dcfe5.tar.xz |
Deprecate several Path/Text APIs.
This CL deprecates the following APIs in favor of the more general
versions:
FPDFPath_SetStrokeColor
FPDFPath_GetStrokeColor
FPDFPath_SetStrokeWidth
FPDFPath_SetLineJoin
FPDFPath_SetLineCap
FPDFPath_SetFillColor
FPDFPath_GetFillColor
FPDFText_SetFillColor
Change-Id: Iccaa2ce26025e51366bc50e058e39650f3698836
Reviewed-on: https://pdfium-review.googlesource.com/32711
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/fpdf_editpath.cpp | 71 |
1 files changed, 20 insertions, 51 deletions
diff --git a/fpdfsdk/fpdf_editpath.cpp b/fpdfsdk/fpdf_editpath.cpp index aca2bebf81..a5873ef67d 100644 --- a/fpdfsdk/fpdf_editpath.cpp +++ b/fpdfsdk/fpdf_editpath.cpp @@ -42,10 +42,6 @@ CPDF_PathObject* CPDFPathObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) { return obj ? obj->AsPath() : nullptr; } -unsigned int GetAlphaAsUnsignedInt(float alpha) { - return static_cast<unsigned int>(alpha * 255.f + 0.5f); -} - } // namespace FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewPath(float x, @@ -77,15 +73,10 @@ FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path, unsigned int B, unsigned int A) { auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); - if (!pPathObj || R > 255 || G > 255 || B > 255 || A > 255) + if (!pPathObj) return false; - std::vector<float> rgb = {R / 255.f, G / 255.f, B / 255.f}; - pPathObj->m_GeneralState.SetStrokeAlpha(A / 255.f); - pPathObj->m_ColorState.SetStrokeColor( - CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb); - pPathObj->SetDirty(true); - return true; + return FPDFPageObj_SetStrokeColor(path, R, G, B, A); } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV @@ -95,26 +86,19 @@ FPDFPath_GetStrokeColor(FPDF_PAGEOBJECT path, unsigned int* B, unsigned int* A) { auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); - if (!pPathObj || !R || !G || !B || !A) + if (!pPathObj) return false; - FX_COLORREF strokeColor = pPathObj->m_ColorState.GetStrokeColorRef(); - *R = FXSYS_GetRValue(strokeColor); - *G = FXSYS_GetGValue(strokeColor); - *B = FXSYS_GetBValue(strokeColor); - *A = GetAlphaAsUnsignedInt(pPathObj->m_GeneralState.GetStrokeAlpha()); - return true; + return FPDFPageObj_GetStrokeColor(path, R, G, B, A); } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width) { auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); - if (!pPathObj || width < 0.0f) + if (!pPathObj) return false; - pPathObj->m_GraphState.SetLineWidth(width); - pPathObj->SetDirty(true); - return true; + return FPDFPageObj_SetStrokeWidth(path, width); } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetFillColor(FPDF_PAGEOBJECT path, @@ -122,6 +106,10 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetFillColor(FPDF_PAGEOBJECT path, unsigned int G, unsigned int B, unsigned int A) { + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); + if (!pPathObj) + return false; + return FPDFPageObj_SetFillColor(path, R, G, B, A); } @@ -131,15 +119,10 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetFillColor(FPDF_PAGEOBJECT path, unsigned int* B, unsigned int* A) { auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); - if (!pPathObj || !R || !G || !B || !A) + if (!pPathObj) return false; - FX_COLORREF fillColor = pPathObj->m_ColorState.GetFillColorRef(); - *R = FXSYS_GetRValue(fillColor); - *G = FXSYS_GetGValue(fillColor); - *B = FXSYS_GetBValue(fillColor); - *A = GetAlphaAsUnsignedInt(pPathObj->m_GeneralState.GetFillAlpha()); - return true; + return FPDFPageObj_GetFillColor(path, R, G, B, A); } FPDF_EXPORT int FPDF_CALLCONV FPDFPath_CountSegments(FPDF_PAGEOBJECT path) { @@ -237,34 +220,20 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT path, int line_join) { - if (!path) - return; - if (line_join < - static_cast<int>(CFX_GraphStateData::LineJoin::LineJoinMiter) || - line_join > - static_cast<int>(CFX_GraphStateData::LineJoin::LineJoinBevel)) { + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); + if (!pPathObj) return; - } - auto* pPathObj = CPDFPageObjectFromFPDFPageObject(path); - CFX_GraphStateData::LineJoin lineJoin = - static_cast<CFX_GraphStateData::LineJoin>(line_join); - pPathObj->m_GraphState.SetLineJoin(lineJoin); - pPathObj->SetDirty(true); + + FPDFPageObj_SetLineJoin(path, line_join); } FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT path, int line_cap) { - if (!path) - return; - if (line_cap < static_cast<int>(CFX_GraphStateData::LineCap::LineCapButt) || - line_cap > static_cast<int>(CFX_GraphStateData::LineCap::LineCapSquare)) { + auto* pPathObj = CPDFPathObjectFromFPDFPageObject(path); + if (!pPathObj) return; - } - auto* pPathObj = CPDFPageObjectFromFPDFPageObject(path); - CFX_GraphStateData::LineCap lineCap = - static_cast<CFX_GraphStateData::LineCap>(line_cap); - pPathObj->m_GraphState.SetLineCap(lineCap); - pPathObj->SetDirty(true); + + FPDFPageObj_SetLineCap(path, line_cap); } FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |