Make CanvasResourceProvider::IsOriginTopLeft virtual [chromium/src : main]

0 views
Skip to first unread message

Vasiliy Telezhnikov (Gerrit)

unread,
Nov 12, 2024, 2:17:29 PMNov 12
to Jean-Philippe Gravel, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, blink-reviews-p...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, kinuko...@chromium.org
Attention needed from Jean-Philippe Gravel

Vasiliy Telezhnikov added 1 comment

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Vasiliy Telezhnikov . resolved

Please, take a look.

Open in Gerrit

Related details

Attention is currently required from:
  • Jean-Philippe Gravel
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5dcfcd7d1cab3e918562547dffa9e17c1f2e1cf8
Gerrit-Change-Number: 6000557
Gerrit-PatchSet: 5
Gerrit-Owner: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Reviewer: Jean-Philippe Gravel <jpgr...@chromium.org>
Gerrit-Reviewer: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Jean-Philippe Gravel <jpgr...@chromium.org>
Gerrit-Comment-Date: Tue, 12 Nov 2024 19:17:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Jean-Philippe Gravel (Gerrit)

unread,
Nov 12, 2024, 8:33:31 PMNov 12
to Vasiliy Telezhnikov, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, blink-reviews-p...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, kinuko...@chromium.org
Attention needed from Vasiliy Telezhnikov

Jean-Philippe Gravel voted and added 1 comment

Votes added by Jean-Philippe Gravel

Code-Review+1

1 comment

Commit Message
Line 10, Patchset 5 (Latest):This CL makes it virtual and override in Passthrough, so it's easier
to eliminate call-sites and the function all together.
Jean-Philippe Gravel . unresolved

Do you mean that in a follow up, you'll remove the IsOriginTopLeft method?

As a general thought on this, I find that we often abuse inheritance and virtual calls. Adding a virtual method to a base class when that feature is only ever needed by one child class seems more like and unfortunate consequence of how the code is structured (e.g. I need to use this feature of child class but all I have is a pointer to the parent class) than a correct use of an API interface.

But maybe that's not the case here: the position of the origin is a trait that all child classes care about, irrespective of the default. It remains that by replacing the member attribute with a virtual call, we are adding virtual dispatches in places where we originally had direct access to the value, which complexifies data flow and could impact performance. I've been bitten many times by thinking that a certain method is being used, when in reality, an unexpected remotely defined override is actually being used. All that to say that there is advantages to having a member attribute in the parent class. But if all this is going away, either option works.

Open in Gerrit

Related details

Attention is currently required from:
  • Vasiliy Telezhnikov
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5dcfcd7d1cab3e918562547dffa9e17c1f2e1cf8
Gerrit-Change-Number: 6000557
Gerrit-PatchSet: 5
Gerrit-Owner: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Reviewer: Jean-Philippe Gravel <jpgr...@chromium.org>
Gerrit-Reviewer: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Comment-Date: Wed, 13 Nov 2024 01:33:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Vasiliy Telezhnikov (Gerrit)

unread,
Nov 13, 2024, 9:48:00 AMNov 13
to Jean-Philippe Gravel, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, blink-reviews-p...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, kinuko...@chromium.org

Vasiliy Telezhnikov voted and added 2 comments

Votes added by Vasiliy Telezhnikov

Commit-Queue+2

2 comments

Patchset-level comments
Vasiliy Telezhnikov . resolved

Thanks for the review.

Commit Message
Line 10, Patchset 5 (Latest):This CL makes it virtual and override in Passthrough, so it's easier
to eliminate call-sites and the function all together.
Jean-Philippe Gravel . resolved

Do you mean that in a follow up, you'll remove the IsOriginTopLeft method?

As a general thought on this, I find that we often abuse inheritance and virtual calls. Adding a virtual method to a base class when that feature is only ever needed by one child class seems more like and unfortunate consequence of how the code is structured (e.g. I need to use this feature of child class but all I have is a pointer to the parent class) than a correct use of an API interface.

But maybe that's not the case here: the position of the origin is a trait that all child classes care about, irrespective of the default. It remains that by replacing the member attribute with a virtual call, we are adding virtual dispatches in places where we originally had direct access to the value, which complexifies data flow and could impact performance. I've been bitten many times by thinking that a certain method is being used, when in reality, an unexpected remotely defined override is actually being used. All that to say that there is advantages to having a member attribute in the parent class. But if all this is going away, either option works.

Vasiliy Telezhnikov

Yes, I plan to remove IsOriginTopLeft from everywhere eventually.

I agree that it has theoretical performance impact, but unless whole chrome would try to avoid virtual calls and memory allocations on the critical path there is no practical difference.

And I agree that from architectural point of view it might be better to have variable and non-virtual getter, but tooling-wise it's much more complicated to trace all places where variable comes from, especially if it's plumbed through few functions vs all overrides of the function. And to easier reasoning for the follow-up CLs that are based on "This code place doesn't use CanvasReourceProviderPassthrough, so origin can't be bottom left" I want to land this as prerequisite.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5dcfcd7d1cab3e918562547dffa9e17c1f2e1cf8
Gerrit-Change-Number: 6000557
Gerrit-PatchSet: 5
Gerrit-Owner: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Reviewer: Jean-Philippe Gravel <jpgr...@chromium.org>
Gerrit-Reviewer: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Comment-Date: Wed, 13 Nov 2024 14:47:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Jean-Philippe Gravel <jpgr...@chromium.org>
satisfied_requirement
open
diffy

