[Impeller] ToColor should produce a DlColor, not SkColor. (flutter/engine#43987)
Closes https://github.com/flutter/flutter/issues/124455.
This commit is contained in:
@@ -129,6 +129,7 @@
|
||||
../../../flutter/impeller/compiler/compiler_unittests.cc
|
||||
../../../flutter/impeller/compiler/switches_unittests.cc
|
||||
../../../flutter/impeller/display_list/dl_unittests.cc
|
||||
../../../flutter/impeller/display_list/skia_conversions_unittests.cc
|
||||
../../../flutter/impeller/docs
|
||||
../../../flutter/impeller/entity/contents/filters/inputs/filter_input_unittests.cc
|
||||
../../../flutter/impeller/entity/entity_unittests.cc
|
||||
|
||||
@@ -77,6 +77,7 @@ impeller_component("impeller_unittests") {
|
||||
"base:base_unittests",
|
||||
"blobcat:blobcat_unittests",
|
||||
"compiler:compiler_unittests",
|
||||
"display_list:skia_conversions_unittests",
|
||||
"geometry:geometry_unittests",
|
||||
"runtime_stage:runtime_stage_unittests",
|
||||
"scene/importer:importer_unittests",
|
||||
|
||||
@@ -13,6 +13,7 @@ impeller_component("skia_conversions") {
|
||||
public_deps = [
|
||||
"../core",
|
||||
"../geometry",
|
||||
"//flutter/display_list",
|
||||
"//flutter/fml",
|
||||
"//third_party/skia",
|
||||
"//third_party/skia/modules/skparagraph",
|
||||
@@ -68,3 +69,14 @@ impeller_component("display_list_unittests") {
|
||||
defines += [ "IMPELLER_ENABLE_3D" ]
|
||||
}
|
||||
}
|
||||
|
||||
impeller_component("skia_conversions_unittests") {
|
||||
testonly = true
|
||||
|
||||
sources = [ "skia_conversions_unittests.cc" ]
|
||||
|
||||
deps = [
|
||||
":skia_conversions",
|
||||
"//flutter/testing:testing_lib",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "third_party/imgui/imgui.h"
|
||||
#include "third_party/skia/include/core/SkBlurTypes.h"
|
||||
#include "third_party/skia/include/core/SkClipOp.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkPathBuilder.h"
|
||||
#include "third_party/skia/include/core/SkRRect.h"
|
||||
|
||||
@@ -121,7 +120,7 @@ TEST_P(DisplayListTest, CanDrawCapsAndJoins) {
|
||||
|
||||
paint.setDrawStyle(flutter::DlDrawStyle::kStroke);
|
||||
paint.setStrokeWidth(30);
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setColor(flutter::DlColor::kRed());
|
||||
|
||||
auto path =
|
||||
SkPathBuilder{}.moveTo(-50, 0).lineTo(0, -50).lineTo(50, 0).snapshot();
|
||||
@@ -209,10 +208,10 @@ TEST_P(DisplayListTest, CanDrawArc) {
|
||||
paint.setStrokeJoin(flutter::DlStrokeJoin::kMiter);
|
||||
paint.setStrokeMiter(10);
|
||||
auto rect = SkRect::MakeLTRB(p1.x, p1.y, p2.x, p2.y);
|
||||
paint.setColor(SK_ColorGREEN);
|
||||
paint.setColor(flutter::DlColor::kGreen());
|
||||
paint.setStrokeWidth(2);
|
||||
builder.DrawRect(rect, paint);
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setColor(flutter::DlColor::kRed());
|
||||
paint.setStrokeWidth(stroke_width);
|
||||
builder.DrawArc(rect, start_angle, sweep_angle, use_center, paint);
|
||||
|
||||
@@ -226,7 +225,7 @@ TEST_P(DisplayListTest, StrokedPathsDrawCorrectly) {
|
||||
flutter::DisplayListBuilder builder;
|
||||
flutter::DlPaint paint;
|
||||
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setColor(flutter::DlColor::kRed());
|
||||
paint.setDrawStyle(flutter::DlDrawStyle::kStroke);
|
||||
|
||||
static float stroke_width = 10.0f;
|
||||
@@ -398,7 +397,7 @@ TEST_P(DisplayListTest, CanDrawWithOddPathWinding) {
|
||||
flutter::DisplayListBuilder builder;
|
||||
flutter::DlPaint paint;
|
||||
|
||||
paint.setColor(SK_ColorRED);
|
||||
paint.setColor(flutter::DlColor::kRed());
|
||||
paint.setDrawStyle(flutter::DlDrawStyle::kFill);
|
||||
|
||||
builder.Translate(300, 300);
|
||||
@@ -427,7 +426,7 @@ TEST_P(DisplayListTest, CanDrawWithMaskBlur) {
|
||||
|
||||
// Mask blurred filled path.
|
||||
{
|
||||
paint.setColor(SK_ColorYELLOW);
|
||||
paint.setColor(flutter::DlColor::kYellow());
|
||||
auto filter =
|
||||
flutter::DlBlurMaskFilter(flutter::DlBlurStyle::kOuter, 10.0f);
|
||||
paint.setMaskFilter(&filter);
|
||||
@@ -480,7 +479,7 @@ TEST_P(DisplayListTest, CanDrawWithBlendColorFilter) {
|
||||
|
||||
// Pipeline blended image.
|
||||
{
|
||||
auto filter = flutter::DlBlendColorFilter(SK_ColorYELLOW,
|
||||
auto filter = flutter::DlBlendColorFilter(flutter::DlColor::kYellow(),
|
||||
flutter::DlBlendMode::kModulate);
|
||||
paint.setColorFilter(&filter);
|
||||
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(100, 100),
|
||||
@@ -489,8 +488,8 @@ TEST_P(DisplayListTest, CanDrawWithBlendColorFilter) {
|
||||
|
||||
// Advanced blended image.
|
||||
{
|
||||
auto filter =
|
||||
flutter::DlBlendColorFilter(SK_ColorRED, flutter::DlBlendMode::kScreen);
|
||||
auto filter = flutter::DlBlendColorFilter(flutter::DlColor::kRed(),
|
||||
flutter::DlBlendMode::kScreen);
|
||||
paint.setColorFilter(&filter);
|
||||
builder.DrawImage(DlImageImpeller::Make(texture), SkPoint::Make(250, 250),
|
||||
flutter::DlImageSampling::kNearestNeighbor, &paint);
|
||||
@@ -860,7 +859,7 @@ TEST_P(DisplayListTest, TransparentShadowProducesCorrectColor) {
|
||||
dispatcher.save();
|
||||
dispatcher.scale(1.618, 1.618);
|
||||
dispatcher.drawShadow(SkPath{}.addRect(SkRect::MakeXYWH(0, 0, 200, 100)),
|
||||
SK_ColorTRANSPARENT, 15, false, 1);
|
||||
flutter::DlColor::kTransparent(), 15, false, 1);
|
||||
dispatcher.restore();
|
||||
auto picture = dispatcher.EndRecordingAsPicture();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "impeller/display_list/skia_conversions.h"
|
||||
#include "display_list/dl_color.h"
|
||||
#include "third_party/skia/modules/skparagraph/include/Paragraph.h"
|
||||
|
||||
namespace impeller {
|
||||
@@ -134,12 +135,12 @@ Point ToPoint(const SkPoint& point) {
|
||||
return Point::MakeXY(point.fX, point.fY);
|
||||
}
|
||||
|
||||
Color ToColor(const SkColor& color) {
|
||||
Color ToColor(const flutter::DlColor& color) {
|
||||
return {
|
||||
static_cast<Scalar>(SkColorGetR(color) / 255.0), //
|
||||
static_cast<Scalar>(SkColorGetG(color) / 255.0), //
|
||||
static_cast<Scalar>(SkColorGetB(color) / 255.0), //
|
||||
static_cast<Scalar>(SkColorGetA(color) / 255.0) //
|
||||
static_cast<Scalar>(color.getRedF()), //
|
||||
static_cast<Scalar>(color.getGreenF()), //
|
||||
static_cast<Scalar>(color.getBlueF()), //
|
||||
static_cast<Scalar>(color.getAlphaF()) //
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "display_list/dl_color.h"
|
||||
#include "impeller/core/formats.h"
|
||||
#include "impeller/geometry/color.h"
|
||||
#include "impeller/geometry/path.h"
|
||||
@@ -31,7 +32,7 @@ std::vector<Point> ToPoints(const SkPoint points[], int count);
|
||||
|
||||
Point ToPoint(const SkPoint& point);
|
||||
|
||||
Color ToColor(const SkColor& color);
|
||||
Color ToColor(const flutter::DlColor& color);
|
||||
|
||||
std::vector<Matrix> ToRSXForms(const SkRSXform xform[], int count);
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// 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/testing/testing.h"
|
||||
#include "impeller/display_list/skia_conversions.h"
|
||||
#include "impeller/geometry/scalar.h"
|
||||
|
||||
namespace impeller {
|
||||
namespace testing {
|
||||
|
||||
TEST(SkiaConversionsTest, ToColor) {
|
||||
// Create a color with alpha, red, green, and blue values that are all
|
||||
// trivially divisible by 255 so that we can test the conversion results in
|
||||
// correct scalar values.
|
||||
// AARRGGBB
|
||||
const flutter::DlColor color = 0x8040C020;
|
||||
auto converted_color = skia_conversions::ToColor(color);
|
||||
|
||||
ASSERT_TRUE(ScalarNearlyEqual(converted_color.alpha, 0x80 * (1.0f / 255)));
|
||||
ASSERT_TRUE(ScalarNearlyEqual(converted_color.red, 0x40 * (1.0f / 255)));
|
||||
ASSERT_TRUE(ScalarNearlyEqual(converted_color.green, 0xC0 * (1.0f / 255)));
|
||||
ASSERT_TRUE(ScalarNearlyEqual(converted_color.blue, 0x20 * (1.0f / 255)));
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "flutter/shell/common/dl_op_spy.h"
|
||||
|
||||
#ifdef IMPELLER_SUPPORTS_RENDERING
|
||||
#include "impeller/display_list/dl_dispatcher.h"
|
||||
#endif // IMPELLER_SUPPORTS_RENDERING
|
||||
#include "impeller/display_list/dl_dispatcher.h" // nogncheck
|
||||
#endif // IMPELLER_SUPPORTS_RENDERING
|
||||
|
||||
namespace flutter {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user