Skip to content

Commit

Permalink
[lint] Update local variable names in flow (flutter#36136)
Browse files Browse the repository at this point in the history
This updates local variable names to use clang `lower_case` style in the
flow directory. This is one of several patches to update our variable
names to a consistent style before enabling enforcement in our
clang-tidy rules.

This is a formatting-only change with no intended semantic change.
  • Loading branch information
cbracken authored Sep 14, 2022
1 parent 3c7ed9f commit 179d528
Show file tree
Hide file tree
Showing 15 changed files with 224 additions and 224 deletions.
8 changes: 4 additions & 4 deletions flow/instrumentation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ double Stopwatch::UnitFrameInterval(double raster_time_ms) const {

double Stopwatch::UnitHeight(double raster_time_ms,
double max_unit_interval) const {
double unitHeight = UnitFrameInterval(raster_time_ms) / max_unit_interval;
if (unitHeight > 1.0) {
unitHeight = 1.0;
double unit_height = UnitFrameInterval(raster_time_ms) / max_unit_interval;
if (unit_height > 1.0) {
unit_height = 1.0;
}
return unitHeight;
return unit_height;
}

fml::TimeDelta Stopwatch::MaxDelta() const {
Expand Down
24 changes: 12 additions & 12 deletions flow/layers/clip_path_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,20 @@ TEST_F(ClipPathLayerTest, OpacityInheritance) {

{
// ClipRectLayer(aa with saveLayer) will always be compatible
auto clip_path_saveLayer = std::make_shared<ClipPathLayer>(
auto clip_path_savelayer = std::make_shared<ClipPathLayer>(
layer_clip, Clip::antiAliasWithSaveLayer);
clip_path_saveLayer->Add(mock1);
clip_path_saveLayer->Add(mock2);
clip_path_savelayer->Add(mock1);
clip_path_savelayer->Add(mock2);

// Double check first two children are compatible and non-overlapping
context->subtree_can_inherit_opacity = false;
clip_path_saveLayer->Preroll(context, SkMatrix::I());
clip_path_savelayer->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);

// Now add the overlapping child and test again, should still be compatible
clip_path_saveLayer->Add(mock3);
clip_path_savelayer->Add(mock3);
context->subtree_can_inherit_opacity = false;
clip_path_saveLayer->Preroll(context, SkMatrix::I());
clip_path_savelayer->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);
}

Expand Down Expand Up @@ -350,20 +350,20 @@ TEST_F(ClipPathLayerTest, OpacityInheritance) {

{
// ClipRectLayer(aa with saveLayer) will always be compatible
auto clip_path_saveLayer_bad_child = std::make_shared<ClipPathLayer>(
auto clip_path_savelayer_bad_child = std::make_shared<ClipPathLayer>(
layer_clip, Clip::antiAliasWithSaveLayer);
clip_path_saveLayer_bad_child->Add(mock1);
clip_path_saveLayer_bad_child->Add(mock2);
clip_path_savelayer_bad_child->Add(mock1);
clip_path_savelayer_bad_child->Add(mock2);

// Double check first two children are compatible and non-overlapping
context->subtree_can_inherit_opacity = false;
clip_path_saveLayer_bad_child->Preroll(context, SkMatrix::I());
clip_path_savelayer_bad_child->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);

// Now add the incompatible child and test again, should still be compatible
clip_path_saveLayer_bad_child->Add(mock4);
clip_path_savelayer_bad_child->Add(mock4);
context->subtree_can_inherit_opacity = false;
clip_path_saveLayer_bad_child->Preroll(context, SkMatrix::I());
clip_path_savelayer_bad_child->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);
}
}
Expand Down
24 changes: 12 additions & 12 deletions flow/layers/clip_rect_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,20 +299,20 @@ TEST_F(ClipRectLayerTest, OpacityInheritance) {

{
// ClipRectLayer(aa with saveLayer) will always be compatible
auto clip_rect_saveLayer = std::make_shared<ClipRectLayer>(
auto clip_path_savelayer = std::make_shared<ClipRectLayer>(
clip_rect, Clip::antiAliasWithSaveLayer);
clip_rect_saveLayer->Add(mock1);
clip_rect_saveLayer->Add(mock2);
clip_path_savelayer->Add(mock1);
clip_path_savelayer->Add(mock2);

// Double check first two children are compatible and non-overlapping
context->subtree_can_inherit_opacity = false;
clip_rect_saveLayer->Preroll(context, SkMatrix::I());
clip_path_savelayer->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);

// Now add the overlapping child and test again, should still be compatible
clip_rect_saveLayer->Add(mock3);
clip_path_savelayer->Add(mock3);
context->subtree_can_inherit_opacity = false;
clip_rect_saveLayer->Preroll(context, SkMatrix::I());
clip_path_savelayer->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);
}

Expand Down Expand Up @@ -343,20 +343,20 @@ TEST_F(ClipRectLayerTest, OpacityInheritance) {

{
// ClipRectLayer(aa with saveLayer) will always be compatible
auto clip_rect_saveLayer_bad_child = std::make_shared<ClipRectLayer>(
auto clip_path_savelayer_bad_child = std::make_shared<ClipRectLayer>(
clip_rect, Clip::antiAliasWithSaveLayer);
clip_rect_saveLayer_bad_child->Add(mock1);
clip_rect_saveLayer_bad_child->Add(mock2);
clip_path_savelayer_bad_child->Add(mock1);
clip_path_savelayer_bad_child->Add(mock2);

// Double check first two children are compatible and non-overlapping
context->subtree_can_inherit_opacity = false;
clip_rect_saveLayer_bad_child->Preroll(context, SkMatrix::I());
clip_path_savelayer_bad_child->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);

// Now add the incompatible child and test again, should still be compatible
clip_rect_saveLayer_bad_child->Add(mock4);
clip_path_savelayer_bad_child->Add(mock4);
context->subtree_can_inherit_opacity = false;
clip_rect_saveLayer_bad_child->Preroll(context, SkMatrix::I());
clip_path_savelayer_bad_child->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);
}
}
Expand Down
90 changes: 45 additions & 45 deletions flow/layers/clip_rrect_layer_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,53 +272,53 @@ TEST_F(ClipRRectLayerTest, OpacityInheritance) {
auto path1 = SkPath().addRect({10, 10, 30, 30});
auto mock1 = MockLayer::MakeOpacityCompatible(path1);
SkRect clip_rect = SkRect::MakeWH(500, 500);
SkRRect clip_r_rect = SkRRect::MakeRectXY(clip_rect, 20, 20);
auto clip_r_rect_layer =
std::make_shared<ClipRRectLayer>(clip_r_rect, Clip::hardEdge);
clip_r_rect_layer->Add(mock1);
SkRRect clip_rrect = SkRRect::MakeRectXY(clip_rect, 20, 20);
auto clip_rrect_layer =
std::make_shared<ClipRRectLayer>(clip_rrect, Clip::hardEdge);
clip_rrect_layer->Add(mock1);

// ClipRectLayer will pass through compatibility from a compatible child
PrerollContext* context = preroll_context();
context->subtree_can_inherit_opacity = false;
clip_r_rect_layer->Preroll(context, SkMatrix::I());
clip_rrect_layer->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);

auto path2 = SkPath().addRect({40, 40, 50, 50});
auto mock2 = MockLayer::MakeOpacityCompatible(path2);
clip_r_rect_layer->Add(mock2);
clip_rrect_layer->Add(mock2);

// ClipRectLayer will pass through compatibility from multiple
// non-overlapping compatible children
context->subtree_can_inherit_opacity = false;
clip_r_rect_layer->Preroll(context, SkMatrix::I());
clip_rrect_layer->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);

auto path3 = SkPath().addRect({20, 20, 40, 40});
auto mock3 = MockLayer::MakeOpacityCompatible(path3);
clip_r_rect_layer->Add(mock3);
clip_rrect_layer->Add(mock3);

// ClipRectLayer will not pass through compatibility from multiple
// overlapping children even if they are individually compatible
context->subtree_can_inherit_opacity = false;
clip_r_rect_layer->Preroll(context, SkMatrix::I());
clip_rrect_layer->Preroll(context, SkMatrix::I());
EXPECT_FALSE(context->subtree_can_inherit_opacity);

{
// ClipRectLayer(aa with saveLayer) will always be compatible
auto clip_r_rect_saveLayer = std::make_shared<ClipRRectLayer>(
clip_r_rect, Clip::antiAliasWithSaveLayer);
clip_r_rect_saveLayer->Add(mock1);
clip_r_rect_saveLayer->Add(mock2);
auto clip_rrect_savelayer = std::make_shared<ClipRRectLayer>(
clip_rrect, Clip::antiAliasWithSaveLayer);
clip_rrect_savelayer->Add(mock1);
clip_rrect_savelayer->Add(mock2);

// Double check first two children are compatible and non-overlapping
context->subtree_can_inherit_opacity = false;
clip_r_rect_saveLayer->Preroll(context, SkMatrix::I());
clip_rrect_savelayer->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);

// Now add the overlapping child and test again, should still be compatible
clip_r_rect_saveLayer->Add(mock3);
clip_rrect_savelayer->Add(mock3);
context->subtree_can_inherit_opacity = false;
clip_r_rect_saveLayer->Preroll(context, SkMatrix::I());
clip_rrect_savelayer->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);
}

