summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render
AgeCommit message (Collapse)Author
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-25Revert "Remove unreachable code in CPDF_DIBBase."Lei Zhang
This reverts commit 214982c4d02a720c3b1b3de121cddc62189b8848. Reason for revert: Turns out it is reachable. Original change's description: > Remove unreachable code in CPDF_DIBBase. > > The colorspace is always available when creating image decoders that use > colorspaces. > > Change-Id: I20ac75edcd614ccc1e83de262c128776e9d03eed > Reviewed-on: https://pdfium-review.googlesource.com/42872 > Commit-Queue: Ryan Harrison <rharrison@chromium.org> > Reviewed-by: Ryan Harrison <rharrison@chromium.org> TBR=thestig@chromium.org,rharrison@chromium.org BUG=chromium:888743 # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I45903543f0e4bf2785660fb8c1e45c34febb6ecf Reviewed-on: https://pdfium-review.googlesource.com/43050 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@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-21Remove unreachable code in CPDF_DIBBase.Lei Zhang
The colorspace is always available when creating image decoders that use colorspaces. Change-Id: I20ac75edcd614ccc1e83de262c128776e9d03eed Reviewed-on: https://pdfium-review.googlesource.com/42872 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-09-21Validate more image values in CPDF_DIBBase.Lei Zhang
Change-Id: Ia5f72e6397ee959d897a945c4069f47c494b5511 Reviewed-on: https://pdfium-review.googlesource.com/42870 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-09-20Remove many unneeded STL #includes from headers.Lei Zhang
Change-Id: I7010cedee8d17d05b2c37a94d767e6f3a9c48f7d Reviewed-on: https://pdfium-review.googlesource.com/42790 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-19Initialize CPDF_ImageRenderer in the header.Lei Zhang
Also add a GetRenderOptions() helper method. Change-Id: I47db7a21f55f396e08775575f6b2a48e440c2f91 Reviewed-on: https://pdfium-review.googlesource.com/42750 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-09-19Encapsulate CPDF_ImageLoader.Lei Zhang
Change-Id: Iee7ce04630fed86f651cd382a19e46b2f7ab6d61 Reviewed-on: https://pdfium-review.googlesource.com/42672 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: 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-09-17Encapsulate CPDF_StreamAcc::LoadAllData().Lei Zhang
Make it a private method, and add public methods so only limited combinations of LoadAllData() arguments are possible. Change-Id: I8c2220eb0e95012350858876586f7c470c40a7c3 Reviewed-on: https://pdfium-review.googlesource.com/42590 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@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-29Remove FPDFAPI_ prefix from internal cid/encoder functionsTom Sepez
These look too much like public/ FPDF functions otherwise and yet they are not exposed anywhere beyond core/fpdfapi. Disambiguate one method vs. top-level function usage as a result. Bug: pdfium:1141 Change-Id: I9cfdfced90386bb9ef6b2b86f568f2e6f8ee6a5a Reviewed-on: https://pdfium-review.googlesource.com/41530 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-28Use pdfium::span<> in more image modulesTom Sepez
Change-Id: Ie344bb37abf7dde158d03cc2897dca3588f1a5e3 Reviewed-on: https://pdfium-review.googlesource.com/41550 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-28Use std::span<> in CCodec_JPEGModuleTom Sepez
Also rename .cpp file to match class name and .h file. Modify some helper functions to operate on spans. Move some initializations to member declarations. Change-Id: Ie0889bda91daaef80fae6f5681f8ce068e92453b Reviewed-on: https://pdfium-review.googlesource.com/41534 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-27Use pdfium::span<> in CCodec_RLScanlineDecoderTom Sepez
Change-Id: I3dc2dd54d89858722c2aea4b9e694308796b8274 Reviewed-on: https://pdfium-review.googlesource.com/41510 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-27The final game: mark everything final.Tom Sepez
Then revert the ones that break compilation. Fix one IWYU noticed during presubmit. Change-Id: I881a8a72818e55dbc4816247e35ff5e3015194e7 Reviewed-on: https://pdfium-review.googlesource.com/41470 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@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-23Fix GCC build with V8 disabled.Lei Zhang
- Remove set, but otherwise unused variables. - Mark some pdfium_test code as V8-enabled only. - Do not build one unit test with GCC. Change-Id: I3f04273a7731086e08386478a62769bf06f6d8a4 Reviewed-on: https://pdfium-review.googlesource.com/41271 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@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 default args from CPDF_DIBSource::StartLoadDIBSource().Tom Sepez
Change-Id: I13f53f581487f643acf160f53d02e9af7d54cfd1 Reviewed-on: https://pdfium-review.googlesource.com/40151 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-10Remove const args and const_casts where not required.Tom Sepez
Introduce const/non-const versions of method where required. Part of the war on const_cast<>. Tidy one expression to use [] instead of .data(). Change-Id: I41e45669c79eee242ff2244c7dc3afcf6386a433 Reviewed-on: https://pdfium-review.googlesource.com/39852 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-10Add CFX_DIBSource::GetWritableScanline().Tom Sepez
Remove a bunch of const_cast<uint8_t*> or equivalent. This will also help when we convert to span<>, since casting spans is a nuisance. Change-Id: I330e5041cbaf33a84425fc4242a3dfacf5ca8011 Reviewed-on: https://pdfium-review.googlesource.com/39831 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-09Change CPDF_Font::GetNextChar()'s in-out parameter to pass by pointer.chromium/3518Lei Zhang
Instead of passing by non-const reference. Adjust the override in CPDF_CIDFont and CPDF_CMap::GetNextChar() as well. Change-Id: I0ee6dc21077101cbeeb0e334498075fc463a2d65 Reviewed-on: https://pdfium-review.googlesource.com/39492 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@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-18Improve image size validation in CPDF_ScaledRenderBuffer.Lei Zhang
In CPDF_ScaledRenderBuffer::Initialize(), use the existing CFX_DIBitmap::CalculatePitchAndSize() function to figure out the pitch and size. Unlike the existing code, CalculatePitchAndSize() does a better job of checking for integer overflows. BUG=pdfium:1123 Change-Id: Ic8fe7226bc56fed0456486d88e02a7af2928bc94 Reviewed-on: https://pdfium-review.googlesource.com/38010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@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-10Fix m_ExtGID usage in CPDF_CharPosListNicolás Peña
This CL allows Apple to use m_GlyphIndex as a replacement for m_ExtGID when it is invalid. Bug: pdfium:1121 Change-Id: I49e7936201815bae5a2c8a26680fc1e542a60c43 Reviewed-on: https://pdfium-review.googlesource.com/37390 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-07-05Fix integer overflow in CPDF_Type3Cachechromium/3483Nicolas Pena
Bug: chromium:845800 Change-Id: Ib878dd991e435a76b63b662ef3d9d33c2cc61a19 Reviewed-on: https://pdfium-review.googlesource.com/37191 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@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-26Add some more consts to unowned pointers.Tom Sepez
Ideally, unowned ptrs might well be const, as updating something through an unowned reference is best avoided. Change-Id: Ida8111ffe0ee1e30bbf6b7718b0929dfb5cafdff Reviewed-on: https://pdfium-review.googlesource.com/36050 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@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-21Avoid const-refs to implicitly constructed strings.Tom Sepez
Because the invisible temporary goes out of scope at the next semicolon. Also avoid returning const string references since the cost is low to properly keep the string alive. Change-Id: Id283e4fd99f79a02d79d739a533a4ce05e831e2a Reviewed-on: https://pdfium-review.googlesource.com/35710 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@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-13Remove almost all usages of CFX_FixedBufGrow from cpdf_dibsource.cppNicolas Pena
This CL removes all the usages of CFX_FixedBufGrow, except for one that would cause performance issues for our corpus tests. Bug: pdfium:177 Change-Id: I0ad76c14f713b116cf7dce50606554e3b03d9f2c Reviewed-on: https://pdfium-review.googlesource.com/35150 Commit-Queue: Nicolás Peña Moreno <npm@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-05Tidy parser lifecycle state machine in CPDF_PageObjectHolder.Tom Sepez
Only update state in CPDF_PageObjectHolder itself. Make more data private. Remove CPDF_Page::GetPageBBox() as exact duplicate of CPDF_PageObjectHolder::GetBBox(). Change-Id: I083ec33f61a1490e7a5e673c9787751af15a6cd1 Reviewed-on: https://pdfium-review.googlesource.com/33810 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@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-31Clean up some nits in CPDF_Type3GlyphNicolas Pena
Change-Id: Ia466bb0119d914794b0d7ed9385547a7be245858 Reviewed-on: https://pdfium-review.googlesource.com/33312 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-05-31Handle image mask continuous loading correctlyWei Li
When image mask doesn't need multi-steps to load, ContinueLoadMaskDIB() will return LoadState::kFail as result. For this case, the loading should continue as usual instead of aborting. BUG=pdfium:1087 Change-Id: I5c43a67e43469ac7febca4c0cf1faa96ee105206 Reviewed-on: https://pdfium-review.googlesource.com/33310 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Wei Li <weili@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>