Jean-Philippe Gravel (Gerrit)

unread,
Nov 13, 2024, 9:50:15 AMNov 13
to Vasiliy Telezhnikov, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, blink-reviews-p...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, kinuko...@chromium.org
Attention needed from Vasiliy Telezhnikov

Jean-Philippe Gravel added 1 comment

Commit Message
Line 10, Patchset 5 (Latest):This CL makes it virtual and override in Passthrough, so it's easier
to eliminate call-sites and the function all together.
Jean-Philippe Gravel . resolved

Do you mean that in a follow up, you'll remove the IsOriginTopLeft method?

As a general thought on this, I find that we often abuse inheritance and virtual calls. Adding a virtual method to a base class when that feature is only ever needed by one child class seems more like and unfortunate consequence of how the code is structured (e.g. I need to use this feature of child class but all I have is a pointer to the parent class) than a correct use of an API interface.

But maybe that's not the case here: the position of the origin is a trait that all child classes care about, irrespective of the default. It remains that by replacing the member attribute with a virtual call, we are adding virtual dispatches in places where we originally had direct access to the value, which complexifies data flow and could impact performance. I've been bitten many times by thinking that a certain method is being used, when in reality, an unexpected remotely defined override is actually being used. All that to say that there is advantages to having a member attribute in the parent class. But if all this is going away, either option works.

Vasiliy Telezhnikov

Yes, I plan to remove IsOriginTopLeft from everywhere eventually.

I agree that it has theoretical performance impact, but unless whole chrome would try to avoid virtual calls and memory allocations on the critical path there is no practical difference.

And I agree that from architectural point of view it might be better to have variable and non-virtual getter, but tooling-wise it's much more complicated to trace all places where variable comes from, especially if it's plumbed through few functions vs all overrides of the function. And to easier reasoning for the follow-up CLs that are based on "This code place doesn't use CanvasReourceProviderPassthrough, so origin can't be bottom left" I want to land this as prerequisite.

Jean-Philippe Gravel

Sounds good!

Open in Gerrit

Related details

Attention is currently required from:
  • Vasiliy Telezhnikov
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5dcfcd7d1cab3e918562547dffa9e17c1f2e1cf8
Gerrit-Change-Number: 6000557
Gerrit-PatchSet: 5
Gerrit-Owner: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Reviewer: Jean-Philippe Gravel <jpgr...@chromium.org>
Gerrit-Reviewer: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Attention: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Comment-Date: Wed, 13 Nov 2024 14:50:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Vasiliy Telezhnikov <vas...@chromium.org>
Comment-In-Reply-To: Jean-Philippe Gravel <jpgr...@chromium.org>
satisfied_requirement
open
diffy

Vasiliy Telezhnikov (Gerrit)

unread,
Nov 13, 2024, 11:37:59 AMNov 13
to Jean-Philippe Gravel, Chromium LUCI CQ, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, blink-reviews-p...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, kinuko...@chromium.org

Vasiliy Telezhnikov voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5dcfcd7d1cab3e918562547dffa9e17c1f2e1cf8
Gerrit-Change-Number: 6000557
Gerrit-PatchSet: 6
Gerrit-Owner: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Reviewer: Jean-Philippe Gravel <jpgr...@chromium.org>
Gerrit-Reviewer: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-CC: Dirk Schulze <dsch...@chromium.org>
Gerrit-CC: Stephen Chenney <sche...@chromium.org>
Gerrit-Comment-Date: Wed, 13 Nov 2024 16:37:48 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Chromium LUCI CQ (Gerrit)

unread,
Nov 13, 2024, 11:41:55 AMNov 13
to Vasiliy Telezhnikov, Jean-Philippe Gravel, chromium...@chromium.org, Dirk Schulze, Stephen Chenney, blink-reviews-p...@chromium.org, blink-...@chromium.org, drott+bl...@chromium.org, fmalit...@chromium.org, fserb...@chromium.org, kinuko...@chromium.org

Chromium LUCI CQ submitted the change

Unreviewed changes

5 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Change information

Commit message:
Make CanvasResourceProvider::IsOriginTopLeft virtual

Only CanvasResourceProviderPassthrough can have bottom left origin.

This CL makes it virtual and override in Passthrough, so it's easier
to eliminate call-sites and the function all together.
Bug: 378688985
Change-Id: I5dcfcd7d1cab3e918562547dffa9e17c1f2e1cf8
Commit-Queue: Vasiliy Telezhnikov <vas...@chromium.org>
Reviewed-by: Jean-Philippe Gravel <jpgr...@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382382}
Files:
  • M third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc
  • M third_party/blink/renderer/platform/graphics/canvas_resource_provider.cc
  • M third_party/blink/renderer/platform/graphics/canvas_resource_provider.h
Change size: S
Delta: 3 files changed, 10 insertions(+), 18 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Jean-Philippe Gravel
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5dcfcd7d1cab3e918562547dffa9e17c1f2e1cf8
Gerrit-Change-Number: 6000557
Gerrit-PatchSet: 7
Gerrit-Owner: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Jean-Philippe Gravel <jpgr...@chromium.org>
Gerrit-Reviewer: Vasiliy Telezhnikov <vas...@chromium.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages