summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render/cpdf_renderstatus.cpp
AgeCommit message (Collapse)Author
2018-10-12Remove more unnecessary includes and do IWYU as needed.Lei Zhang
Also move some implementations out of headers. Change-Id: I321fc26970c440d874b135bd28e8bc8156b9afee Reviewed-on: https://pdfium-review.googlesource.com/c/43890 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-12Rename CPDF_{Array,Dictionary}::GetCount() to size().Lei Zhang
Make them compatible with pdfium::CollectionSize(). Change-Id: Ibef3b182e35a7eca7c656cf590462782de0cc157 Reviewed-on: https://pdfium-review.googlesource.com/c/43937 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-06Encapsulate CPDF_PageObject's rect member.Lei Zhang
At the same time, change it from 4 floats to a CFX_FloatRect. Change-Id: I00ded941723d6a264b7a17c73fd337e66b449308 Reviewed-on: https://pdfium-review.googlesource.com/c/43570 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-05Remove optional matrix parameter from CPDF_PageObject::GetBBox().Lei Zhang
Instead, add GetTransformedBBox() with a required matrix parameter and use that when the there is a matrix. Change-Id: I594f3eb6bc7e1bc3eb6aa9f66556ebb1dfdbebe1 Reviewed-on: https://pdfium-review.googlesource.com/c/43553 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-05Make CPDF_RenderStatus matrix params const-ref.Lei Zhang
Eliminate the possibility of nullptr. Change-Id: I16c3e442d78e5151330db7227bd1c1630af3d4a3 Reviewed-on: https://pdfium-review.googlesource.com/c/43531 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-27Shading functions should take const matrix pointers.chromium/3568chromium/3567chromium/3566chromium/3565chromium/3564Lei Zhang
Change-Id: If13cc70d3d047f255f5d289f35a8533811523146 Reviewed-on: https://pdfium-review.googlesource.com/43110 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-09-21Replace CPDF_Color::Copy() with honest-to-goodness operator=().Tom Sepez
Change-Id: Ifcce7b1e513c8859752d5248ae686bbe5349e342 Reviewed-on: https://pdfium-review.googlesource.com/42614 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-17Extract duplicate code into GetShadingSteps().Lei Zhang
Change-Id: I6761a5f7fc099807c09abacdccbb72d282252551 Reviewed-on: https://pdfium-review.googlesource.com/42604 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-08-31Simplify radial shading.Henrique Nakashima
Change-Id: I3b6a386cf376a418ad64514313c791437ea54cf6 Reviewed-on: https://pdfium-review.googlesource.com/41610 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-31Fix radial shading when start circle is a point in the center of end circle.Henrique Nakashima
The bug also requires end circle to be tiny (radius of < 0.01). Bug: pdfium:1140 Change-Id: I2b355f44f0383334b8988fe41f82cb3f587e9909 Reviewed-on: https://pdfium-review.googlesource.com/41672 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-08-29Fix radial shading when center of start point is on the border of an end circle.Henrique Nakashima
Radial shading is done between two circles with their own centers and radii. When one has a radius of 0 and is located on or very close to the border of the other circle, a should be 0, but is not due to rounding errors unless the circles are aligned in x or y. Bug: pdfium:1140 Change-Id: Ief2efa91f3f16f7bed439aa471b258fa4d680acf Reviewed-on: https://pdfium-review.googlesource.com/41590 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-08-24Rename CFX_DIBSource to CFX_DIBBase.Tom Sepez
It is not a source from which you can get CFX_DIBs, but rather a base class from which all DIBs inherit. Do the same thing for the CPDF_DIBSource wrapper class. Mechanical change apart from adding a one-line comment in cfx_dibbase.h Change-Id: Id2bde87813ca301d9fafc55ce08d703dfc6a7184 Reviewed-on: https://pdfium-review.googlesource.com/41352 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-17Use more UnownedPtr<> in cpdf_renderstatus.h.chromium/3526Tom Sepez
This immediately flags a case where a pointer from a heap object to a caller's stack object is persisted past the caller's lifetime. Fix it the simplest way via AutoRestorer<> so we'll get a nice safe segv should it be used. Change-Id: I554304b235e73c279fa0cd79c9e3ee0138be45f9 Reviewed-on: https://pdfium-review.googlesource.com/40592 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-16Remove optional bool bType from GetFillArgb()Tom Sepez
Two variants make the intention much clearer. Change-Id: Ied0d8e6fa8c5524c19cafe8036d7c1b470fda86d Reviewed-on: https://pdfium-review.googlesource.com/40352 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-16Remove more optional args in core/Tom Sepez
Change-Id: I6a2bd03e00ad4e3d57f6931c0c6cf4ae0c760afb Reviewed-on: https://pdfium-review.googlesource.com/40290 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-15Make CPDF_RenderStatus::Initialize() saner.Tom Sepez
Move mandatory arguments to ctor. Replace long list of positional parameters with setter methods. Make Initialize() return void since it can't fail. Change-Id: I490118923855158891cf45eecd5de1e922a3a1fe Reviewed-on: https://pdfium-review.googlesource.com/40170 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-14Remove more default arg = nullptr cases.Tom Sepez
Bring in line with standards. Remove argument entirely for mac code that is always nullptr. Change-Id: I0710bdbd51fc0bc2e1d428ef44976be39a631147 Reviewed-on: https://pdfium-review.googlesource.com/40091 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-07Change CPDF_Font::GetFace() to HasFace().Lei Zhang
Callers do not actually need the returned handle. Change-Id: I1b8c0be00809eb7fdae9f6e95b4b325e75f4b847 Reviewed-on: https://pdfium-review.googlesource.com/39491 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-04Use more text object state in DrawTextPathWithPattern().chromium/3514chromium/3513chromium/3512Lei Zhang
BUG=chromium:668762 Change-Id: Iaf3fc9bcf68b8da2c947bbd78c5d72f78195b621 Reviewed-on: https://pdfium-review.googlesource.com/35991 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-12Rename 'ori' to 'backdrop' in rendering code.Lei Zhang
Change-Id: I6fa3fd93638bc3aeaaef854676fe31476888433b Reviewed-on: https://pdfium-review.googlesource.com/37671 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-05Delete CPDF_ContentMark::HasRef()Henrique Nakashima
This is called by many client to make sure CountItems() does not crash. Moving the check to CountItems() makes HasRef() unnecessary. Bug: pdfium:1037 Change-Id: I4f21f33a88c9aad54f0dae18a38b370c6ceaec80 Reviewed-on: https://pdfium-review.googlesource.com/37133 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-06-29Better determine if ICC colorspaces can be used for blending.Lei Zhang
Implement CPDF_ColorSpace::IsNormal() and check it when rendering. While IsNormal() is trivial for most colorspaces, it needs to be implemented separately for ICC colorspaces. This fixes a rendering regression from commit 1c0de38c. BUG=chromium:847346 Change-Id: Iaafed3f8ee40b26ac2cbfbdf2251407f7935311b Reviewed-on: https://pdfium-review.googlesource.com/36571 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-25Combine common code into CPDF_RenderStatus::ClipPattern().Lei Zhang
Change-Id: I53ce4ee699644b0a30132e642b8f466cd9b6e7b1 Reviewed-on: https://pdfium-review.googlesource.com/35972 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-25Make DrawRadialShading() slightly more compact.Lei Zhang
Change-Id: Ic0e528d01338a349deb1ee5a91372b132959e4ae Reviewed-on: https://pdfium-review.googlesource.com/35971 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-13Remove CFX_FixedBufGrow from cpdf_renderstatus.cppNicolas Pena
Bug: pdfium:177 Change-Id: I58fe339d5a0a962215c5cb29c963b37b86832637 Reviewed-on: https://pdfium-review.googlesource.com/35113 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-07Rename CPDF_PageObjectHolder::GetFormDict() to GetDict().Henrique Nakashima
Renamed the underlying member m_pFormDict as well. These names are misleading, as a page also uses the same field as the page dict. Change-Id: I52e0f1864a917a1e1b863725cb0d4f22faecacb3 Reviewed-on: https://pdfium-review.googlesource.com/34450 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-06-05Revert "Create m_ContentStream field in CPDF_PageObject."Henrique Nakashima
This reverts commit d3d8287e143daf12a602a919c120b4e0c656abf8. Reason for revert: Need to revert https://pdfium-review.googlesource.com/c/pdfium/+/33595 that this depends on. Original change's description: > Create m_ContentStream field in CPDF_PageObject. > > Content streams are now split and can set nonzero values to identify > each parsed content stream. > > Bug: pdfium:1051 > Change-Id: Ia2cb1e0997db5264d468043af31f9b41e8d0d349 > Reviewed-on: https://pdfium-review.googlesource.com/33591 > Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> > Reviewed-by: Ryan Harrison <rharrison@chromium.org> TBR=thestig@chromium.org,hnakashima@chromium.org,rharrison@chromium.org Change-Id: I5046b6a76508fccc0ff04cb7393cae6485dd091f No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: pdfium:1051 Reviewed-on: https://pdfium-review.googlesource.com/33990 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-06-05Create m_ContentStream field in CPDF_PageObject.Henrique Nakashima
Content streams are now split and can set nonzero values to identify each parsed content stream. Bug: pdfium:1051 Change-Id: Ia2cb1e0997db5264d468043af31f9b41e8d0d349 Reviewed-on: https://pdfium-review.googlesource.com/33591 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-30Exclude certain colorspace types for calculating transparency backdrop color.Lei Zhang
Per discussion for the "CS" entry in the PDF 1.7 spec table 7.13, several types of colorspaces do not meet the requirements of this particular colorspace entry. In terms of implementation, this avoids hitting a NOTREACHED() in CPDF_PatternCS::GetRGB(). BUG=chromium:847346 Change-Id: If994a91cdcd84b8977196256ee6926e20c4b74aa Reviewed-on: https://pdfium-review.googlesource.com/33210 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-29Get rid of FXARGB_MAKE macro.Lei Zhang
ArgbEncode() does the same thing. Change-Id: Ibb05ed4aae720c0a5ba66771699c0d7e11230921 Reviewed-on: https://pdfium-review.googlesource.com/32230 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-28Revert 'Remove almost all usages of CFX_FixedBufGrow with std::vector'chromium/3444Nicolas Pena
This is a manual revert of the CL at: https://pdfium-review.googlesource.com/c/pdfium/+/32159 The only file manually changed was cpdf_renderstatus.cpp Reason for revert: the bug below shows that sometimes the vector size used is larger than the parameter given to CFX_FixedBufGrow. Thus, we will revert, then add vectors using std::max unless it's clear from the code that the code will never access indices outside. Bug: chromium:847247 Change-Id: Iee54af023c8564824418a7d34a6385b0bc418ff0 Reviewed-on: https://pdfium-review.googlesource.com/33050 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-05-25Add proper const/non-const versions of CPDF_Dictionary::GetStreamFor().chromium/3441Lei Zhang
BUG=pdfium:234 Change-Id: Ia3e758bbe5c445c3856f5215e900e02a16b4d7d7 Reviewed-on: https://pdfium-review.googlesource.com/32910 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-17Update third_party/base/compiler_specific.h.Lei Zhang
Import Chromium's base/compiler_specific.h from r537069. Now that FALLTHROUGH is available via compiler_specific.h, remove FX_FALLTHROUGH. Change-Id: I8b9631a4f007673e10e0c26951dfd61e9dcada30 Reviewed-on: https://pdfium-review.googlesource.com/32639 Reviewed-by: Nico Weber <thakis@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-14Cleanup CPDF_Form parsing codechromium/3431Dan Sinclair
This CL folds the StartParse() method of CPDF_Form into the ParserContent method. The no arguments ParseContent is removed and ParseContentWithParams renamed to ParseContent. The callsites are updated to pass the nullptr's. Bug: chromium:813349 Change-Id: I304b77aef1de1b9aa20e4a3044db5023f5701584 Reviewed-on: https://pdfium-review.googlesource.com/32511 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-10Add CPDF_Transparency.Lei Zhang
Encapsulates transparency status instead of having it be a raw int. Change-Id: I8b10dafa97da112795cf84c46cf416a0294551d5 Reviewed-on: https://pdfium-review.googlesource.com/32194 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-09Mark numerious pointers as const.Lei Zhang
They are mostly CPDF_Object* and derived classes, but others that should be are marked const as well. Change-Id: Ib3344d7d8db90940df8edc97c0dd6c59da080541 Reviewed-on: https://pdfium-review.googlesource.com/32180 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-05-09Add constants for PDF 1.7 spec, table 7.13.Lei Zhang
BUG=pdfium:1049 Change-Id: I3a589fe51f2e584dc130ba31faa144d4494a1b08 Reviewed-on: https://pdfium-review.googlesource.com/32179 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-09Break backcolor code out of CPDF_RenderStatus::LoadSMask().Lei Zhang
Fix some nits in the code in the process. Change-Id: I660b3bf547823a11bc291ed2dd1ec19a76b24b5b Reviewed-on: https://pdfium-review.googlesource.com/32178 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-08Remove almost all usages of CFX_FixedBufGrow with std::vectorNicolas Pena
Tested by running safetynet_compare.py on this patch vs master. The results were 0 regressions and 0 improvements. The two remaining usages cannot be replaced because they would cause a regression. Bug: pdfium:177 Change-Id: I43eddf4ffaac2eb063f2004d6606bc3cd6e627ac Reviewed-on: https://pdfium-review.googlesource.com/32159 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-05-07Add some getters for CPDF_PageObjectHolder.Lei Zhang
Change-Id: I3fe99ecb17d37f893ce5d0d59219c82ee31fe7ea Reviewed-on: https://pdfium-review.googlesource.com/32110 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Initialize CPDF_RenderStatus members in the header.Lei Zhang
Also move static private members into the .cpp file. Change-Id: Idbbdc7c78ac4199968888466caa20c58a5653dfd Reviewed-on: https://pdfium-review.googlesource.com/32151 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-19Change SHADING_STEPS from a #define to a constant.Lei Zhang
Change-Id: I06eab59d7944309d6fe99b97956e8ffb11d64088 Reviewed-on: https://pdfium-review.googlesource.com/30991 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-18Fix integer overflow in shading drawing code.Lei Zhang
BUG=chromium:833721 Change-Id: I3ca878760c12144ef27a71dcbbfd7c18d12a5f3b Reviewed-on: https://pdfium-review.googlesource.com/30992 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-04-12More CPDF_Color improvements.Lei Zhang
Make Copy() take a const-ref parameter. As is, the parameter is a pointer and it is dereferenced without any checks, and there are no crash reports as a result of that. Also mention GetPattern() should only be called when IsPattern() returns true. Change-Id: Ice3b7c941532d5a312fdd8f0c032e08d1ee1c6b5 Reviewed-on: https://pdfium-review.googlesource.com/30430 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-09Pass FX_RECT by const-ref in rendering code.Lei Zhang
Change-Id: I1232e6c61cbe696d90d87f461ebed0a7aea40893 Reviewed-on: https://pdfium-review.googlesource.com/29973 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-09Remove RenderDeviceDriverIface::GetCTM().Lei Zhang
It has no overrides and always returns the identity matrix. Many callers that use the returned value can be simplified, because they are scaling by 1 or concatenating an identity matrix. Change-Id: I7afb7214be210d02638644dfb9b58404420c2ef2 Reviewed-on: https://pdfium-review.googlesource.com/29972 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-09Cleanup CPDF_RenderStatus::GetObjectClippedRect().Lei Zhang
- Just return the rect directly and let the caller check for emptiness. - Get rid of a boolean parameter with always false argument. Change-Id: Ia33587db34c0a628047e59b7faa390c3ac57ec8a Reviewed-on: https://pdfium-review.googlesource.com/29971 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-03Re-arrange so inline vectors come last in structs.Tom Sepez
This might make the memory tools more effective in finding OOBs. Change-Id: Id093bb0a88c37954c80d612ac00b5a168e75bdbf Reviewed-on: https://pdfium-review.googlesource.com/29550 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-03-21Rename one ArgbEncode() variant to AlphaAndColorRefToArgb().Lei Zhang
Mark the other ArgbEncode() variant as constexpr. Change-Id: I84207d805766e5efc669638bd8a15cfead356a41 Reviewed-on: https://pdfium-review.googlesource.com/28577 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-20Rename "RGB" methods/variables to "ColorRef" in CPDF_ColorState.Lei Zhang
Change-Id: I196e3148d680c9efeaf9609dd3ddbfe3f6635fa6 Reviewed-on: https://pdfium-review.googlesource.com/28576 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>