Expand All @@ -328,41 +328,41 @@ TEST_F(ClipRRectLayerTest, OpacityInheritance) {

{
// ClipRectLayer with incompatible child will not be compatible
auto clip_r_rect_bad_child =
std::make_shared<ClipRRectLayer>(clip_r_rect, Clip::hardEdge);
clip_r_rect_bad_child->Add(mock1);
clip_r_rect_bad_child->Add(mock2);
auto clip_rrect_bad_child =
std::make_shared<ClipRRectLayer>(clip_rrect, Clip::hardEdge);
clip_rrect_bad_child->Add(mock1);
clip_rrect_bad_child->Add(mock2);

// Double check first two children are compatible and non-overlapping
context->subtree_can_inherit_opacity = false;
clip_r_rect_bad_child->Preroll(context, SkMatrix::I());
clip_rrect_bad_child->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);

clip_r_rect_bad_child->Add(mock4);
clip_rrect_bad_child->Add(mock4);

// The third child is non-overlapping, but not compatible so the
// TransformLayer should end up incompatible
context->subtree_can_inherit_opacity = false;
clip_r_rect_bad_child->Preroll(context, SkMatrix::I());
clip_rrect_bad_child->Preroll(context, SkMatrix::I());
EXPECT_FALSE(context->subtree_can_inherit_opacity);
}

{
// ClipRectLayer(aa with saveLayer) will always be compatible
auto clip_r_rect_saveLayer_bad_child = std::make_shared<ClipRRectLayer>(
clip_r_rect, Clip::antiAliasWithSaveLayer);
clip_r_rect_saveLayer_bad_child->Add(mock1);
clip_r_rect_saveLayer_bad_child->Add(mock2);
auto clip_rrect_savelayer_bad_child = std::make_shared<ClipRRectLayer>(
clip_rrect, Clip::antiAliasWithSaveLayer);
clip_rrect_savelayer_bad_child->Add(mock1);
clip_rrect_savelayer_bad_child->Add(mock2);

// Double check first two children are compatible and non-overlapping
context->subtree_can_inherit_opacity = false;
clip_r_rect_saveLayer_bad_child->Preroll(context, SkMatrix::I());
clip_rrect_savelayer_bad_child->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);

// Now add the incompatible child and test again, should still be compatible
clip_r_rect_saveLayer_bad_child->Add(mock4);
clip_rrect_savelayer_bad_child->Add(mock4);
context->subtree_can_inherit_opacity = false;
clip_r_rect_saveLayer_bad_child->Preroll(context, SkMatrix::I());
clip_rrect_savelayer_bad_child->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);
}
}
Expand All @@ -373,9 +373,9 @@ TEST_F(ClipRRectLayerTest, OpacityInheritancePainting) {
auto path2 = SkPath().addRect({40, 40, 50, 50});
auto mock2 = MockLayer::MakeOpacityCompatible(path2);
SkRect clip_rect = SkRect::MakeWH(500, 500);
SkRRect clip_r_rect = SkRRect::MakeRectXY(clip_rect, 20, 20);
SkRRect clip_rrect = SkRRect::MakeRectXY(clip_rect, 20, 20);
auto clip_rect_layer =
std::make_shared<ClipRRectLayer>(clip_r_rect, Clip::antiAlias);
std::make_shared<ClipRRectLayer>(clip_rrect, Clip::antiAlias);
clip_rect_layer->Add(mock1);
clip_rect_layer->Add(mock2);

Expand All @@ -401,7 +401,7 @@ TEST_F(ClipRRectLayerTest, OpacityInheritancePainting) {
expected_builder.translate(offset.fX, offset.fY);
/* ClipRectLayer::Paint() */ {
expected_builder.save();
expected_builder.clipRRect(clip_r_rect, SkClipOp::kIntersect, true);
expected_builder.clipRRect(clip_rrect, SkClipOp::kIntersect, true);
/* child layer1 paint */ {
expected_builder.setColor(opacity_alpha << 24);
expected_builder.saveLayer(&path1.getBounds(), true);
Expand Down Expand Up @@ -438,23 +438,23 @@ TEST_F(ClipRRectLayerTest, OpacityInheritanceSaveLayerPainting) {
auto children_bounds = path1.getBounds();
children_bounds.join(path2.getBounds());
SkRect clip_rect = SkRect::MakeWH(500, 500);
SkRRect clip_r_rect = SkRRect::MakeRectXY(clip_rect, 20, 20);
auto clip_r_rect_layer = std::make_shared<ClipRRectLayer>(
clip_r_rect, Clip::antiAliasWithSaveLayer);
clip_r_rect_layer->Add(mock1);
clip_r_rect_layer->Add(mock2);
SkRRect clip_rrect = SkRRect::MakeRectXY(clip_rect, 20, 20);
auto clip_rrect_layer = std::make_shared<ClipRRectLayer>(
clip_rrect, Clip::antiAliasWithSaveLayer);
clip_rrect_layer->Add(mock1);
clip_rrect_layer->Add(mock2);

// ClipRectLayer will pass through compatibility from multiple
// non-overlapping compatible children
PrerollContext* context = preroll_context();
context->subtree_can_inherit_opacity = false;
clip_r_rect_layer->Preroll(context, SkMatrix::I());
clip_rrect_layer->Preroll(context, SkMatrix::I());
EXPECT_TRUE(context->subtree_can_inherit_opacity);

int opacity_alpha = 0x7F;
SkPoint offset = SkPoint::Make(10, 10);
auto opacity_layer = std::make_shared<OpacityLayer>(opacity_alpha, offset);
opacity_layer->Add(clip_r_rect_layer);
opacity_layer->Add(clip_rrect_layer);
context->subtree_can_inherit_opacity = false;
opacity_layer->Preroll(context, SkMatrix::I());
EXPECT_TRUE(opacity_layer->children_can_accept_opacity());
Expand All @@ -466,7 +466,7 @@ TEST_F(ClipRRectLayerTest, OpacityInheritanceSaveLayerPainting) {
expected_builder.translate(offset.fX, offset.fY);
/* ClipRectLayer::Paint() */ {
expected_builder.save();
expected_builder.clipRRect(clip_r_rect, SkClipOp::kIntersect, true);
expected_builder.clipRRect(clip_rrect, SkClipOp::kIntersect, true);
expected_builder.setColor(opacity_alpha << 24);
expected_builder.saveLayer(&children_bounds, true);
/* child layer1 paint */ {
Expand All @@ -491,8 +491,8 @@ TEST_F(ClipRRectLayerTest, LayerCached) {
SkPaint paint = SkPaint();
auto mock1 = MockLayer::MakeOpacityCompatible(path1);
SkRect clip_rect = SkRect::MakeWH(500, 500);
SkRRect clip_r_rect = SkRRect::MakeRectXY(clip_rect, 20, 20);
auto layer = std::make_shared<ClipRRectLayer>(clip_r_rect,
SkRRect clip_rrect = SkRRect::MakeRectXY(clip_rect, 20, 20);
auto layer = std::make_shared<ClipRRectLayer>(clip_rrect,
Clip::antiAliasWithSaveLayer);
layer->Add(mock1);

Expand Down Expand Up @@ -530,8 +530,8 @@ TEST_F(ClipRRectLayerTest, NoSaveLayerShouldNotCache) {

auto mock1 = MockLayer::MakeOpacityCompatible(path1);
SkRect clip_rect = SkRect::MakeWH(500, 500);
SkRRect clip_r_rect = SkRRect::MakeRectXY(clip_rect, 20, 20);
auto layer = std::make_shared<ClipRRectLayer>(clip_r_rect, Clip::antiAlias);
SkRRect clip_rrect = SkRRect::MakeRectXY(clip_rect, 20, 20);
auto layer = std::make_shared<ClipRRectLayer>(clip_rrect, Clip::antiAlias);
layer->Add(mock1);

auto initial_transform = SkMatrix::Translate(50.0, 25.5);
Expand Down
4 changes: 2 additions & 2 deletions flow/layers/layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Layer::Layer()
Layer::~Layer() = default;

uint64_t Layer::NextUniqueID() {
static std::atomic<uint64_t> nextID(1);
static std::atomic<uint64_t> next_id(1);
uint64_t id;
do {
id = nextID.fetch_add(1);
id = next_id.fetch_add(1);
} while (id == 0); // 0 is reserved for an invalid id.
return id;
}
Expand Down
14 changes: 7 additions & 7 deletions flow/layers/opacity_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,21 @@ void OpacityLayer::Paint(PaintContext& context) const {
return;
}

// Skia may clip the content with saveLayerBounds (although it's not a
// guaranteed clip). So we have to provide a big enough saveLayerBounds. To do
// so, we first remove the offset from paint bounds since it's already in the
// matrix. Then we round out the bounds.
// Skia may clip the content with save_layer_bounds (although it's not a
// guaranteed clip). So we have to provide a big enough save_layer_bounds. To
// do so, we first remove the offset from paint bounds since it's already in
// the matrix. Then we round out the bounds.
//
// Note that the following lines are only accessible when the raster cache is
// not available (e.g., when we're using the software backend in golden
// tests).
SkRect saveLayerBounds;
SkRect save_layer_bounds;
paint_bounds()
.makeOffset(-offset_.fX, -offset_.fY)
.roundOut(&saveLayerBounds);
.roundOut(&save_layer_bounds);

Layer::AutoSaveLayer save_layer =
Layer::AutoSaveLayer::Create(context, saveLayerBounds, &paint);
Layer::AutoSaveLayer::Create(context, save_layer_bounds, &paint);
context.inherited_opacity = SK_Scalar1;
PaintChildren(context);
context.inherited_opacity = inherited_opacity;
Expand Down
Loading

0 comments on commit 179d528

Please sign in to comment.