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

DRY up VideoSource code #3353

Merged
merged 1 commit into from
Oct 12, 2016
Merged

DRY up VideoSource code #3353

merged 1 commit into from
Oct 12, 2016

Conversation

mourner
Copy link
Member

@mourner mourner commented Oct 12, 2016

While looking into #3350, I noticed that most of the VideoSource code is a copy-paste from ImageSource. This PR removes a lot of duplication by making VideoSource inherit from ImageSource.

We might later consider some kind of composition instead of inheritance, or inheriting both from a shared base class (e.g. GeoreferencedSource), but I'd leave that for later when we address #3186.

👀 @lucaswoj @ansis

@mourner
Copy link
Member Author

mourner commented Oct 12, 2016

Forgot to mention that this PR also fixes ImageSource constantly recreating the GL texture on every frame — previously _prepared was never set to true for some reason (while it was in VideoSource).

@@ -107,92 +97,18 @@ VideoSource.prototype = util.inherit(Evented, /** @lends VideoSource.prototype *
/**
* Sets the video's coordinates and re-renders the map.
*
* @method setCoordinates
* @param {Array<Array<number>>} coordinates Four geographical coordinates,
* represented as arrays of longitude and latitude numbers, which define the corners of the video.
* The coordinates start at the top left corner of the video and proceed in clockwise order.
* They do not have to represent a rectangle.
* @returns {VideoSource} this
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we eliminate the need for this inherited comment by rewording it? s/video/source or s/video/data or s/video/layer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe, but what to do with @returns {VideoSource}? cc @jfirebaugh

Copy link
Contributor

Choose a reason for hiding this comment

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

Oooh. Good point.

Copy link
Contributor

@lucaswoj lucaswoj left a comment

Choose a reason for hiding this comment

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

Looks good! 84 lines lighter! 🎈

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.

2 participants