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 | |
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>
-rw-r--r-- | fpdfsdk/fpdf_editpath.cpp | 71 | ||||
-rw-r--r-- | public/fpdf_edit.h | 24 |
2 files changed, 44 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 diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h index c0766a33b8..6eca64fde1 100644 --- a/public/fpdf_edit.h +++ b/public/fpdf_edit.h @@ -596,6 +596,9 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_SetBlendMode(FPDF_PAGEOBJECT page_object, FPDF_BYTESTRING blend_mode); +// DEPRECATED as of May 2018. This API will be removed in the future. Please +// use FPDFPageObj_SetStrokeColor instead. +// // Set the stroke RGBA of a path. Range of values: 0 - 255. // // path - the handle to the path object. @@ -628,6 +631,9 @@ FPDFPageObj_SetStrokeColor(FPDF_PAGEOBJECT page_object, unsigned int B, unsigned int A); +// DEPRECATED as of May 2018. This API will be removed in the future. Please +// use FPDFPageObj_GetStrokeColor instead. Get the stroke RGBA of a path. +// // Get the stroke RGBA of a path. Range of values: 0 - 255. // // path - the handle to the path object. @@ -660,6 +666,9 @@ FPDFPageObj_GetStrokeColor(FPDF_PAGEOBJECT page_object, unsigned int* B, unsigned int* A); +// DEPRECATED as of May 2018. This API will be removed in the future. Please +// use FPDFPageObj_SetStrokeWidth instead. +// // Set the stroke width of a path. // // path - the handle to the path object. @@ -678,6 +687,9 @@ FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width); FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_SetStrokeWidth(FPDF_PAGEOBJECT page_object, float width); +// DEPRECATED as of May 2018. This API will be removed in the future. Please +// use FPDFPageObj_SetLineJoin instead. +// // Set the line join of |page_object|. // // page_object - handle to a page object. @@ -698,6 +710,9 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT page_object, FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_SetLineJoin(FPDF_PAGEOBJECT page_object, int line_join); +// DEPRECATED as of May 2018. This API will be removed in the future. Please +// use FPDFPageObj_SetLineCap instead. +// // Set the line cap of |page_object|. // // page_object - handle to a page object. @@ -718,6 +733,9 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT page_object, FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap); +// DEPRECATED as of May 2018. This API will be removed in the future. Please +// use FPDFPageObj_SetFillColor instead. +// // Set the fill RGBA of a path. Range of values: 0 - 255. // // path - the handle to the path object. @@ -749,6 +767,9 @@ FPDFPageObj_SetFillColor(FPDF_PAGEOBJECT page_object, unsigned int B, unsigned int A); +// DEPRECATED as of May 2018. This API will be removed in the future. Please +// use FPDFPageObj_GetFillColor instead. +// // Get the fill RGBA of a path. Range of values: 0 - 255. // // path - the handle to the path object. @@ -938,6 +959,9 @@ FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFText_LoadFont(FPDF_DOCUMENT document, int font_type, FPDF_BOOL cid); +// DEPRECATED as of May 2018. This API will be removed in the future. Please +// use FPDFPageObj_SetFillColor instead. +// // Set the fill RGBA of a text object. Range of values: 0 - 255. // // text_object - handle to the text object. |