未验证 提交 edef8bb8 编写于 作者: L liyuqian 提交者: GitHub

Reland elevation test (#8633)

Reland "Add a unit test for PhysicalShapeLayer (#8616)"

This reverts commit 91b71070.

The only change is the namespace.
上级 4b9966f5
......@@ -89,6 +89,7 @@ FILE: ../../../flutter/flow/layers/performance_overlay_layer.h
FILE: ../../../flutter/flow/layers/performance_overlay_layer_unittests.cc
FILE: ../../../flutter/flow/layers/physical_shape_layer.cc
FILE: ../../../flutter/flow/layers/physical_shape_layer.h
FILE: ../../../flutter/flow/layers/physical_shape_layer_unittests.cc
FILE: ../../../flutter/flow/layers/picture_layer.cc
FILE: ../../../flutter/flow/layers/picture_layer.h
FILE: ../../../flutter/flow/layers/platform_view_layer.cc
......
......@@ -98,6 +98,7 @@ executable("flow_unittests") {
"flow_test_utils.cc",
"flow_test_utils.h",
"layers/performance_overlay_layer_unittests.cc",
"layers/physical_shape_layer_unittests.cc",
"matrix_decomposition_unittests.cc",
"raster_cache_unittests.cc",
]
......
......@@ -27,8 +27,7 @@ void ContainerLayer::PrerollChildren(PrerollContext* context,
const SkMatrix& child_matrix,
SkRect* child_paint_bounds) {
for (auto& layer : layers_) {
PrerollContext child_context = *context;
layer->Preroll(&child_context, child_matrix);
layer->Preroll(context, child_matrix);
if (layer->needs_system_composite()) {
set_needs_system_composite(true);
......
......@@ -47,6 +47,7 @@ void PhysicalShapeLayer::Preroll(PrerollContext* context,
total_elevation_ = context->total_elevation;
SkRect child_paint_bounds;
PrerollChildren(context, matrix, &child_paint_bounds);
context->total_elevation -= elevation_;
if (elevation_ == 0) {
set_paint_bounds(path_.getBounds());
......
......@@ -52,6 +52,8 @@ class PhysicalShapeLayer : public ContainerLayer {
bool isRect_;
SkRRect frameRRect_;
Clip clip_behavior_;
friend class PhysicalShapeLayer_TotalElevation_Test;
};
} // namespace flutter
......
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/flow/layers/physical_shape_layer.h"
#include "gtest/gtest.h"
namespace flutter {
TEST(PhysicalShapeLayer, TotalElevation) {
std::shared_ptr<PhysicalShapeLayer> layers[4];
for (int i = 0; i < 4; i += 1) {
layers[i] = std::make_shared<PhysicalShapeLayer>(Clip::none);
layers[i]->set_elevation((float)(i + 1));
}
layers[0]->Add(layers[1]);
layers[0]->Add(layers[2]);
layers[2]->Add(layers[3]);
const Stopwatch unused_stopwatch;
TextureRegistry unused_texture_registry;
PrerollContext preroll_context{
nullptr, // raster_cache (don't consult the cache)
nullptr, // gr_context (used for the raster cache)
nullptr, // external view embedder
nullptr, // SkColorSpace* dst_color_space
kGiantRect, // SkRect cull_rect
unused_stopwatch, // frame time (dont care)
unused_stopwatch, // engine time (dont care)
unused_texture_registry, // texture registry (not supported)
false, // checkerboard_offscreen_layers
0.0f, // total elevation
};
SkMatrix identity;
identity.setIdentity();
layers[0]->Preroll(&preroll_context, identity);
// It should look like this:
// layers[0] +1.0f
// | \
// | \
// | \
// | layers[2] +3.0f
// | |
// | layers[3] +4.0f
// |
// |
// layers[1] + 2.0f
EXPECT_EQ(layers[0]->total_elevation_, 1.0f);
EXPECT_EQ(layers[1]->total_elevation_, 3.0f);
EXPECT_EQ(layers[2]->total_elevation_, 4.0f);
EXPECT_EQ(layers[3]->total_elevation_, 8.0f);
}
} // namespace flutter
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册