Skip to content

Commit

Permalink
Avoid implicit conversions to floats in dart:ui (flutter#40098)
Browse files Browse the repository at this point in the history
Avoid implicit conversions to floats in dart:ui
  • Loading branch information
dnfield authored Mar 24, 2023
1 parent 608d5b2 commit 6c2dafe
Show file tree
Hide file tree
Showing 31 changed files with 626 additions and 577 deletions.
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,7 @@ ORIGIN: ../../../flutter/lib/ui/dart_wrapper.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/experiments/scene.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/experiments/setup_hooks.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/experiments/ui.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/floating_point.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/geometry.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/hash_codes.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/hooks.dart + ../../../flutter/LICENSE
Expand Down Expand Up @@ -4186,6 +4187,7 @@ FILE: ../../../flutter/lib/ui/dart_wrapper.h
FILE: ../../../flutter/lib/ui/experiments/scene.dart
FILE: ../../../flutter/lib/ui/experiments/setup_hooks.dart
FILE: ../../../flutter/lib/ui/experiments/ui.dart
FILE: ../../../flutter/lib/ui/floating_point.h
FILE: ../../../flutter/lib/ui/geometry.dart
FILE: ../../../flutter/lib/ui/hash_codes.dart
FILE: ../../../flutter/lib/ui/hooks.dart
Expand Down
2 changes: 1 addition & 1 deletion display_list/dl_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct DlColor {
bool operator!=(uint32_t const& other) const { return argb != other; }

private:
static float toF(uint8_t comp) { return comp * (1.0 / 255); }
static float toF(uint8_t comp) { return comp * (1.0f / 255); }
static uint8_t toC(float fComp) { return round(fComp * 255); }
};

Expand Down
4 changes: 2 additions & 2 deletions display_list/effects/dl_image_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ class DlBlurImageFilter final : public DlImageFilter {

SkRect* map_local_bounds(const SkRect& input_bounds,
SkRect& output_bounds) const override {
output_bounds = input_bounds.makeOutset(sigma_x_ * 3, sigma_y_ * 3);
output_bounds = input_bounds.makeOutset(sigma_x_ * 3.0f, sigma_y_ * 3.0f);
return &output_bounds;
}

SkIRect* map_device_bounds(const SkIRect& input_bounds,
const SkMatrix& ctm,
SkIRect& output_bounds) const override {
return outset_device_bounds(input_bounds, sigma_x_ * 3.0, sigma_y_ * 3.0,
return outset_device_bounds(input_bounds, sigma_x_ * 3.0f, sigma_y_ * 3.0f,
ctm, output_bounds);
}

Expand Down
2 changes: 1 addition & 1 deletion flow/embedded_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Mutator {
return *filter_mutation_;
}
const int& GetAlpha() const { return alpha_; }
float GetAlphaFloat() const { return (alpha_ / 255.0); }
float GetAlphaFloat() const { return (alpha_ / 255.0f); }

bool operator==(const Mutator& other) const {
if (type_ != other.type_) {
Expand Down
2 changes: 1 addition & 1 deletion flow/layers/opacity_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OpacityLayer : public CacheableContainerLayer {
children_can_accept_opacity_ = value;
}

SkScalar opacity() const { return alpha_ * 1.0 / SK_AlphaOPAQUE; }
SkScalar opacity() const { return alpha_ * 1.0f / SK_AlphaOPAQUE; }

private:
SkAlpha alpha_;
Expand Down
Loading

0 comments on commit 6c2dafe

Please sign in to comment.