|
|
DescriptionDesktopRect::UnionWith() to extend current rect to cover the input rect
The logic to calculate a smallest rectangle to cover two rectangles is
duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and
desktop_configuration.mm. Meanwhile the implementation in
desktop_configuration.mm is not safe: if either rectangle is empty, it will
extend current rectangle to cover (0, 0). So a function in DesktopRect to cover
the requirement could be more efficient and safer.
BUG=webrtc:7541
Review-Url: https://codereview.webrtc.org/2845213002
Cr-Commit-Position: refs/heads/master@{#18171}
Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8eb3d346f8b64049
Patch Set 1 #Patch Set 2 : Rename JoinWith to UnionWith #
Total comments: 2
Patch Set 3 : Resolve review comments #
Total comments: 6
Patch Set 4 : Resolve review comments #Patch Set 5 : Sync latest changes #
Messages
Total messages: 62 (39 generated)
The CQ bit was checked by zijiehe@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: presubmit on master.tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/presubmit/builds/16518)
Description was changed from ========== DesktopRect::JoinWith() BUG= ========== to ========== Add a DesktopRect::JoinWith() function to extend current instance to cover both instances This small piece of logic is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile, the implementation in desktop_configuration.mm is not safe. So I think a function in DesktopRect to cover the requirement could be more efficient and safer. I struggle with the name of this function: it's indeed not the "Join" of two rectangles. But I cannot find a better choice. Considering we have a JoinRects() function in desktop_configuration.mm, JoinWith() is still a choice. But I am happy with other names. BUG=webrtc:7541 ==========
zijiehe@chromium.org changed reviewers: + sergeyu@chromium.org
I think "Union" would be suitable a name for this. Technically, the union of two rectangles is not typically a rectangle, but given that it operates on a rectangle, I think the semantics will be pretty clear if you use that name. If you're uncomfortable with that, "BoundingRectangle" is a more verbose option.
The CQ bit was checked by zijiehe@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
On 2017/04/29 00:44:22, jamiewalch wrote: > I think "Union" would be suitable a name for this. Technically, the union of two > rectangles is not typically a rectangle, but given that it operates on a > rectangle, I think the semantics will be pretty clear if you use that name. If > you're uncomfortable with that, "BoundingRectangle" is a more verbose option. Sorry, I have lost tracking this change. Updated.
jamiewalch@google.com changed reviewers: + jamiewalch@google.com
lgtm https://codereview.webrtc.org/2845213002/diff/20001/webrtc/modules/desktop_ca... File webrtc/modules/desktop_capture/desktop_geometry.h (right): https://codereview.webrtc.org/2845213002/diff/20001/webrtc/modules/desktop_ca... webrtc/modules/desktop_capture/desktop_geometry.h:142: // replaces |this| with |rect|. This is not symmetric w.r.t |this| and |rect|. Specifically, if |rect| is empty, |this| will be extended to include it. This might be the behaviour you want, but I think it's worth calling it out explicitly one way or the other here. Also, since this method is complementary to IntersectionWith(), maybe move it to immediately after that method in both header and implementation.
The CQ bit was checked by zijiehe@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.webrtc.org/2845213002/diff/20001/webrtc/modules/desktop_ca... File webrtc/modules/desktop_capture/desktop_geometry.h (right): https://codereview.webrtc.org/2845213002/diff/20001/webrtc/modules/desktop_ca... webrtc/modules/desktop_capture/desktop_geometry.h:142: // replaces |this| with |rect|. On 2017/05/02 22:18:11, jamiewalch wrote: > This is not symmetric w.r.t |this| and |rect|. Specifically, if |rect| is empty, > |this| will be extended to include it. This might be the behaviour you want, but > I think it's worth calling it out explicitly one way or the other here. > > Also, since this method is complementary to IntersectionWith(), maybe move it to > immediately after that method in both header and implementation. A good point, I failed to notice it. I believe a correct behavior is to ignore |rect| if it's empty. In DirectX capturer, the |rect| won't be empty. In desktop_configuration.mm, I do not believe believe pixel_bounds may be empty, otherwise we would have bug for a long time.
The CQ bit was checked by zijiehe@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from jamiewalch@google.com Link to the patchset: https://codereview.webrtc.org/2845213002/#ps40001 (title: "Resolve review comments")
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
The CQ bit was unchecked by commit-bot@chromium.org
No L-G-T-M from a valid reviewer yet. CQ run can only be started once the patch has received an L-G-T-M from a full committer. Even if an L-G-T-M may have been provided, it was from a non-committer,_not_ a full super star committer. Committers are members of the group "project-webrtc-committers". Note that this has nothing to do with OWNERS files.
zijiehe@chromium.org changed reviewers: + zijiehe@chromium.org
Sergey is OoO during these two weeks. Since this is a tiny and safe change, I will LGTM for myself.
On 2017/05/02 23:33:03, Hzj_jie wrote: > Sergey is OoO during these two weeks. Since this is a tiny and safe change, I > will LGTM for myself. lgtm
On 2017/05/02 23:33:29, Hzj_jie wrote: > On 2017/05/02 23:33:03, Hzj_jie wrote: > > Sergey is OoO during these two weeks. Since this is a tiny and safe change, I > > will LGTM for myself. > > lgtm lgtm
The CQ bit was checked by zijiehe@chromium.org
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
The CQ bit was unchecked by commit-bot@chromium.org
No L-G-T-M from a valid reviewer yet. CQ run can only be started once the patch has received an L-G-T-M from a full committer. Even if an L-G-T-M may have been provided, it was from a non-committer,_not_ a full super star committer. Committers are members of the group "project-webrtc-committers". Note that this has nothing to do with OWNERS files.
zijiehe@chromium.org changed reviewers: - zijiehe@chromium.org
It looks like the "Add myself as reviewer" option box does not work as my expectation. I still cannot submit this change without lgtm from Sergey.
jamiewalch@google.com changed reviewers: + wez@chromium.org
On 2017/05/02 23:37:14, Hzj_jie wrote: > It looks like the "Add myself as reviewer" option box does not work as my > expectation. I still cannot submit this change without lgtm from Sergey. You just need someone in OWNERS. I added Wez since Sergey is OOO and it's a simple change.
Please update the description - it still mentions JoinWith(). LGTM once my comments are addressed https://codereview.webrtc.org/2845213002/diff/40001/webrtc/modules/desktop_ca... File webrtc/modules/desktop_capture/desktop_geometry.cc (right): https://codereview.webrtc.org/2845213002/diff/40001/webrtc/modules/desktop_ca... webrtc/modules/desktop_capture/desktop_geometry.cc:42: left_ = rect.left(); *this = rect; https://codereview.webrtc.org/2845213002/diff/40001/webrtc/modules/desktop_ca... webrtc/modules/desktop_capture/desktop_geometry.cc:46: } else if (!rect.is_empty()) { I'd prefer to format this function as follows: if (is_empty()) { *this = rect; return; } if (rect.is_empty()) return; left_ = std::min(left(), rect.left()); top_ = std::min(top(), rect.top()); right_ = std::max(right(), rect.right()); bottom_ = std::max(bottom(), rect.bottom()); This makes the default case obvious and separates it from the cases when one of the rects is empty https://codereview.webrtc.org/2845213002/diff/40001/webrtc/modules/desktop_ca... File webrtc/modules/desktop_capture/desktop_geometry.h (right): https://codereview.webrtc.org/2845213002/diff/40001/webrtc/modules/desktop_ca... webrtc/modules/desktop_capture/desktop_geometry.h:127: // Finds the minimum area to cover both |this| and |rect|. If |this| is empty, It's not clear from this comment that the result is stored in the same object. Maybe reword the first sentence as "Extends the rectangle to cover |rect|."
Description was changed from ========== Add a DesktopRect::JoinWith() function to extend current instance to cover both instances This small piece of logic is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile, the implementation in desktop_configuration.mm is not safe. So I think a function in DesktopRect to cover the requirement could be more efficient and safer. I struggle with the name of this function: it's indeed not the "Join" of two rectangles. But I cannot find a better choice. Considering we have a JoinRects() function in desktop_configuration.mm, JoinWith() is still a choice. But I am happy with other names. BUG=webrtc:7541 ========== to ========== Add a DesktopRect::UnionWith() function to extend current instance to cover both instances This small piece of logic is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile, the implementation in desktop_configuration.mm is not safe. So I think a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 ==========
The CQ bit was checked by zijiehe@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
The CQ bit was checked by zijiehe@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
https://codereview.webrtc.org/2845213002/diff/40001/webrtc/modules/desktop_ca... File webrtc/modules/desktop_capture/desktop_geometry.cc (right): https://codereview.webrtc.org/2845213002/diff/40001/webrtc/modules/desktop_ca... webrtc/modules/desktop_capture/desktop_geometry.cc:42: left_ = rect.left(); On 2017/05/16 19:53:00, Sergey Ulanov wrote: > *this = rect; Done. https://codereview.webrtc.org/2845213002/diff/40001/webrtc/modules/desktop_ca... webrtc/modules/desktop_capture/desktop_geometry.cc:46: } else if (!rect.is_empty()) { On 2017/05/16 19:53:00, Sergey Ulanov wrote: > I'd prefer to format this function as follows: > > if (is_empty()) { > *this = rect; > return; > } > > if (rect.is_empty()) > return; > > left_ = std::min(left(), rect.left()); > top_ = std::min(top(), rect.top()); > right_ = std::max(right(), rect.right()); > bottom_ = std::max(bottom(), rect.bottom()); > > This makes the default case obvious and separates it from the cases when one of > the rects is empty Done. https://codereview.webrtc.org/2845213002/diff/40001/webrtc/modules/desktop_ca... File webrtc/modules/desktop_capture/desktop_geometry.h (right): https://codereview.webrtc.org/2845213002/diff/40001/webrtc/modules/desktop_ca... webrtc/modules/desktop_capture/desktop_geometry.h:127: // Finds the minimum area to cover both |this| and |rect|. If |this| is empty, On 2017/05/16 19:53:00, Sergey Ulanov wrote: > It's not clear from this comment that the result is stored in the same object. > Maybe reword the first sentence as "Extends the rectangle to cover |rect|." Done.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by zijiehe@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from sergeyu@chromium.org, jamiewalch@google.com Link to the patchset: https://codereview.webrtc.org/2845213002/#ps80001 (title: "Sync latest changes")
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
CQ is committing da patch. Bot data: {"patchset_id": 80001, "attempt_start_ts": 1494978449829480, "parent_rev": "9756238084707787f735e1294e896e462e459717", "commit_rev": "73c1234f6aee9ec75074348b8eb3d346f8b64049"}
Message was sent while issue was closed.
Description was changed from ========== Add a DesktopRect::UnionWith() function to extend current instance to cover both instances This small piece of logic is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile, the implementation in desktop_configuration.mm is not safe. So I think a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 ========== to ========== Add a DesktopRect::UnionWith() function to extend current instance to cover both instances This small piece of logic is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile, the implementation in desktop_configuration.mm is not safe. So I think a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ==========
Message was sent while issue was closed.
Committed patchset #5 (id:80001) as https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8...
Message was sent while issue was closed.
BTW: nit about the CL description, for future reference: Short description is "Add a DesktopRect::UnionWith() function to extend current instance to cover both instances" - it isn't clear from context what you mean by "instance", and you use the term twice, without explanation. Similarly, the "detailed" description doesn't add any actually detail beyond mentioning that two code files duplicate "the logic" - there's no description of _which_ logic. In general the CL description provides any additional context for a change that wouldn't make sense as a comment on the actual code (e.g. if we change the code from mechanism A to mechanism B, the code might simply explain how B works, and the CL description might clarify why we're changing it)
Message was sent while issue was closed.
Description was changed from ========== Add a DesktopRect::UnionWith() function to extend current instance to cover both instances This small piece of logic is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile, the implementation in desktop_configuration.mm is not safe. So I think a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ========== to ========== Add a DesktopRect::UnionWith() function to extend current rectangle to cover the input rectangle The UnionWith() logic is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile the implementation in desktop_configuration.mm is not safe: if the input rectangle is empty, it will extend current rectangle to cover (0, 0). So a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ==========
Message was sent while issue was closed.
Description was changed from ========== Add a DesktopRect::UnionWith() function to extend current rectangle to cover the input rectangle The UnionWith() logic is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile the implementation in desktop_configuration.mm is not safe: if the input rectangle is empty, it will extend current rectangle to cover (0, 0). So a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ========== to ========== Add a DesktopRect::UnionWith() function to extend current rectangle to cover the input rectangle The logic to calculate a smallest rectangle to cover two rectangles is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile the implementation in desktop_configuration.mm is not safe: if the either rectangle is empty, it will extend current rectangle to cover (0, 0). So a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ==========
Message was sent while issue was closed.
Thank you Wiz for the feedback. I have updated the description according to your suggestion. Is it better?
Message was sent while issue was closed.
Description was changed from ========== Add a DesktopRect::UnionWith() function to extend current rectangle to cover the input rectangle The logic to calculate a smallest rectangle to cover two rectangles is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile the implementation in desktop_configuration.mm is not safe: if the either rectangle is empty, it will extend current rectangle to cover (0, 0). So a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ========== to ========== Add a DesktopRect::UnionWith() function to extend current rectangle to cover the input rectangle The logic to calculate a smallest rectangle to cover two rectangles is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile the implementation in desktop_configuration.mm is not safe: if either rectangle is empty, it will extend current rectangle to cover (0, 0). So a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ==========
Message was sent while issue was closed.
On 2017/05/17 17:13:42, Hzj_jie wrote: > Thank you Wiz for the feedback. I have updated the description according to your > suggestion. Is it better? Thank you. You could also make the summary line shorter (e.g. it could be "Add a DesktopRect::UnionWith()" for this CL). There is no hard limit. This document says it should be below 50 characters: https://chris.beams.io/posts/git-commit/ (linked from https://www.chromium.org/developers/contributing-code). This may be too strict, summaries in chromium are often longer. But it's best to keep it shorter than description lines, i.e. 72 chars
Message was sent while issue was closed.
Description was changed from ========== Add a DesktopRect::UnionWith() function to extend current rectangle to cover the input rectangle The logic to calculate a smallest rectangle to cover two rectangles is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile the implementation in desktop_configuration.mm is not safe: if either rectangle is empty, it will extend current rectangle to cover (0, 0). So a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ========== to ========== Add a DesktopRect::UnionWith() to extend current rect to cover the input rect The logic to calculate a smallest rectangle to cover two rectangles is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile the implementation in desktop_configuration.mm is not safe: if either rectangle is empty, it will extend current rectangle to cover (0, 0). So a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ==========
Message was sent while issue was closed.
Description was changed from ========== Add a DesktopRect::UnionWith() to extend current rect to cover the input rect The logic to calculate a smallest rectangle to cover two rectangles is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile the implementation in desktop_configuration.mm is not safe: if either rectangle is empty, it will extend current rectangle to cover (0, 0). So a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ========== to ========== DesktopRect::UnionWith() to extend current rect to cover the input rect The logic to calculate a smallest rectangle to cover two rectangles is duplicated in DxgiDuplicatorController, DxgiAdapterDuplicator and desktop_configuration.mm. Meanwhile the implementation in desktop_configuration.mm is not safe: if either rectangle is empty, it will extend current rectangle to cover (0, 0). So a function in DesktopRect to cover the requirement could be more efficient and safer. BUG=webrtc:7541 Review-Url: https://codereview.webrtc.org/2845213002 Cr-Commit-Position: refs/heads/master@{#18171} Committed: https://chromium.googlesource.com/external/webrtc/+/73c1234f6aee9ec75074348b8... ==========
Message was sent while issue was closed.
On 2017/05/17 17:27:35, Sergey Ulanov wrote: > On 2017/05/17 17:13:42, Hzj_jie wrote: > > Thank you Wiz for the feedback. I have updated the description according to > your > > suggestion. Is it better? > > Thank you. You could also make the summary line shorter (e.g. it could be "Add a > DesktopRect::UnionWith()" for this CL). > There is no hard limit. This document says it should be below 50 characters: > https://chris.beams.io/posts/git-commit/ (linked from > https://www.chromium.org/developers/contributing-code). This may be too strict, > summaries in chromium are often longer. But it's best to keep it shorter than > description lines, i.e. 72 chars I still prefer to keep a little bit detail, i.e. the functionality of the newly added function. As Jamie and I discussed in the code review, typically Rectangle.UnionWith() should generate a DesktopRegion but not a DesktopRect. Without a little bit more description, it may be a little bit confusing.
Message was sent while issue was closed.
On 2017/05/17 17:35:34, Hzj_jie wrote: > On 2017/05/17 17:27:35, Sergey Ulanov wrote: > > On 2017/05/17 17:13:42, Hzj_jie wrote: > > > Thank you Wiz for the feedback. I have updated the description according to > > your > > > suggestion. Is it better? > > > > Thank you. You could also make the summary line shorter (e.g. it could be "Add > a > > DesktopRect::UnionWith()" for this CL). > > There is no hard limit. This document says it should be below 50 characters: > > https://chris.beams.io/posts/git-commit/ (linked from > > https://www.chromium.org/developers/contributing-code). This may be too > strict, > > summaries in chromium are often longer. But it's best to keep it shorter than > > description lines, i.e. 72 chars > > I still prefer to keep a little bit detail, i.e. the functionality of the newly > added function. As Jamie and I discussed in the code review, typically > Rectangle.UnionWith() should generate a DesktopRegion but not a DesktopRect. > Without a little bit more description, it may be a little bit confusing. Yes you should put these details in the CL description, but they don't need to be in the summary line (i.e. the first line). It's almost never possible to put all relevant details in one line and it's not what summary line is for. |