forked from firka/flutter
Move display list to its own library. (flutter/engine#30398)
This commit is contained in:
@@ -32,18 +32,18 @@ FILE: ../../../flutter/common/settings.cc
|
||||
FILE: ../../../flutter/common/settings.h
|
||||
FILE: ../../../flutter/common/task_runners.cc
|
||||
FILE: ../../../flutter/common/task_runners.h
|
||||
FILE: ../../../flutter/display_list/display_list.cc
|
||||
FILE: ../../../flutter/display_list/display_list.h
|
||||
FILE: ../../../flutter/display_list/display_list_canvas.cc
|
||||
FILE: ../../../flutter/display_list/display_list_canvas.h
|
||||
FILE: ../../../flutter/display_list/display_list_canvas_unittests.cc
|
||||
FILE: ../../../flutter/display_list/display_list_unittests.cc
|
||||
FILE: ../../../flutter/display_list/display_list_utils.cc
|
||||
FILE: ../../../flutter/display_list/display_list_utils.h
|
||||
FILE: ../../../flutter/flow/compositor_context.cc
|
||||
FILE: ../../../flutter/flow/compositor_context.h
|
||||
FILE: ../../../flutter/flow/diff_context.cc
|
||||
FILE: ../../../flutter/flow/diff_context.h
|
||||
FILE: ../../../flutter/flow/display_list.cc
|
||||
FILE: ../../../flutter/flow/display_list.h
|
||||
FILE: ../../../flutter/flow/display_list_canvas.cc
|
||||
FILE: ../../../flutter/flow/display_list_canvas.h
|
||||
FILE: ../../../flutter/flow/display_list_canvas_unittests.cc
|
||||
FILE: ../../../flutter/flow/display_list_unittests.cc
|
||||
FILE: ../../../flutter/flow/display_list_utils.cc
|
||||
FILE: ../../../flutter/flow/display_list_utils.h
|
||||
FILE: ../../../flutter/flow/embedded_view_params_unittests.cc
|
||||
FILE: ../../../flutter/flow/embedded_views.cc
|
||||
FILE: ../../../flutter/flow/embedded_views.h
|
||||
|
||||
37
engine/src/flutter/display_list/BUILD.gn
Normal file
37
engine/src/flutter/display_list/BUILD.gn
Normal file
@@ -0,0 +1,37 @@
|
||||
# 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.
|
||||
|
||||
source_set("display_list") {
|
||||
sources = [
|
||||
"display_list.cc",
|
||||
"display_list.h",
|
||||
"display_list_canvas.cc",
|
||||
"display_list_canvas.h",
|
||||
"display_list_utils.cc",
|
||||
"display_list_utils.h",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
"//flutter/fml",
|
||||
"//third_party/skia",
|
||||
]
|
||||
}
|
||||
|
||||
# Instead of creating a new test harness for display lists, the flow_unittests
|
||||
# harness includes these in its own.
|
||||
source_set("unittests") {
|
||||
testonly = true
|
||||
|
||||
sources = [
|
||||
"display_list_canvas_unittests.cc",
|
||||
"display_list_unittests.cc",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//flutter/testing:testing_lib",
|
||||
"//third_party/skia",
|
||||
]
|
||||
|
||||
public_deps = [ ":display_list" ]
|
||||
}
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "flutter/flow/display_list.h"
|
||||
#include "flutter/flow/display_list_canvas.h"
|
||||
#include "flutter/flow/display_list_utils.h"
|
||||
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/display_list/display_list_canvas.h"
|
||||
#include "flutter/display_list/display_list_utils.h"
|
||||
#include "third_party/skia/include/core/SkPath.h"
|
||||
#include "third_party/skia/include/core/SkRSXform.h"
|
||||
#include "third_party/skia/include/core/SkTextBlob.h"
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "third_party/skia/include/core/SkBlender.h"
|
||||
#include "third_party/skia/include/core/SkBlurTypes.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
@@ -19,8 +20,6 @@
|
||||
#include "third_party/skia/include/core/SkShader.h"
|
||||
#include "third_party/skia/include/core/SkVertices.h"
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
|
||||
// The Flutter DisplayList mechanism encapsulates a persistent sequence of
|
||||
// rendering operations.
|
||||
//
|
||||
@@ -2,15 +2,18 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/flow/display_list_canvas.h"
|
||||
|
||||
#include "flutter/flow/layers/physical_shape_layer.h"
|
||||
#include "flutter/display_list/display_list_canvas.h"
|
||||
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "third_party/skia/include/core/SkMaskFilter.h"
|
||||
#include "third_party/skia/include/core/SkTextBlob.h"
|
||||
#include "third_party/skia/include/utils/SkShadowUtils.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
const SkScalar kLightHeight = 600;
|
||||
const SkScalar kLightRadius = 800;
|
||||
|
||||
const SkPaint* DisplayListCanvasDispatcher::safe_paint(bool use_attributes) {
|
||||
if (use_attributes) {
|
||||
// The accumulated SkPaint object will already have incorporated
|
||||
@@ -217,13 +220,49 @@ void DisplayListCanvasDispatcher::drawTextBlob(const sk_sp<SkTextBlob> blob,
|
||||
SkScalar y) {
|
||||
canvas_->drawTextBlob(blob, x, y, paint());
|
||||
}
|
||||
|
||||
SkRect DisplayListCanvasDispatcher::ComputeShadowBounds(const SkPath& path,
|
||||
float elevation,
|
||||
SkScalar dpr,
|
||||
const SkMatrix& ctm) {
|
||||
SkRect shadow_bounds(path.getBounds());
|
||||
SkShadowUtils::GetLocalBounds(
|
||||
ctm, path, SkPoint3::Make(0, 0, dpr * elevation),
|
||||
SkPoint3::Make(0, -1, 1), kLightRadius / kLightHeight,
|
||||
SkShadowFlags::kDirectionalLight_ShadowFlag, &shadow_bounds);
|
||||
return shadow_bounds;
|
||||
}
|
||||
|
||||
void DisplayListCanvasDispatcher::DrawShadow(SkCanvas* canvas,
|
||||
const SkPath& path,
|
||||
SkColor color,
|
||||
float elevation,
|
||||
bool transparentOccluder,
|
||||
SkScalar dpr) {
|
||||
const SkScalar kAmbientAlpha = 0.039f;
|
||||
const SkScalar kSpotAlpha = 0.25f;
|
||||
|
||||
uint32_t flags = transparentOccluder
|
||||
? SkShadowFlags::kTransparentOccluder_ShadowFlag
|
||||
: SkShadowFlags::kNone_ShadowFlag;
|
||||
flags |= SkShadowFlags::kDirectionalLight_ShadowFlag;
|
||||
SkColor inAmbient = SkColorSetA(color, kAmbientAlpha * SkColorGetA(color));
|
||||
SkColor inSpot = SkColorSetA(color, kSpotAlpha * SkColorGetA(color));
|
||||
SkColor ambientColor, spotColor;
|
||||
SkShadowUtils::ComputeTonalColors(inAmbient, inSpot, &ambientColor,
|
||||
&spotColor);
|
||||
SkShadowUtils::DrawShadow(canvas, path, SkPoint3::Make(0, 0, dpr * elevation),
|
||||
SkPoint3::Make(0, -1, 1),
|
||||
kLightRadius / kLightHeight, ambientColor,
|
||||
spotColor, flags);
|
||||
}
|
||||
|
||||
void DisplayListCanvasDispatcher::drawShadow(const SkPath& path,
|
||||
const SkColor color,
|
||||
const SkScalar elevation,
|
||||
bool transparent_occluder,
|
||||
SkScalar dpr) {
|
||||
flutter::PhysicalShapeLayer::DrawShadow(canvas_, path, color, elevation,
|
||||
transparent_occluder, dpr);
|
||||
DrawShadow(canvas_, path, color, elevation, transparent_occluder, dpr);
|
||||
}
|
||||
|
||||
DisplayListCanvasRecorder::DisplayListCanvasRecorder(const SkRect& bounds)
|
||||
@@ -5,10 +5,9 @@
|
||||
#ifndef FLUTTER_FLOW_DISPLAY_LIST_CANVAS_H_
|
||||
#define FLUTTER_FLOW_DISPLAY_LIST_CANVAS_H_
|
||||
|
||||
#include "flutter/flow/display_list.h"
|
||||
#include "flutter/flow/display_list_utils.h"
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/display_list/display_list_utils.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkCanvasVirtualEnforcer.h"
|
||||
#include "third_party/skia/include/utils/SkNoDrawCanvas.h"
|
||||
|
||||
@@ -117,6 +116,18 @@ class DisplayListCanvasDispatcher : public virtual Dispatcher,
|
||||
bool transparent_occluder,
|
||||
SkScalar dpr) override;
|
||||
|
||||
static SkRect ComputeShadowBounds(const SkPath& path,
|
||||
float elevation,
|
||||
SkScalar dpr,
|
||||
const SkMatrix& ctm);
|
||||
|
||||
static void DrawShadow(SkCanvas* canvas,
|
||||
const SkPath& path,
|
||||
SkColor color,
|
||||
float elevation,
|
||||
bool transparentOccluder,
|
||||
SkScalar dpr);
|
||||
|
||||
private:
|
||||
SkCanvas* canvas_;
|
||||
SkPaint temp_paint_;
|
||||
@@ -2,9 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/flow/display_list_canvas.h"
|
||||
#include "flutter/flow/layers/physical_shape_layer.h"
|
||||
|
||||
#include "flutter/display_list/display_list_canvas.h"
|
||||
#include "flutter/fml/math.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkImageInfo.h"
|
||||
#include "third_party/skia/include/core/SkPath.h"
|
||||
@@ -20,10 +20,6 @@
|
||||
#include "third_party/skia/include/effects/SkGradientShader.h"
|
||||
#include "third_party/skia/include/effects/SkImageFilters.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
@@ -1543,8 +1539,10 @@ class CanvasCompareTester {
|
||||
0, 1, 0, RenderCenterY, //
|
||||
0, 0, 1, 0, //
|
||||
0, 0, .001, 1);
|
||||
m44.preConcat(SkM44::Rotate({1, 0, 0}, M_PI / 60)); // 3 degrees around X
|
||||
m44.preConcat(SkM44::Rotate({0, 1, 0}, M_PI / 45)); // 4 degrees around Y
|
||||
m44.preConcat(
|
||||
SkM44::Rotate({1, 0, 0}, math::kPi / 60)); // 3 degrees around X
|
||||
m44.preConcat(
|
||||
SkM44::Rotate({0, 1, 0}, math::kPi / 45)); // 4 degrees around Y
|
||||
m44.preTranslate(-RenderCenterX, -RenderCenterY);
|
||||
RenderWith(
|
||||
testP, env, skewed_tolerance,
|
||||
@@ -3021,8 +3019,8 @@ TEST_F(DisplayListCanvas, DrawShadow) {
|
||||
CanvasCompareTester::RenderAll( //
|
||||
TestParameters(
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) { //
|
||||
PhysicalShapeLayer::DrawShadow(canvas, path, color, elevation,
|
||||
false, 1.0);
|
||||
DisplayListCanvasDispatcher::DrawShadow(canvas, path, color,
|
||||
elevation, false, 1.0);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) { //
|
||||
builder.drawShadow(path, color, elevation, false, 1.0);
|
||||
@@ -3048,8 +3046,8 @@ TEST_F(DisplayListCanvas, DrawShadowTransparentOccluder) {
|
||||
CanvasCompareTester::RenderAll( //
|
||||
TestParameters(
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) { //
|
||||
PhysicalShapeLayer::DrawShadow(canvas, path, color, elevation, true,
|
||||
1.0);
|
||||
DisplayListCanvasDispatcher::DrawShadow(canvas, path, color,
|
||||
elevation, true, 1.0);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) { //
|
||||
builder.drawShadow(path, color, elevation, true, 1.0);
|
||||
@@ -3075,8 +3073,8 @@ TEST_F(DisplayListCanvas, DrawShadowDpr) {
|
||||
CanvasCompareTester::RenderAll( //
|
||||
TestParameters(
|
||||
[=](SkCanvas* canvas, const SkPaint& paint) { //
|
||||
PhysicalShapeLayer::DrawShadow(canvas, path, color, elevation,
|
||||
false, 1.5);
|
||||
DisplayListCanvasDispatcher::DrawShadow(canvas, path, color,
|
||||
elevation, false, 1.5);
|
||||
},
|
||||
[=](DisplayListBuilder& builder) { //
|
||||
builder.drawShadow(path, color, elevation, false, 1.5);
|
||||
@@ -2,8 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/flow/display_list_canvas.h"
|
||||
|
||||
#include "flutter/display_list/display_list_canvas.h"
|
||||
#include "flutter/fml/math.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkImageInfo.h"
|
||||
#include "third_party/skia/include/core/SkPath.h"
|
||||
@@ -19,10 +20,6 @@
|
||||
#include "third_party/skia/include/effects/SkGradientShader.h"
|
||||
#include "third_party/skia/include/effects/SkImageFilters.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
@@ -1449,7 +1446,7 @@ TEST(DisplayList, SingleOpsMightSupportGroupOpacityWithOrWithoutBlendMode) {
|
||||
SkRRect::MakeRectXY({2, 2, 8, 8}, 2, 2)););
|
||||
RUN_TESTS(builder.drawPath(
|
||||
SkPath().addOval({0, 0, 10, 10}).addOval({5, 5, 15, 15})););
|
||||
RUN_TESTS(builder.drawArc({0, 0, 10, 10}, 0, M_PI, true););
|
||||
RUN_TESTS(builder.drawArc({0, 0, 10, 10}, 0, math::kPi, true););
|
||||
RUN_TESTS2(builder.drawPoints(SkCanvas::kPoints_PointMode, TestPointCount,
|
||||
TestPoints);
|
||||
, false);
|
||||
@@ -2,13 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/display_list/display_list_utils.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <type_traits>
|
||||
|
||||
#include "flutter/flow/display_list_utils.h"
|
||||
#include "flutter/flow/layers/physical_shape_layer.h"
|
||||
#include "flutter/display_list/display_list_canvas.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkMaskFilter.h"
|
||||
#include "third_party/skia/include/core/SkPath.h"
|
||||
#include "third_party/skia/include/core/SkRSXform.h"
|
||||
@@ -518,8 +518,8 @@ void DisplayListBoundsCalculator::drawShadow(const SkPath& path,
|
||||
const SkScalar elevation,
|
||||
bool transparent_occluder,
|
||||
SkScalar dpr) {
|
||||
SkRect shadow_bounds =
|
||||
PhysicalShapeLayer::ComputeShadowBounds(path, elevation, dpr, matrix());
|
||||
SkRect shadow_bounds = DisplayListCanvasDispatcher::ComputeShadowBounds(
|
||||
path, elevation, dpr, matrix());
|
||||
AccumulateRect(shadow_bounds, kDrawShadowFlags);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "flutter/flow/display_list.h"
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkMaskFilter.h"
|
||||
|
||||
// This file contains various utility classes to ease implementing
|
||||
@@ -12,12 +12,6 @@ source_set("flow") {
|
||||
"compositor_context.h",
|
||||
"diff_context.cc",
|
||||
"diff_context.h",
|
||||
"display_list.cc",
|
||||
"display_list.h",
|
||||
"display_list_canvas.cc",
|
||||
"display_list_canvas.h",
|
||||
"display_list_utils.cc",
|
||||
"display_list_utils.h",
|
||||
"embedded_views.cc",
|
||||
"embedded_views.h",
|
||||
"frame_timings.cc",
|
||||
@@ -89,6 +83,8 @@ source_set("flow") {
|
||||
"//flutter/fml",
|
||||
"//third_party/skia",
|
||||
]
|
||||
|
||||
public_deps = [ "//flutter/display_list" ]
|
||||
}
|
||||
|
||||
if (enable_unittests) {
|
||||
@@ -125,6 +121,7 @@ if (enable_unittests) {
|
||||
deps = [
|
||||
":flow",
|
||||
"//flutter/common/graphics",
|
||||
"//flutter/display_list:unittests",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -132,8 +129,6 @@ if (enable_unittests) {
|
||||
testonly = true
|
||||
|
||||
sources = [
|
||||
"display_list_canvas_unittests.cc",
|
||||
"display_list_unittests.cc",
|
||||
"embedded_view_params_unittests.cc",
|
||||
"flow_run_all_unittests.cc",
|
||||
"flow_test_utils.cc",
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "flutter/flow/layers/clip_rrect_layer.h"
|
||||
#include "flutter/flow/layers/physical_shape_layer.h"
|
||||
|
||||
#include "flutter/display_list/display_list_canvas.h"
|
||||
#include "flutter/flow/testing/layer_test.h"
|
||||
#include "flutter/flow/testing/mock_layer.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
@@ -294,7 +295,7 @@ TEST_F(CheckerBoardLayerTest, PhysicalSaveLayerNotCheckBoard) {
|
||||
// The Fuchsia system compositor handles all elevated PhysicalShapeLayers and
|
||||
// their shadows , so we do not do any painting there.
|
||||
EXPECT_EQ(layer->paint_bounds(),
|
||||
PhysicalShapeLayer::ComputeShadowBounds(
|
||||
DisplayListCanvasDispatcher::ComputeShadowBounds(
|
||||
layer_path, initial_elevation, 1.0f, SkMatrix()));
|
||||
EXPECT_TRUE(layer->needs_painting(paint_context()));
|
||||
EXPECT_EQ(layer->elevation(), initial_elevation);
|
||||
@@ -333,7 +334,7 @@ TEST_F(CheckerBoardLayerTest, PhysicalSaveLayerCheckBoard) {
|
||||
// The Fuchsia system compositor handles all elevated PhysicalShapeLayers and
|
||||
// their shadows , so we do not do any painting there.
|
||||
EXPECT_EQ(layer->paint_bounds(),
|
||||
PhysicalShapeLayer::ComputeShadowBounds(
|
||||
DisplayListCanvasDispatcher::ComputeShadowBounds(
|
||||
layer_path, initial_elevation, 1.0f, SkMatrix()));
|
||||
EXPECT_TRUE(layer->needs_painting(paint_context()));
|
||||
EXPECT_EQ(layer->elevation(), initial_elevation);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "flutter/flow/layers/display_list_layer.h"
|
||||
|
||||
#include "flutter/flow/display_list_canvas.h"
|
||||
#include "flutter/display_list/display_list_canvas.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef FLUTTER_FLOW_LAYERS_DISPLAY_LIST_LAYER_H_
|
||||
#define FLUTTER_FLOW_LAYERS_DISPLAY_LIST_LAYER_H_
|
||||
|
||||
#include "flutter/flow/display_list.h"
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/flow/layers/layer.h"
|
||||
#include "flutter/flow/skia_gpu_object.h"
|
||||
|
||||
|
||||
@@ -4,14 +4,11 @@
|
||||
|
||||
#include "flutter/flow/layers/physical_shape_layer.h"
|
||||
|
||||
#include "flutter/display_list/display_list_canvas.h"
|
||||
#include "flutter/flow/paint_utils.h"
|
||||
#include "third_party/skia/include/utils/SkShadowUtils.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
const SkScalar kLightHeight = 600;
|
||||
const SkScalar kLightRadius = 800;
|
||||
|
||||
PhysicalShapeLayer::PhysicalShapeLayer(SkColor color,
|
||||
SkColor shadow_color,
|
||||
float elevation,
|
||||
@@ -39,9 +36,9 @@ void PhysicalShapeLayer::Diff(DiffContext* context, const Layer* old_layer) {
|
||||
if (elevation_ == 0) {
|
||||
bounds = path_.getBounds();
|
||||
} else {
|
||||
bounds = ComputeShadowBounds(path_, elevation_,
|
||||
context->frame_device_pixel_ratio(),
|
||||
context->GetTransform());
|
||||
bounds = DisplayListCanvasDispatcher::ComputeShadowBounds(
|
||||
path_, elevation_, context->frame_device_pixel_ratio(),
|
||||
context->GetTransform());
|
||||
}
|
||||
|
||||
context->AddLayerBounds(bounds);
|
||||
@@ -68,7 +65,7 @@ void PhysicalShapeLayer::Preroll(PrerollContext* context,
|
||||
// We will draw the shadow in Paint(), so add some margin to the paint
|
||||
// bounds to leave space for the shadow. We fill this whole region and clip
|
||||
// children to it so we don't need to join the child paint bounds.
|
||||
set_paint_bounds(ComputeShadowBounds(
|
||||
set_paint_bounds(DisplayListCanvasDispatcher::ComputeShadowBounds(
|
||||
path_, elevation_, context->frame_device_pixel_ratio, matrix));
|
||||
}
|
||||
}
|
||||
@@ -78,8 +75,9 @@ void PhysicalShapeLayer::Paint(PaintContext& context) const {
|
||||
FML_DCHECK(needs_painting(context));
|
||||
|
||||
if (elevation_ != 0) {
|
||||
DrawShadow(context.leaf_nodes_canvas, path_, shadow_color_, elevation_,
|
||||
SkColorGetA(color_) != 0xff, context.frame_device_pixel_ratio);
|
||||
DisplayListCanvasDispatcher::DrawShadow(
|
||||
context.leaf_nodes_canvas, path_, shadow_color_, elevation_,
|
||||
SkColorGetA(color_) != 0xff, context.frame_device_pixel_ratio);
|
||||
}
|
||||
|
||||
// Call drawPath without clip if possible for better performance.
|
||||
@@ -126,40 +124,4 @@ void PhysicalShapeLayer::Paint(PaintContext& context) const {
|
||||
}
|
||||
}
|
||||
|
||||
SkRect PhysicalShapeLayer::ComputeShadowBounds(const SkPath& path,
|
||||
float elevation,
|
||||
SkScalar dpr,
|
||||
const SkMatrix& ctm) {
|
||||
SkRect shadow_bounds(path.getBounds());
|
||||
SkShadowUtils::GetLocalBounds(
|
||||
ctm, path, SkPoint3::Make(0, 0, dpr * elevation),
|
||||
SkPoint3::Make(0, -1, 1), kLightRadius / kLightHeight,
|
||||
SkShadowFlags::kDirectionalLight_ShadowFlag, &shadow_bounds);
|
||||
return shadow_bounds;
|
||||
}
|
||||
|
||||
void PhysicalShapeLayer::DrawShadow(SkCanvas* canvas,
|
||||
const SkPath& path,
|
||||
SkColor color,
|
||||
float elevation,
|
||||
bool transparentOccluder,
|
||||
SkScalar dpr) {
|
||||
const SkScalar kAmbientAlpha = 0.039f;
|
||||
const SkScalar kSpotAlpha = 0.25f;
|
||||
|
||||
uint32_t flags = transparentOccluder
|
||||
? SkShadowFlags::kTransparentOccluder_ShadowFlag
|
||||
: SkShadowFlags::kNone_ShadowFlag;
|
||||
flags |= SkShadowFlags::kDirectionalLight_ShadowFlag;
|
||||
SkColor inAmbient = SkColorSetA(color, kAmbientAlpha * SkColorGetA(color));
|
||||
SkColor inSpot = SkColorSetA(color, kSpotAlpha * SkColorGetA(color));
|
||||
SkColor ambientColor, spotColor;
|
||||
SkShadowUtils::ComputeTonalColors(inAmbient, inSpot, &ambientColor,
|
||||
&spotColor);
|
||||
SkShadowUtils::DrawShadow(canvas, path, SkPoint3::Make(0, 0, dpr * elevation),
|
||||
SkPoint3::Make(0, -1, 1),
|
||||
kLightRadius / kLightHeight, ambientColor,
|
||||
spotColor, flags);
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@@ -17,17 +17,6 @@ class PhysicalShapeLayer : public ContainerLayer {
|
||||
const SkPath& path,
|
||||
Clip clip_behavior);
|
||||
|
||||
static SkRect ComputeShadowBounds(const SkPath& path,
|
||||
float elevation,
|
||||
SkScalar dpr,
|
||||
const SkMatrix& ctm);
|
||||
static void DrawShadow(SkCanvas* canvas,
|
||||
const SkPath& path,
|
||||
SkColor color,
|
||||
float elevation,
|
||||
bool transparentOccluder,
|
||||
SkScalar dpr);
|
||||
|
||||
void Diff(DiffContext* context, const Layer* old_layer) override;
|
||||
|
||||
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "flutter/flow/layers/physical_shape_layer.h"
|
||||
|
||||
#include "flutter/display_list/display_list_canvas.h"
|
||||
#include "flutter/flow/testing/diff_context_test.h"
|
||||
#include "flutter/flow/testing/layer_test.h"
|
||||
#include "flutter/flow/testing/mock_layer.h"
|
||||
@@ -125,7 +126,7 @@ TEST_F(PhysicalShapeLayerTest, ElevationSimple) {
|
||||
// The Fuchsia system compositor handles all elevated PhysicalShapeLayers and
|
||||
// their shadows , so we do not do any painting there.
|
||||
EXPECT_EQ(layer->paint_bounds(),
|
||||
PhysicalShapeLayer::ComputeShadowBounds(
|
||||
DisplayListCanvasDispatcher::ComputeShadowBounds(
|
||||
layer_path, initial_elevation, 1.0f, SkMatrix()));
|
||||
EXPECT_TRUE(layer->needs_painting(paint_context()));
|
||||
EXPECT_EQ(layer->elevation(), initial_elevation);
|
||||
@@ -174,7 +175,7 @@ TEST_F(PhysicalShapeLayerTest, ElevationComplex) {
|
||||
// PhysicalShapeLayers and their shadows , so we do not do any painting
|
||||
// there.
|
||||
EXPECT_EQ(layers[i]->paint_bounds(),
|
||||
(PhysicalShapeLayer::ComputeShadowBounds(
|
||||
(DisplayListCanvasDispatcher::ComputeShadowBounds(
|
||||
layer_path, initial_elevations[i], 1.0f /* pixel_ratio */,
|
||||
SkMatrix())));
|
||||
EXPECT_TRUE(layers[i]->needs_painting(paint_context()));
|
||||
@@ -210,14 +211,14 @@ TEST_F(PhysicalShapeLayerTest, ShadowNotDependsCtm) {
|
||||
path.addRect(0, 0, 8, 8).close();
|
||||
|
||||
for (SkScalar elevation : elevations) {
|
||||
SkRect baseline_bounds = PhysicalShapeLayer::ComputeShadowBounds(
|
||||
SkRect baseline_bounds = DisplayListCanvasDispatcher::ComputeShadowBounds(
|
||||
path, elevation, 1.0f, SkMatrix());
|
||||
for (SkScalar scale : scales) {
|
||||
for (SkScalar translateX : translates) {
|
||||
for (SkScalar translateY : translates) {
|
||||
SkMatrix ctm;
|
||||
ctm.setScaleTranslate(scale, scale, translateX, translateY);
|
||||
SkRect bounds = PhysicalShapeLayer::ComputeShadowBounds(
|
||||
SkRect bounds = DisplayListCanvasDispatcher::ComputeShadowBounds(
|
||||
path, elevation, scale, ctm);
|
||||
EXPECT_FLOAT_EQ(bounds.fLeft, baseline_bounds.fLeft);
|
||||
EXPECT_FLOAT_EQ(bounds.fTop, baseline_bounds.fTop);
|
||||
@@ -274,14 +275,14 @@ TEST_F(PhysicalShapeLayerTest, ShadowNotDependsPathSize) {
|
||||
[=](SkCanvas* canvas) {
|
||||
SkPath path;
|
||||
path.addRect(test_case[0]).close();
|
||||
PhysicalShapeLayer::DrawShadow(canvas, path, SK_ColorBLACK,
|
||||
1.0f, false, 1.0f);
|
||||
DisplayListCanvasDispatcher::DrawShadow(
|
||||
canvas, path, SK_ColorBLACK, 1.0f, false, 1.0f);
|
||||
},
|
||||
[=](SkCanvas* canvas) {
|
||||
SkPath path;
|
||||
path.addRect(test_case[1]).close();
|
||||
PhysicalShapeLayer::DrawShadow(canvas, path, SK_ColorBLACK,
|
||||
1.0f, false, 1.0f);
|
||||
DisplayListCanvasDispatcher::DrawShadow(
|
||||
canvas, path, SK_ColorBLACK, 1.0f, false, 1.0f);
|
||||
},
|
||||
SkSize::Make(100, 100)),
|
||||
0);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "flutter/flow/display_list.h"
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/flow/raster_cache_key.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/memory/weak_ptr.h"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "flutter/flow/display_list.h"
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/flow/raster_cache.h"
|
||||
|
||||
#include "flutter/flow/testing/mock_raster_cache.h"
|
||||
|
||||
@@ -138,6 +138,7 @@ source_set("ui") {
|
||||
deps = [
|
||||
"//flutter/assets",
|
||||
"//flutter/common",
|
||||
"//flutter/display_list",
|
||||
"//flutter/fml",
|
||||
"//flutter/runtime:test_font",
|
||||
"//flutter/third_party/tonic",
|
||||
|
||||
@@ -661,7 +661,7 @@ void Canvas::drawShadow(const CanvasPath* path,
|
||||
builder()->drawShadow(path->path(), color, elevation, transparentOccluder,
|
||||
dpr);
|
||||
} else if (canvas_) {
|
||||
flutter::PhysicalShapeLayer::DrawShadow(
|
||||
DisplayListCanvasDispatcher::DrawShadow(
|
||||
canvas_, path->path(), color, elevation, transparentOccluder, dpr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
#ifndef FLUTTER_LIB_UI_PAINTING_PAINT_H_
|
||||
#define FLUTTER_LIB_UI_PAINTING_PAINT_H_
|
||||
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "third_party/skia/include/core/SkPaint.h"
|
||||
#include "third_party/tonic/converter/dart_converter.h"
|
||||
|
||||
#include "flow/display_list.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
class Paint {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef FLUTTER_LIB_UI_PAINTING_PICTURE_H_
|
||||
#define FLUTTER_LIB_UI_PAINTING_PICTURE_H_
|
||||
|
||||
#include "flutter/flow/display_list.h"
|
||||
#include "flutter/display_list/display_list.h"
|
||||
#include "flutter/flow/skia_gpu_object.h"
|
||||
#include "flutter/lib/ui/dart_wrapper.h"
|
||||
#include "flutter/lib/ui/painting/image.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_
|
||||
#define FLUTTER_LIB_UI_PAINTING_PICTURE_RECORDER_H_
|
||||
|
||||
#include "flutter/flow/display_list_canvas.h"
|
||||
#include "flutter/display_list/display_list_canvas.h"
|
||||
#include "flutter/lib/ui/dart_wrapper.h"
|
||||
#include "third_party/skia/include/core/SkPictureRecorder.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user