Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor improvements and code cleanup for canvas.js #5446

Merged

Conversation

CodingFabian
Copy link
Contributor

These changes are by products of my investigations on slow pdfs.
The impact disappears in the noise, but I still would like to merge them:

  • Direct property access using "[foo]" instead of "foo in"
  • making FULL_CHUNK_HEIGHT a global variable
  • not calculating patternFill every time when read, but set on write
  • replaced fullChunk/partialChunk calculation.

What I find interesting is that a (possibly flawed) benchmark for the
floor+ceil code vs the modulo variant shows so dramatic differences:
http://jsperf.com/floor-and-ceil-or-modulo

I had expected that modulo is faster than invoking the methods, but
the safari 8 result blows my mind. Additionally, I am wondering about
the reason for the Firefox regression for a calculation which has a
modulo !== 0


var glyph = this.processingType3;

if (COMPILE_TYPE3_GLYPHS && glyph && !('compiled' in glyph)) {
var MAX_SIZE_TO_COMPILE = 1000;
if (COMPILE_TYPE3_GLYPHS && glyph && glyph['compiled'] !== undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last comparison looks off. The old code is !('compiled' in glyph), so shouldn't it be !glyph['compiled'] in the new code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct. I reverted this once and seemed to have missed that when retyping. thanks!

@CodingFabian CodingFabian force-pushed the minorImprovementsInCanvasjs branch 2 times, most recently from 81fcf8f to 00b95d9 Compare October 26, 2014 17:47
@timvandermeij
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/6ec16c70295539f/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.22.172.223:8877/6bd5b60d74ddd8d/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/6bd5b60d74ddd8d/output.txt

Total script time: 17.10 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://107.22.172.223:8877/6bd5b60d74ddd8d/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Linux)


Failed

Full output at http://107.21.233.14:8877/6ec16c70295539f/output.txt

Total script time: 22.36 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://107.21.233.14:8877/6ec16c70295539f/reftest-analyzer.html#web=eq.log

@CodingFabian
Copy link
Contributor Author

hu, the image diffs are interesting. need to check whats with that.

@CodingFabian CodingFabian force-pushed the minorImprovementsInCanvasjs branch from 00b95d9 to 6869697 Compare December 16, 2014 19:47
@CodingFabian
Copy link
Contributor Author

okay, pretty stupid math error.
@timvandermeij can you retrigger the /botio test ?

@Snuffleupagus
Copy link
Collaborator

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/0b989db6ebb4dd6/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.22.172.223:8877/8557598532920fb/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/8557598532920fb/output.txt

Total script time: 17.11 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/0b989db6ebb4dd6/output.txt

Total script time: 22.39 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed


var glyph = this.processingType3;

if (COMPILE_TYPE3_GLYPHS && glyph && !('compiled' in glyph)) {
var MAX_SIZE_TO_COMPILE = 1000;
if (COMPILE_TYPE3_GLYPHS && glyph && glyph['compiled'] === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: glyph.compiled === undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am fine with changing, but there are more places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine -- we can fix that latter. I'm looking at that in this code context. Thanks

@yurydelendik
Copy link
Contributor

Good to go with comment above fixed. Thanks

@CodingFabian CodingFabian force-pushed the minorImprovementsInCanvasjs branch 2 times, most recently from d034a32 to c1b8e01 Compare December 18, 2014 19:15
@@ -829,7 +829,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
},
setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
var ctx = this.ctx;
if ('setLineDash' in ctx) {
if (ctx['setLineDash'] !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, are you talking about these? Yeah, let's fix these too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@CodingFabian CodingFabian force-pushed the minorImprovementsInCanvasjs branch from c1b8e01 to 6ffcafe Compare December 18, 2014 19:58
@yurydelendik
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @yurydelendik received. Current queue size: 0

Live output at: http://107.22.172.223:8877/9f550d10b0c6b14/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @yurydelendik received. Current queue size: 0

Live output at: http://107.21.233.14:8877/e3038493bfc1e31/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/9f550d10b0c6b14/output.txt

Total script time: 17.52 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/e3038493bfc1e31/output.txt

Total script time: 22.70 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

destCtx.setLineDash(sourceCtx.getLineDash());
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
} else if ('mozDash' in sourceCtx) {
} else if (sourceCtx.mozDash !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember mozDash property has to create an array, can we switch that to the mozDashOffset check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@CodingFabian CodingFabian force-pushed the minorImprovementsInCanvasjs branch from 6ffcafe to 5405b1c Compare December 18, 2014 20:59
yurydelendik added a commit that referenced this pull request Dec 18, 2014
minor improvements and code cleanup for canvas.js
@yurydelendik yurydelendik merged commit a018e93 into mozilla:master Dec 18, 2014
@yurydelendik
Copy link
Contributor

Excellent! Thank you.

speedplane pushed a commit to speedplane/pdf.js that referenced this pull request Feb 24, 2015
…Canvasjs

minor improvements and code cleanup for canvas.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants