Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Introduce Size type - #6674

Merged
kkaefer merged 1 commit into
masterfrom
6674-size-type
Oct 28, 2016
Merged

kkaefer merged 1 commit into
masterfrom
6674-size-type

Conversation

@kkaefer

@kkaefer kkaefer commented Oct 26, 2016

Copy link
Copy Markdown
Member

We frequently specify sizes that have a width and a height and should introduce a size type that encodes this instead of using std::array<uint16_t, 2> in those places.

/cc @jfirebaugh

@jfirebaugh

Copy link
Copy Markdown
Contributor

👍. This type should basically be geometry::point but a distinct type and w and h as members rather than x and y.

@jfirebaugh jfirebaugh added Core The cross-platform C++ core, aka mbgl refactor labels Oct 17, 2016
@jfirebaugh jfirebaugh self-assigned this Oct 26, 2016
@mention-bot

Copy link
Copy Markdown

@kkaefer, thanks for your PR! By analyzing the history of the files in this pull request, we identified @brunoabinader, @jfirebaugh and @ansis to be potential reviewers.

Comment thread include/mbgl/map/map.hpp Outdated
uint16_t getWidth() const;
uint16_t getHeight() const;
void setSize(Size);
uint32_t getWidth() const;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should combine getWidth() and getHeight() into a single getSize().


float getWidth() const { return image.width / pixelRatio; }
float getHeight() const { return image.height / pixelRatio; }
float getWidth() const { return image.size.width / pixelRatio; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In this particular case, we're using floats to represent the width/height, but our Size type uses integers, so we should keep this.

Comment thread platform/default/offscreen_view.cpp Outdated
}

context.viewport = { 0, 0, size[0], size[1] };
context.viewport = { 0, 0, size.width, size.height };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be able to do context.viewport = { 0, 0, size }.

@kkaefer
kkaefer force-pushed the 6674-size-type branch 3 times, most recently from c51321a to da1d52c Compare October 27, 2016 22:37
@kkaefer kkaefer assigned kkaefer and unassigned jfirebaugh Oct 27, 2016
@kkaefer
kkaefer force-pushed the 6674-size-type branch 2 times, most recently from c2b362d to e71f66b Compare October 28, 2016 01:19
@kkaefer
kkaefer merged commit 62b56b7 into master Oct 28, 2016
@kkaefer
kkaefer deleted the 6674-size-type branch October 28, 2016 01:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Core The cross-platform C++ core, aka mbgl refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants