-
Notifications
You must be signed in to change notification settings - Fork 6k
Add DlSamplingOptions & DlFilterMode #34024
Add DlSamplingOptions & DlFilterMode #34024
Conversation
52d97e5 to
b16b89b
Compare
b16b89b to
5223b9b
Compare
|
I don't see an issue filed per the guidelines of flutter/flutter#95434 Filing the issue and linking it to the umbrella task is important so that we track who is working on what features at any time and can prepare for them in Impeller. We can also provide guidance for the task. The current guidance in the umbrella issue is that we do not need the flexibility of SkSamplingOptions in DL or Impeller and so a simple enum will be fine. It would actually be far far preferable because we have no intention of implementing any options beyond the 4 enum values that Flutter uses in Impeller. Please create the issue, link it to the line in the description in the umbrella issue above as is customary, and replace DlSamplingOptions with: For the methods which take an SkFilterMode, we should probably use the above enum and just treat Mipmap and Cubic as Linear. |
flar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented with a few code cleanup issues, but there are also a couple of general issues to look at:
- The new enums need unit tests in display_list_enum_unittests.cc
- Nearly everywhere SkSamplingOptions was used as a parameter to a method it was qualified with const so that the object could not be modified. Now that it is an enum it is passed by value ad so the const qualifiers are no longer relevant.
(const is still needed where Sampling is a field in a class, though, to prevent modification)
|
Also, create an Issue for this work and link it in to the umbrella Issue as mentioned in flutter/flutter#95434 (comment) |
flar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only really critical change is that all fields in all structs defined in dl_ops.h need to be const so that the DL records are read-only, so those "const" modifiers need to be restored.
Everything else is a nit.
display_list/display_list_ops.h
Outdated
| \ | ||
| const SkPoint point; \ | ||
| const DlImageSampling sampling; \ | ||
| DlImageSampling sampling; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a field declaration. Leave const here so that the record cannot be modified.
(The const in the argument list is OK to remove, just not "const" on a variable or field declaration.)
display_list/display_list_ops.h
Outdated
| const SkRect src; | ||
| const SkRect dst; | ||
| const DlImageSampling sampling; | ||
| DlImageSampling sampling; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave const here.
display_list/display_list_ops.h
Outdated
| const uint8_t has_colors; | ||
| const uint8_t render_with_attributes; | ||
| const DlImageSampling sampling; | ||
| DlImageSampling sampling; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave const here.
| return DlImageSampling::kMipmapLinear; | ||
| } | ||
| } | ||
| if (so.filter == SkFilterMode::kNearest && so.mipmap == SkMipmapMode::kNone) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if statement isn't useful any more, now that the default return value below it is kNearest.
| }; | ||
| const sk_sp<SkImage> image = CanvasCompareTester::kTestImage; | ||
| const DlImageSampling sampling = DlImageSampling::kNearestNeighbor; | ||
| DlImageSampling sampling = DlImageSampling::kNearestNeighbor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 3 const modifiers should probably be left in because they are locking a local variable against modification. Only "const" in argument lists is unnecessary.
| }; | ||
| const sk_sp<SkImage> image = CanvasCompareTester::kTestImage; | ||
| const DlImageSampling sampling = DlImageSampling::kNearestNeighbor; | ||
| DlImageSampling sampling = DlImageSampling::kNearestNeighbor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore const here.
| }; | ||
| const sk_sp<SkImage> image = CanvasCompareTester::kTestImage; | ||
| const DlImageSampling sampling = DlImageSampling::kLinear; | ||
| DlImageSampling sampling = DlImageSampling::kLinear; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore const here.
flar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This reverts commit e25d1ce.
Fixes flutter/flutter#106013
Using DlSamplingOptions and DlFilterMode to replace SkSamplingOptions and SkFilterMode