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

Split large unsafe block in rasterize_glyph() into multiple smaller ones #757

Merged
merged 1 commit into from Jan 20, 2017

Conversation

@hgallagher1993
Copy link
Contributor

hgallagher1993 commented Jan 19, 2017

Fixes issue #515

r? @emilio not really sure who to assign to tbh


This change is Reviewable

Copy link
Member

emilio left a comment

Looks great, thanks for looking into this!

I think that alignment issue should be fixed if it's not too much churn, what do you think?

let metrics = unsafe { &(*slot).metrics };
let mut glyph_width = (metrics.width >> 6) as i32;
let glyph_height = (metrics.height >> 6) as i32;
let mut final_buffer = Vec::with_capacity(glyph_width as usize *

This comment has been minimized.

@emilio

emilio Jan 19, 2017

Member

This alignment looks weird, can you align everything to the paren?

This comment has been minimized.

@hgallagher1993

hgallagher1993 Jan 19, 2017

Author Contributor

Do mean have these lines lined up like this?

...(*slot).metrics
...(metrics.width >> 6)
...(metrics.height >> 6)

This comment has been minimized.

@emilio

emilio Jan 20, 2017

Member

Nope, I meant the arguments to Vec::with_capacity.

This comment has been minimized.

@hgallagher1993

hgallagher1993 Jan 20, 2017

Author Contributor

Ok I read over the code a load of times and I'm really not sure how I missed that. . .since it's only alignment will I just do --fixup?

This comment has been minimized.

@emilio

emilio Jan 20, 2017

Member

Yeah, that sounds fine :)

This comment has been minimized.

@emilio

emilio Jan 20, 2017

Member

Yup! Nice, can you squash your commits?

This comment has been minimized.

@hgallagher1993

hgallagher1993 Jan 20, 2017

Author Contributor

That's this (from the servo workflow) git rebase -i --autosquash .....? . . .This is only my second pull request to an opensource project so still getting used to the work flow :-)

This comment has been minimized.

@emilio

emilio Jan 20, 2017

Member

Yes, right, that's it :)

No worries! It's normal :P

This comment has been minimized.

@hgallagher1993

hgallagher1993 Jan 20, 2017

Author Contributor

I think that's done now

This comment has been minimized.

@emilio

emilio Jan 20, 2017

Member

Awesome, thanks!

@hgallagher1993 hgallagher1993 force-pushed the hgallagher1993:local_branch branch from 8ebe3d9 to be0a460 Jan 20, 2017
@emilio
Copy link
Member

emilio commented Jan 20, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jan 20, 2017

📌 Commit be0a460 has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Jan 20, 2017

Testing commit be0a460 with merge f7d3d38...

bors-servo added a commit that referenced this pull request Jan 20, 2017
Split large unsafe block in rasterize_glyph() into multiple smaller ones

Fixes issue #515

r? @emilio not really sure who to assign to tbh

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/757)
<!-- Reviewable:end -->
@kvark
kvark approved these changes Jan 20, 2017
let byte_value = if valid_byte {
let byte_index = (y * bitmap.pitch as i32) + (x >> 3);

unsafe {
let bit_index = x & 7;
let byte_ptr = bitmap.buffer.offset(byte_index as isize);
let bit = (*byte_ptr & (0x80 >> bit_index)) != 0;

This comment has been minimized.

@kvark

kvark Jan 20, 2017

Member

I think *byte_ptr is the only expression in here that is unsafe

This comment has been minimized.

@hgallagher1993

hgallagher1993 Jan 20, 2017

Author Contributor

Well bit_index definitely shouldn't be in there don't know why I left it in there tbh, but the line above *byte_ptr is unsafe as well let byte_ptr = bitmap.buffer.offset(byte_index as isize);

So it'd have to be changed to

let byte_ptr = unsafe { ... }
let bit = unsafe { ... }

No problem changing if you think it's worth it?

This comment has been minimized.

@kvark

kvark Jan 20, 2017

Member

Ah, I didn't know offset is unsafe. TIL.
Never mind then!

This comment has been minimized.

@hgallagher1993

hgallagher1993 Jan 20, 2017

Author Contributor

|
187 | let byte_ptr = bitmap.buffer.offset(byte_index as isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invocation of unsafe method

error: aborting due to previous error

error: Could not compile webrender.

Yup definitely!

@bors-servo
Copy link
Contributor

bors-servo commented Jan 20, 2017

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit be0a460 into servo:master Jan 20, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.