Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@JsouLiang
Copy link
Contributor

@JsouLiang JsouLiang commented Jun 14, 2022

Fixes flutter/flutter#106013

Using DlSamplingOptions and DlFilterMode to replace SkSamplingOptions and SkFilterMode

@JsouLiang JsouLiang requested review from chinmaygarde and flar June 14, 2022 03:09
@JsouLiang JsouLiang force-pushed the Add_DlSamplingOptions_DlFilterMode branch from 52d97e5 to b16b89b Compare June 14, 2022 03:33
@JsouLiang JsouLiang force-pushed the Add_DlSamplingOptions_DlFilterMode branch from b16b89b to 5223b9b Compare June 14, 2022 06:38
@flar
Copy link
Contributor

flar commented Jun 14, 2022

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:

enum class DlImageSampling {
   kNearestNeighbor,
   kLinear,
   kMipmapLinear,
   kCubic,
};

For the methods which take an SkFilterMode, we should probably use the above enum and just treat Mipmap and Cubic as Linear.

Copy link
Contributor

@flar flar left a 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)

@flar
Copy link
Contributor

flar commented Jun 15, 2022

Also, create an Issue for this work and link it in to the umbrella Issue as mentioned in flutter/flutter#95434 (comment)

Copy link
Contributor

@flar flar left a 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.

\
const SkPoint point; \
const DlImageSampling sampling; \
DlImageSampling sampling; \
Copy link
Contributor

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.)

const SkRect src;
const SkRect dst;
const DlImageSampling sampling;
DlImageSampling sampling;
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave const here.

const uint8_t has_colors;
const uint8_t render_with_attributes;
const DlImageSampling sampling;
DlImageSampling sampling;
Copy link
Contributor

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) {
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Restore const here.

@JsouLiang JsouLiang requested a review from flar June 17, 2022 03:30
Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a DlImageSampling Object

3 participants