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

Replace pdf_path & gs_stack with Vec #57

Merged
merged 7 commits into from
Sep 15, 2019
Merged

Conversation

burrbull
Copy link
Collaborator

@burrbull burrbull commented Sep 14, 2019

use Option<CString> for spot_color_name in pdf_color and other changes in dpx_pdfdraw.rs

Note: issue393_ungetc test doesn't pass now. Panics on empty gs_stack. I think it is not my fault.

@burrbull
Copy link
Collaborator Author

Fixed

@@ -236,6 +236,16 @@ impl pdf_tmatrix {
f: 0.,
}
}
pub const fn init() -> Self {
Copy link
Owner

Choose a reason for hiding this comment

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

identity or something like that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@crlf0710
Copy link
Owner

Do you mind leaving this PR pending for a few days... There're some structural changes that i want to make first. And the state management is too much relying on the global variables (Thus the Mutex). I think we'll want to change that.

@@ -266,6 +276,12 @@ impl pdf_coord {
Self { x: 0., y: 0. }
}
}
impl PartialEq for pdf_coord {
Copy link
Owner

Choose a reason for hiding this comment

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

I think this PartialEq is very weird... Do you think make it a method is a better idea?

Copy link
Collaborator

Choose a reason for hiding this comment

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

More precisely, it’s symmetric but not transitive, so you shouldn’t implement PartialEq this way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See last commit.

Copy link
Owner

Choose a reason for hiding this comment

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

PartialEq actually doesn't have to be transitive, Eq have to be. But it's still better to not hide these kind of logic under equal operator。

strokecolor: pdf_color_graycolor_new(0.).unwrap(),
fillcolor: pdf_color_graycolor_new(0.).unwrap(),
linedash: LineDash::default(),
linecap: 0,
Copy link
Owner

Choose a reason for hiding this comment

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

line cap and line join can be turned into enum in a future pr.

use std::sync::Mutex;

lazy_static! {
static ref gs_stack: Mutex<Vec<pdf_gstate>> = Mutex::new({
Copy link
Owner

Choose a reason for hiding this comment

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

i'm not very happy with the Mutex here. Can we add a struct called PdfDev or pdf_dev and collect these global states within it. and make the drawing invocations its method? (might be a big change to the code base)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Helpful for seeing which statics are linked to by C++:

rg 'static mut (\w+):' myfile -o -r '$1' | xargs -n1 -I {} sh -c 'echo {} && rg -F {} c_sources_directory'

Generally this helps for moving definitions out of extern “C” when they don’t need to be in one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'm not very happy with the Mutex here. Can we add a struct called PdfDev or pdf_dev and collect these global states within it. and make the drawing invocations its method? (might be a big change to the code base)

I thought about this variant too. The problem as you say, it is a big change. And most likely we will be able to do this at one of the last steps of "oxidation".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mutex moved to start of file. Comment added.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@crlf0710
Copy link
Owner

Let's merge it, i think.

@crlf0710 crlf0710 merged commit 89f4e0b into crlf0710:oxidize Sep 15, 2019
@burrbull burrbull deleted the pdfpathvec branch September 15, 2019 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants