diff --git a/engine/src/flutter/display_list/dl_blend_mode.h b/engine/src/flutter/display_list/dl_blend_mode.h index a1c7b1231e9..009ef37b1c5 100644 --- a/engine/src/flutter/display_list/dl_blend_mode.h +++ b/engine/src/flutter/display_list/dl_blend_mode.h @@ -5,63 +5,11 @@ #ifndef FLUTTER_DISPLAY_LIST_DL_BLEND_MODE_H_ #define FLUTTER_DISPLAY_LIST_DL_BLEND_MODE_H_ +#include "flutter/impeller/geometry/color.h" + namespace flutter { -/// A enum define the blend mode. -/// Blends are operators that take in two colors (source, destination) and -/// return a new color. Many of these operate the same on all 4 -/// components: red, green, blue, alpha. For these, we just document what -/// happens to one component, rather than naming each one separately. Different -/// color types might have different representations for color components: -/// 8-bit: 0..255 -/// 6-bit: 0..63 -/// 5-bit: 0..31 -/// 4-bit: 0..15 -/// floats: 0...1 -/// The comments are expressed as if the component values are always 0..1 -/// (floats). For brevity, the documentation uses the following abbreviations s -/// : source d : destination sa : source alpha da : destination alpha Results -/// are abbreviated r : if all 4 components are computed in the same manner ra -/// : result alpha component rc : result "color": red, green, blue components -enum class DlBlendMode { - kClear, //!< r = 0 - kSrc, //!< r = s - kDst, //!< r = d - kSrcOver, //!< r = s + (1-sa)*d - kDstOver, //!< r = d + (1-da)*s - kSrcIn, //!< r = s * da - kDstIn, //!< r = d * sa - kSrcOut, //!< r = s * (1-da) - kDstOut, //!< r = d * (1-sa) - kSrcATop, //!< r = s*da + d*(1-sa) - kDstATop, //!< r = d*sa + s*(1-da) - kXor, //!< r = s*(1-da) + d*(1-sa) - kPlus, //!< r = min(s + d, 1) - kModulate, //!< r = s*d - kScreen, //!< r = s + d - s*d - - kOverlay, //!< multiply or screen, depending on destination - kDarken, //!< rc = s + d - max(s*da, d*sa), ra = kSrcOver - kLighten, //!< rc = s + d - min(s*da, d*sa), ra = kSrcOver - kColorDodge, //!< brighten destination to reflect source - kColorBurn, //!< darken destination to reflect source - kHardLight, //!< multiply or screen, depending on source - kSoftLight, //!< lighten or darken, depending on source - kDifference, //!< rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver - kExclusion, //!< rc = s + d - two(s*d), ra = kSrcOver - kMultiply, //!< r = s*(1-da) + d*(1-sa) + s*d - - kHue, //!< hue of source with saturation and luminosity of destination - kSaturation, //!< saturation of source with hue and luminosity of destination - kColor, //!< hue and saturation of source with luminosity of destination - kLuminosity, //!< luminosity of source with hue and saturation of destination - - kLastCoeffMode = kScreen, //!< last porter duff blend mode - kLastSeparableMode = - kMultiply, //!< last blend mode operating separately on components - kLastMode = kLuminosity, //!< last valid value - kDefaultMode = kSrcOver, -}; +using DlBlendMode = impeller::BlendMode; } // namespace flutter diff --git a/engine/src/flutter/display_list/skia/dl_sk_conversions_unittests.cc b/engine/src/flutter/display_list/skia/dl_sk_conversions_unittests.cc index c460c4e8c7c..61235d29b8d 100644 --- a/engine/src/flutter/display_list/skia/dl_sk_conversions_unittests.cc +++ b/engine/src/flutter/display_list/skia/dl_sk_conversions_unittests.cc @@ -141,8 +141,6 @@ TEST(DisplayListSkConversions, ToSkSamplingOptions) { FUNC(kSaturation) \ FUNC(kColor) \ FUNC(kLuminosity) \ - FUNC(kLastCoeffMode) \ - FUNC(kLastSeparableMode) \ FUNC(kLastMode) TEST(DisplayListSkConversions, ToSkBlendMode){ diff --git a/engine/src/flutter/display_list/testing/dl_rendering_unittests.cc b/engine/src/flutter/display_list/testing/dl_rendering_unittests.cc index 292aded3bfc..0965265d019 100644 --- a/engine/src/flutter/display_list/testing/dl_rendering_unittests.cc +++ b/engine/src/flutter/display_list/testing/dl_rendering_unittests.cc @@ -4390,18 +4390,6 @@ TEST_F(DisplayListRendering, MatrixColorFilterOpacityCommuteCheck) { FUNC(kColor) \ FUNC(kLuminosity) -// This function serves both to enhance error output below and to double -// check that the macro supplies all modes (otherwise it won't compile) -static std::string BlendModeToString(DlBlendMode mode) { - switch (mode) { -#define MODE_CASE(m) \ - case DlBlendMode::m: \ - return #m; - FOR_EACH_BLEND_MODE_ENUM(MODE_CASE) -#undef MODE_CASE - } -} - TEST_F(DisplayListRendering, BlendColorFilterModifyTransparencyCheck) { auto test_mode_color = [](DlBlendMode mode, DlColor color) { std::stringstream desc_str; diff --git a/engine/src/flutter/impeller/display_list/aiks_dl_atlas_unittests.cc b/engine/src/flutter/impeller/display_list/aiks_dl_atlas_unittests.cc index b3d45699566..4decc11fad9 100644 --- a/engine/src/flutter/impeller/display_list/aiks_dl_atlas_unittests.cc +++ b/engine/src/flutter/impeller/display_list/aiks_dl_atlas_unittests.cc @@ -181,7 +181,7 @@ TEST_P(AiksTest, DlAtlasGeometryNoBlend) { DlAtlasGeometry geom(atlas->impeller_texture(), transforms.data(), texture_coordinates.data(), nullptr, transforms.size(), - BlendMode::kSourceOver, {}, std::nullopt); + BlendMode::kSrcOver, {}, std::nullopt); EXPECT_FALSE(geom.ShouldUseBlend()); EXPECT_FALSE(geom.ShouldSkip()); @@ -202,10 +202,9 @@ TEST_P(AiksTest, DlAtlasGeometryBlend) { for (auto i = 0u; i < texture_coordinates.size(); i++) { colors.push_back(DlColor::ARGB(0.5, 1, 1, 1)); } - DlAtlasGeometry geom(atlas->impeller_texture(), transforms.data(), - texture_coordinates.data(), colors.data(), - transforms.size(), BlendMode::kSourceOver, {}, - std::nullopt); + DlAtlasGeometry geom( + atlas->impeller_texture(), transforms.data(), texture_coordinates.data(), + colors.data(), transforms.size(), BlendMode::kSrcOver, {}, std::nullopt); EXPECT_TRUE(geom.ShouldUseBlend()); EXPECT_FALSE(geom.ShouldSkip()); @@ -228,7 +227,7 @@ TEST_P(AiksTest, DlAtlasGeometryColorButNoBlend) { } DlAtlasGeometry geom(atlas->impeller_texture(), transforms.data(), texture_coordinates.data(), colors.data(), - transforms.size(), BlendMode::kSource, {}, std::nullopt); + transforms.size(), BlendMode::kSrc, {}, std::nullopt); // Src blend mode means that colors would be ignored, even if provided. EXPECT_FALSE(geom.ShouldUseBlend()); diff --git a/engine/src/flutter/impeller/display_list/canvas.cc b/engine/src/flutter/impeller/display_list/canvas.cc index 1c60c5857e0..c18ebc8a853 100644 --- a/engine/src/flutter/impeller/display_list/canvas.cc +++ b/engine/src/flutter/impeller/display_list/canvas.cc @@ -85,7 +85,7 @@ static void ApplyFramebufferBlend(Entity& entity) { contents->SetChildContents(src_contents); contents->SetBlendMode(entity.GetBlendMode()); entity.SetContents(std::move(contents)); - entity.SetBlendMode(BlendMode::kSource); + entity.SetBlendMode(BlendMode::kSrc); } /// @brief Create the subpass restore contents, appling any filters or opacity @@ -374,8 +374,7 @@ bool Canvas::AttemptDrawBlurredRRect(const Rect& rect, FilterContents::BlurStyle::kNormal && paint.image_filter) || (paint.mask_blur_descriptor->style == FilterContents::BlurStyle::kSolid && - (!rrect_color.IsOpaque() || - paint.blend_mode != BlendMode::kSourceOver))) { + (!rrect_color.IsOpaque() || paint.blend_mode != BlendMode::kSrcOver))) { Rect render_bounds = rect; if (paint.mask_blur_descriptor->style != FilterContents::BlurStyle::kInner) { @@ -766,7 +765,7 @@ void Canvas::DrawVertices(const std::shared_ptr& vertices, // of Skia's SK_LEGACY_IGNORE_DRAW_VERTICES_BLEND_WITH_NO_SHADER flag, which // is enabled when the Flutter engine builds Skia. if (!paint.color_source) { - blend_mode = BlendMode::kDestination; + blend_mode = BlendMode::kDst; } Entity entity; @@ -780,7 +779,7 @@ void Canvas::DrawVertices(const std::shared_ptr& vertices, } // If the blend mode is destination don't bother to bind or create a texture. - if (blend_mode == BlendMode::kDestination) { + if (blend_mode == BlendMode::kDst) { auto contents = std::make_shared(); contents->SetBlendMode(blend_mode); contents->SetAlpha(paint.color.alpha); @@ -1326,7 +1325,7 @@ bool Canvas::Restore() { element_entity.GetBlendMode(), inputs); contents->SetCoverageHint(element_entity.GetCoverage()); element_entity.SetContents(std::move(contents)); - element_entity.SetBlendMode(BlendMode::kSource); + element_entity.SetBlendMode(BlendMode::kSrc); } } @@ -1489,9 +1488,9 @@ void Canvas::AddRenderEntityToCurrentPass(Entity& entity, bool reuse_depth) { Matrix::MakeTranslation(Vector3(-GetGlobalPassPosition())) * entity.GetTransform()); entity.SetInheritedOpacity(transform_stack_.back().distributed_opacity); - if (entity.GetBlendMode() == BlendMode::kSourceOver && + if (entity.GetBlendMode() == BlendMode::kSrcOver && entity.GetContents()->IsOpaque(entity.GetTransform())) { - entity.SetBlendMode(BlendMode::kSource); + entity.SetBlendMode(BlendMode::kSrc); } // If the entity covers the current render target and is a solid color, then @@ -1558,7 +1557,7 @@ void Canvas::AddRenderEntityToCurrentPass(Entity& entity, bool reuse_depth) { auto contents = ColorFilterContents::MakeBlend(entity.GetBlendMode(), inputs); entity.SetContents(std::move(contents)); - entity.SetBlendMode(BlendMode::kSource); + entity.SetBlendMode(BlendMode::kSrc); } } @@ -1678,7 +1677,7 @@ std::shared_ptr Canvas::FlipBackdrop(Point global_pass_position, Entity msaa_backdrop_entity; msaa_backdrop_entity.SetContents(std::move(msaa_backdrop_contents)); - msaa_backdrop_entity.SetBlendMode(BlendMode::kSource); + msaa_backdrop_entity.SetBlendMode(BlendMode::kSrc); msaa_backdrop_entity.SetClipDepth(std::numeric_limits::max()); if (!msaa_backdrop_entity.Render(renderer_, current_render_pass)) { VALIDATION_LOG << "Failed to render MSAA backdrop entity."; @@ -1739,7 +1738,7 @@ bool Canvas::BlitToOnscreen(bool is_onscreen) { Entity entity; entity.SetContents(contents); - entity.SetBlendMode(BlendMode::kSource); + entity.SetBlendMode(BlendMode::kSrc); if (!entity.Render(renderer_, *render_pass)) { VALIDATION_LOG << "Failed to render EntityPass root blit."; diff --git a/engine/src/flutter/impeller/display_list/canvas_unittests.cc b/engine/src/flutter/impeller/display_list/canvas_unittests.cc index 0ac3c2c3ba7..18382ad7500 100644 --- a/engine/src/flutter/impeller/display_list/canvas_unittests.cc +++ b/engine/src/flutter/impeller/display_list/canvas_unittests.cc @@ -315,7 +315,7 @@ TEST_P(AiksTest, DrawVerticesLinearGradientWithEmptySize) { Paint paint; paint.color_source = gradient.get(); canvas.DrawVertices(std::make_shared(vertices, context), - BlendMode::kSourceOver, paint); + BlendMode::kSrcOver, paint); canvas.EndReplay(); return true; @@ -364,7 +364,7 @@ TEST_P(AiksTest, DrawVerticesWithEmptyTextureCoordinates) { Paint paint; paint.color_source = color_source.get(); canvas.DrawVertices(std::make_shared(vertices, context), - BlendMode::kSourceOver, paint); + BlendMode::kSrcOver, paint); canvas.EndReplay(); return true; diff --git a/engine/src/flutter/impeller/display_list/dl_atlas_geometry.cc b/engine/src/flutter/impeller/display_list/dl_atlas_geometry.cc index 676271b1847..218877021da 100644 --- a/engine/src/flutter/impeller/display_list/dl_atlas_geometry.cc +++ b/engine/src/flutter/impeller/display_list/dl_atlas_geometry.cc @@ -34,7 +34,7 @@ DlAtlasGeometry::DlAtlasGeometry(const std::shared_ptr& atlas, DlAtlasGeometry::~DlAtlasGeometry() = default; bool DlAtlasGeometry::ShouldUseBlend() const { - return colors_ != nullptr && mode_ != BlendMode::kSource; + return colors_ != nullptr && mode_ != BlendMode::kSrc; } bool DlAtlasGeometry::ShouldSkip() const { diff --git a/engine/src/flutter/impeller/display_list/dl_dispatcher.cc b/engine/src/flutter/impeller/display_list/dl_dispatcher.cc index ffb530ce058..a444410ac08 100644 --- a/engine/src/flutter/impeller/display_list/dl_dispatcher.cc +++ b/engine/src/flutter/impeller/display_list/dl_dispatcher.cc @@ -251,7 +251,7 @@ void DlDispatcherBase::setInvertColors(bool invert) { void DlDispatcherBase::setBlendMode(flutter::DlBlendMode dl_mode) { AUTO_DEPTH_WATCHER(0u); - paint_.blend_mode = skia_conversions::ToBlendMode(dl_mode); + paint_.blend_mode = dl_mode; } static FilterContents::BlurStyle ToBlurStyle(flutter::DlBlurStyle blur_style) { @@ -530,7 +530,7 @@ void DlDispatcherBase::drawColor(flutter::DlColor color, Paint paint; paint.color = skia_conversions::ToColor(color); - paint.blend_mode = skia_conversions::ToBlendMode(dl_mode); + paint.blend_mode = dl_mode; GetCanvas().DrawPaint(paint); } @@ -825,7 +825,7 @@ void DlDispatcherBase::drawAtlas(const sk_sp atlas, tex, // colors, // static_cast(count), // - skia_conversions::ToBlendMode(mode), // + mode, // skia_conversions::ToSamplerDescriptor(sampling), // ToOptRect(cull_rect) // ); @@ -992,8 +992,7 @@ static bool RequiresReadbackForBlends( const ContentContext& renderer, flutter::DlBlendMode max_root_blend_mode) { return !renderer.GetDeviceCapabilities().SupportsFramebufferFetch() && - skia_conversions::ToBlendMode(max_root_blend_mode) > - Entity::kLastPipelineBlendMode; + max_root_blend_mode > Entity::kLastPipelineBlendMode; } CanvasDlDispatcher::CanvasDlDispatcher(ContentContext& renderer, @@ -1020,8 +1019,8 @@ void CanvasDlDispatcher::drawVertices( AUTO_DEPTH_WATCHER(1u); GetCanvas().DrawVertices( - std::make_shared(vertices, renderer_), - skia_conversions::ToBlendMode(dl_mode), paint_); + std::make_shared(vertices, renderer_), dl_mode, + paint_); } void CanvasDlDispatcher::SetBackdropData( diff --git a/engine/src/flutter/impeller/display_list/dl_image_impeller.cc b/engine/src/flutter/impeller/display_list/dl_image_impeller.cc index 6b7a198c7f2..0fa7a7c516b 100644 --- a/engine/src/flutter/impeller/display_list/dl_image_impeller.cc +++ b/engine/src/flutter/impeller/display_list/dl_image_impeller.cc @@ -41,7 +41,7 @@ sk_sp DlImageImpeller::MakeFromYUVTextures( auto yuv_to_rgb_filter_contents = FilterContents::MakeYUVToRGBFilter( std::move(y_texture), std::move(uv_texture), yuv_color_space); impeller::Entity entity; - entity.SetBlendMode(impeller::BlendMode::kSource); + entity.SetBlendMode(impeller::BlendMode::kSrc); auto snapshot = yuv_to_rgb_filter_contents->RenderToSnapshot( aiks_context->GetContentContext(), // renderer entity, // entity diff --git a/engine/src/flutter/impeller/display_list/paint.cc b/engine/src/flutter/impeller/display_list/paint.cc index 245d21447fd..ef993002583 100644 --- a/engine/src/flutter/impeller/display_list/paint.cc +++ b/engine/src/flutter/impeller/display_list/paint.cc @@ -387,7 +387,7 @@ std::shared_ptr Paint::MaskBlurDescriptor::CreateMaskBlur( geometry); return ColorFilterContents::MakeBlend( - BlendMode::kSourceIn, + BlendMode::kSrcIn, {FilterInput::Make(blurred_mask), FilterInput::Make(texture_contents)}); } @@ -443,7 +443,7 @@ std::shared_ptr Paint::MaskBlurDescriptor::CreateMaskBlur( /// 5. Composite the color source with the blurred mask. return ColorFilterContents::MakeBlend( - BlendMode::kSourceIn, + BlendMode::kSrcIn, {FilterInput::Make(blurred_mask), FilterInput::Make(color_contents)}); } diff --git a/engine/src/flutter/impeller/display_list/paint.h b/engine/src/flutter/impeller/display_list/paint.h index 2fd33e13529..f6b67552485 100644 --- a/engine/src/flutter/impeller/display_list/paint.h +++ b/engine/src/flutter/impeller/display_list/paint.h @@ -37,7 +37,7 @@ struct Paint { /// @brief Whether or not a save layer with the provided paint can perform the /// opacity peephole optimization. static bool CanApplyOpacityPeephole(const Paint& paint) { - return paint.blend_mode == BlendMode::kSourceOver && + return paint.blend_mode == BlendMode::kSrcOver && paint.invert_colors == false && !paint.mask_blur_descriptor.has_value() && paint.image_filter == nullptr && paint.color_filter == nullptr; @@ -81,7 +81,7 @@ struct Paint { Join stroke_join = Join::kMiter; Scalar stroke_miter = 4.0; Style style = Style::kFill; - BlendMode blend_mode = BlendMode::kSourceOver; + BlendMode blend_mode = BlendMode::kSrcOver; bool invert_colors = false; std::optional mask_blur_descriptor; diff --git a/engine/src/flutter/impeller/display_list/skia_conversions.cc b/engine/src/flutter/impeller/display_list/skia_conversions.cc index 8920f3bd38e..0cfad0b8fa8 100644 --- a/engine/src/flutter/impeller/display_list/skia_conversions.cc +++ b/engine/src/flutter/impeller/display_list/skia_conversions.cc @@ -45,69 +45,5 @@ impeller::SamplerDescriptor ToSamplerDescriptor( return desc; } -BlendMode ToBlendMode(flutter::DlBlendMode mode) { - switch (mode) { - case flutter::DlBlendMode::kClear: - return BlendMode::kClear; - case flutter::DlBlendMode::kSrc: - return BlendMode::kSource; - case flutter::DlBlendMode::kDst: - return BlendMode::kDestination; - case flutter::DlBlendMode::kSrcOver: - return BlendMode::kSourceOver; - case flutter::DlBlendMode::kDstOver: - return BlendMode::kDestinationOver; - case flutter::DlBlendMode::kSrcIn: - return BlendMode::kSourceIn; - case flutter::DlBlendMode::kDstIn: - return BlendMode::kDestinationIn; - case flutter::DlBlendMode::kSrcOut: - return BlendMode::kSourceOut; - case flutter::DlBlendMode::kDstOut: - return BlendMode::kDestinationOut; - case flutter::DlBlendMode::kSrcATop: - return BlendMode::kSourceATop; - case flutter::DlBlendMode::kDstATop: - return BlendMode::kDestinationATop; - case flutter::DlBlendMode::kXor: - return BlendMode::kXor; - case flutter::DlBlendMode::kPlus: - return BlendMode::kPlus; - case flutter::DlBlendMode::kModulate: - return BlendMode::kModulate; - case flutter::DlBlendMode::kScreen: - return BlendMode::kScreen; - case flutter::DlBlendMode::kOverlay: - return BlendMode::kOverlay; - case flutter::DlBlendMode::kDarken: - return BlendMode::kDarken; - case flutter::DlBlendMode::kLighten: - return BlendMode::kLighten; - case flutter::DlBlendMode::kColorDodge: - return BlendMode::kColorDodge; - case flutter::DlBlendMode::kColorBurn: - return BlendMode::kColorBurn; - case flutter::DlBlendMode::kHardLight: - return BlendMode::kHardLight; - case flutter::DlBlendMode::kSoftLight: - return BlendMode::kSoftLight; - case flutter::DlBlendMode::kDifference: - return BlendMode::kDifference; - case flutter::DlBlendMode::kExclusion: - return BlendMode::kExclusion; - case flutter::DlBlendMode::kMultiply: - return BlendMode::kMultiply; - case flutter::DlBlendMode::kHue: - return BlendMode::kHue; - case flutter::DlBlendMode::kSaturation: - return BlendMode::kSaturation; - case flutter::DlBlendMode::kColor: - return BlendMode::kColor; - case flutter::DlBlendMode::kLuminosity: - return BlendMode::kLuminosity; - } - FML_UNREACHABLE(); -} - } // namespace skia_conversions } // namespace impeller diff --git a/engine/src/flutter/impeller/display_list/skia_conversions.h b/engine/src/flutter/impeller/display_list/skia_conversions.h index 4418373016a..e1850beed4d 100644 --- a/engine/src/flutter/impeller/display_list/skia_conversions.h +++ b/engine/src/flutter/impeller/display_list/skia_conversions.h @@ -19,8 +19,6 @@ Color ToColor(const flutter::DlColor& color); impeller::SamplerDescriptor ToSamplerDescriptor( const flutter::DlImageSampling options); -BlendMode ToBlendMode(flutter::DlBlendMode mode); - } // namespace skia_conversions } // namespace impeller diff --git a/engine/src/flutter/impeller/display_list/skia_conversions_unittests.cc b/engine/src/flutter/impeller/display_list/skia_conversions_unittests.cc index a9e8ced9325..76afa77a374 100644 --- a/engine/src/flutter/impeller/display_list/skia_conversions_unittests.cc +++ b/engine/src/flutter/impeller/display_list/skia_conversions_unittests.cc @@ -59,13 +59,5 @@ TEST(SkiaConversionsTest, ToColor) { ASSERT_TRUE(ScalarNearlyEqual(converted_color.blue, 0x20 * (1.0f / 255))); } -TEST(SkiaConversionsTest, BlendMode) { - for (auto i = 0; i < static_cast(flutter::DlBlendMode::kLastMode); i++) { - EXPECT_EQ( - skia_conversions::ToBlendMode(static_cast(i)), - static_cast(i)); - } -} - } // namespace testing } // namespace impeller diff --git a/engine/src/flutter/impeller/entity/contents/atlas_contents.cc b/engine/src/flutter/impeller/entity/contents/atlas_contents.cc index d0bd6e9625a..cc676247bdd 100644 --- a/engine/src/flutter/impeller/entity/contents/atlas_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/atlas_contents.cc @@ -65,7 +65,7 @@ bool AtlasContents::Render(const ContentContext& renderer, auto pipeline_options = OptionsFromPassAndEntity(pass, entity); pipeline_options.primitive_type = PrimitiveType::kTriangle; pipeline_options.depth_write_enabled = - pipeline_options.blend_mode == BlendMode::kSource; + pipeline_options.blend_mode == BlendMode::kSrc; pass.SetPipeline(renderer.GetTexturePipeline(pipeline_options)); pass.SetVertexBuffer(geometry_->CreateSimpleVertexBuffer(host_buffer)); @@ -98,7 +98,7 @@ bool AtlasContents::Render(const ContentContext& renderer, #endif // IMPELLER_DEBUG pass.SetVertexBuffer(geometry_->CreateBlendVertexBuffer(host_buffer)); auto inverted_blend_mode = - InvertPorterDuffBlend(blend_mode).value_or(BlendMode::kSource); + InvertPorterDuffBlend(blend_mode).value_or(BlendMode::kSrc); pass.SetPipeline(renderer.GetPorterDuffPipeline(inverted_blend_mode, OptionsFromPass(pass))); diff --git a/engine/src/flutter/impeller/entity/contents/clip_contents.cc b/engine/src/flutter/impeller/entity/contents/clip_contents.cc index 16e72687502..7c456572bea 100644 --- a/engine/src/flutter/impeller/entity/contents/clip_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/clip_contents.cc @@ -79,7 +79,7 @@ bool ClipContents::Render(const ContentContext& renderer, info.depth = GetShaderClipDepth(clip_depth); auto options = OptionsFromPass(pass); - options.blend_mode = BlendMode::kDestination; + options.blend_mode = BlendMode::kDst; pass.SetStencilReference(0); @@ -157,7 +157,7 @@ bool RenderClipRestore(const ContentContext& renderer, pass.SetCommandLabel("Restore Clip"); auto options = OptionsFromPass(pass); - options.blend_mode = BlendMode::kDestination; + options.blend_mode = BlendMode::kDst; options.stencil_mode = ContentContextOptions::StencilMode::kOverdrawPreventionRestore; options.primitive_type = PrimitiveType::kTriangleStrip; diff --git a/engine/src/flutter/impeller/entity/contents/color_source_contents.h b/engine/src/flutter/impeller/entity/contents/color_source_contents.h index b988ff4ee00..96bfd629284 100644 --- a/engine/src/flutter/impeller/entity/contents/color_source_contents.h +++ b/engine/src/flutter/impeller/entity/contents/color_source_contents.h @@ -158,7 +158,7 @@ class ColorSourceContents : public Contents { pass.SetVertexBuffer(std::move(stencil_geometry_result.vertex_buffer)); options.primitive_type = stencil_geometry_result.type; - options.blend_mode = BlendMode::kDestination; + options.blend_mode = BlendMode::kDst; switch (stencil_geometry_result.mode) { case GeometryResult::Mode::kNonZero: pass.SetCommandLabel("Stencil preparation (NonZero)"); @@ -220,7 +220,7 @@ class ColorSourceContents : public Contents { // Enable depth writing for all opaque entities in order to allow // reordering. Opaque entities are coerced to source blending by // `EntityPass::AddEntity`. - options.depth_write_enabled = options.blend_mode == BlendMode::kSource; + options.depth_write_enabled = options.blend_mode == BlendMode::kSrc; // Take the pre-populated vertex shader uniform struct and set managed // values. @@ -232,7 +232,7 @@ class ColorSourceContents : public Contents { // the stencil buffer (happens below in this method). This can be skipped // for draws that are fully opaque or use src blend mode. if (geometry_result.mode == GeometryResult::Mode::kPreventOverdraw && - options.blend_mode != BlendMode::kSource) { + options.blend_mode != BlendMode::kSrc) { options.stencil_mode = ContentContextOptions::StencilMode::kOverdrawPreventionIncrement; } @@ -259,7 +259,7 @@ class ColorSourceContents : public Contents { // was incremented by 1 in order to self-clip. So simply append a clip // restore to clean it up. if (geometry_result.mode == GeometryResult::Mode::kPreventOverdraw && - options.blend_mode != BlendMode::kSource) { + options.blend_mode != BlendMode::kSrc) { return RenderClipRestore(renderer, pass, entity.GetClipDepth(), GetCoverage(entity)); } diff --git a/engine/src/flutter/impeller/entity/contents/content_context.cc b/engine/src/flutter/impeller/entity/contents/content_context.cc index 7a245eaf721..980656d1120 100644 --- a/engine/src/flutter/impeller/entity/contents/content_context.cc +++ b/engine/src/flutter/impeller/entity/contents/content_context.cc @@ -30,7 +30,7 @@ void ContentContextOptions::ApplyToPipelineDescriptor( if (blend_mode > Entity::kLastPipelineBlendMode) { VALIDATION_LOG << "Cannot use blend mode " << static_cast(blend_mode) << " as a pipeline blend."; - pipeline_blend = BlendMode::kSourceOver; + pipeline_blend = BlendMode::kSrcOver; } desc.SetSampleCount(sample_count); @@ -57,63 +57,63 @@ void ContentContextOptions::ApplyToPipelineDescriptor( color0.src_color_blend_factor = BlendFactor::kZero; } break; - case BlendMode::kSource: + case BlendMode::kSrc: color0.blending_enabled = false; color0.dst_alpha_blend_factor = BlendFactor::kZero; color0.dst_color_blend_factor = BlendFactor::kZero; color0.src_alpha_blend_factor = BlendFactor::kOne; color0.src_color_blend_factor = BlendFactor::kOne; break; - case BlendMode::kDestination: + case BlendMode::kDst: color0.dst_alpha_blend_factor = BlendFactor::kOne; color0.dst_color_blend_factor = BlendFactor::kOne; color0.src_alpha_blend_factor = BlendFactor::kZero; color0.src_color_blend_factor = BlendFactor::kZero; color0.write_mask = ColorWriteMaskBits::kNone; break; - case BlendMode::kSourceOver: + case BlendMode::kSrcOver: color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha; color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha; color0.src_alpha_blend_factor = BlendFactor::kOne; color0.src_color_blend_factor = BlendFactor::kOne; break; - case BlendMode::kDestinationOver: + case BlendMode::kDstOver: color0.dst_alpha_blend_factor = BlendFactor::kOne; color0.dst_color_blend_factor = BlendFactor::kOne; color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha; color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha; break; - case BlendMode::kSourceIn: + case BlendMode::kSrcIn: color0.dst_alpha_blend_factor = BlendFactor::kZero; color0.dst_color_blend_factor = BlendFactor::kZero; color0.src_alpha_blend_factor = BlendFactor::kDestinationAlpha; color0.src_color_blend_factor = BlendFactor::kDestinationAlpha; break; - case BlendMode::kDestinationIn: + case BlendMode::kDstIn: color0.dst_alpha_blend_factor = BlendFactor::kSourceAlpha; color0.dst_color_blend_factor = BlendFactor::kSourceAlpha; color0.src_alpha_blend_factor = BlendFactor::kZero; color0.src_color_blend_factor = BlendFactor::kZero; break; - case BlendMode::kSourceOut: + case BlendMode::kSrcOut: color0.dst_alpha_blend_factor = BlendFactor::kZero; color0.dst_color_blend_factor = BlendFactor::kZero; color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha; color0.src_color_blend_factor = BlendFactor::kOneMinusDestinationAlpha; break; - case BlendMode::kDestinationOut: + case BlendMode::kDstOut: color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha; color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha; color0.src_alpha_blend_factor = BlendFactor::kZero; color0.src_color_blend_factor = BlendFactor::kZero; break; - case BlendMode::kSourceATop: + case BlendMode::kSrcATop: color0.dst_alpha_blend_factor = BlendFactor::kOneMinusSourceAlpha; color0.dst_color_blend_factor = BlendFactor::kOneMinusSourceAlpha; color0.src_alpha_blend_factor = BlendFactor::kDestinationAlpha; color0.src_color_blend_factor = BlendFactor::kDestinationAlpha; break; - case BlendMode::kDestinationATop: + case BlendMode::kDstATop: color0.dst_alpha_blend_factor = BlendFactor::kSourceAlpha; color0.dst_color_blend_factor = BlendFactor::kSourceAlpha; color0.src_alpha_blend_factor = BlendFactor::kOneMinusDestinationAlpha; @@ -852,25 +852,25 @@ PipelineRef ContentContext::GetPorterDuffPipeline( switch (mode) { case BlendMode::kClear: return GetClearBlendPipeline(opts); - case BlendMode::kSource: + case BlendMode::kSrc: return GetSourceBlendPipeline(opts); - case BlendMode::kDestination: + case BlendMode::kDst: return GetDestinationBlendPipeline(opts); - case BlendMode::kSourceOver: + case BlendMode::kSrcOver: return GetSourceOverBlendPipeline(opts); - case BlendMode::kDestinationOver: + case BlendMode::kDstOver: return GetDestinationOverBlendPipeline(opts); - case BlendMode::kSourceIn: + case BlendMode::kSrcIn: return GetSourceInBlendPipeline(opts); - case BlendMode::kDestinationIn: + case BlendMode::kDstIn: return GetDestinationInBlendPipeline(opts); - case BlendMode::kSourceOut: + case BlendMode::kSrcOut: return GetSourceOutBlendPipeline(opts); - case BlendMode::kDestinationOut: + case BlendMode::kDstOut: return GetDestinationOutBlendPipeline(opts); - case BlendMode::kSourceATop: + case BlendMode::kSrcATop: return GetSourceATopBlendPipeline(opts); - case BlendMode::kDestinationATop: + case BlendMode::kDstATop: return GetDestinationATopBlendPipeline(opts); case BlendMode::kXor: return GetXorBlendPipeline(opts); diff --git a/engine/src/flutter/impeller/entity/contents/content_context.h b/engine/src/flutter/impeller/entity/contents/content_context.h index 733293e914f..03487affeb7 100644 --- a/engine/src/flutter/impeller/entity/contents/content_context.h +++ b/engine/src/flutter/impeller/entity/contents/content_context.h @@ -245,7 +245,7 @@ struct ContentContextOptions { }; SampleCount sample_count = SampleCount::kCount1; - BlendMode blend_mode = BlendMode::kSourceOver; + BlendMode blend_mode = BlendMode::kSrcOver; CompareFunction depth_compare = CompareFunction::kAlways; StencilMode stencil_mode = ContentContextOptions::StencilMode::kIgnore; PrimitiveType primitive_type = PrimitiveType::kTriangle; diff --git a/engine/src/flutter/impeller/entity/contents/contents.cc b/engine/src/flutter/impeller/entity/contents/contents.cc index 21d7ebf75d0..2d5982dc95d 100644 --- a/engine/src/flutter/impeller/entity/contents/contents.cc +++ b/engine/src/flutter/impeller/entity/contents/contents.cc @@ -91,7 +91,7 @@ std::optional Contents::RenderToSnapshot( [&contents = *this, &entity, &coverage](const ContentContext& renderer, RenderPass& pass) -> bool { Entity sub_entity; - sub_entity.SetBlendMode(BlendMode::kSourceOver); + sub_entity.SetBlendMode(BlendMode::kSrcOver); sub_entity.SetTransform( Matrix::MakeTranslation(Vector3(-coverage->GetOrigin())) * entity.GetTransform()); diff --git a/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc index a276b575ff9..dbc22154fb6 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.cc @@ -52,26 +52,26 @@ std::optional InvertPorterDuffBlend(BlendMode blend_mode) { switch (blend_mode) { case BlendMode::kClear: return BlendMode::kClear; - case BlendMode::kSource: - return BlendMode::kDestination; - case BlendMode::kDestination: - return BlendMode::kSource; - case BlendMode::kSourceOver: - return BlendMode::kDestinationOver; - case BlendMode::kDestinationOver: - return BlendMode::kSourceOver; - case BlendMode::kSourceIn: - return BlendMode::kDestinationIn; - case BlendMode::kDestinationIn: - return BlendMode::kSourceIn; - case BlendMode::kSourceOut: - return BlendMode::kDestinationOut; - case BlendMode::kDestinationOut: - return BlendMode::kSourceOut; - case BlendMode::kSourceATop: - return BlendMode::kDestinationATop; - case BlendMode::kDestinationATop: - return BlendMode::kSourceATop; + case BlendMode::kSrc: + return BlendMode::kDst; + case BlendMode::kDst: + return BlendMode::kSrc; + case BlendMode::kSrcOver: + return BlendMode::kDstOver; + case BlendMode::kDstOver: + return BlendMode::kSrcOver; + case BlendMode::kSrcIn: + return BlendMode::kDstIn; + case BlendMode::kDstIn: + return BlendMode::kSrcIn; + case BlendMode::kSrcOut: + return BlendMode::kDstOut; + case BlendMode::kDstOut: + return BlendMode::kSrcOut; + case BlendMode::kSrcATop: + return BlendMode::kDstATop; + case BlendMode::kDstATop: + return BlendMode::kSrcATop; case BlendMode::kXor: return BlendMode::kXor; case BlendMode::kPlus: @@ -84,7 +84,7 @@ std::optional InvertPorterDuffBlend(BlendMode blend_mode) { } BlendFilterContents::BlendFilterContents() { - SetBlendMode(BlendMode::kSourceOver); + SetBlendMode(BlendMode::kSrcOver); } BlendFilterContents::~BlendFilterContents() = default; @@ -187,7 +187,7 @@ static std::optional AdvancedBlend( auto options = OptionsFromPass(pass); options.primitive_type = PrimitiveType::kTriangleStrip; - options.blend_mode = BlendMode::kSource; + options.blend_mode = BlendMode::kSrc; PipelineRef pipeline = std::invoke(pipeline_proc, renderer, options); #ifdef IMPELLER_DEBUG @@ -440,7 +440,7 @@ std::optional BlendFilterContents::CreateForegroundPorterDuffBlend( return std::nullopt; } - if (blend_mode == BlendMode::kDestination) { + if (blend_mode == BlendMode::kDst) { return Entity::FromSnapshot(dst_snapshot.value(), entity.GetBlendMode()); } @@ -603,7 +603,7 @@ static std::optional PipelineBlend( }; // Draw the first texture using kSource. - options.blend_mode = BlendMode::kSource; + options.blend_mode = BlendMode::kSrc; pass.SetPipeline(renderer.GetTexturePipeline(options)); if (!add_blend_command(dst_snapshot)) { return true; @@ -769,7 +769,7 @@ std::optional BlendFilterContents::CreateFramebufferAdvancedBlend( }; auto options = OptionsFromPass(pass); - options.blend_mode = BlendMode::kSource; + options.blend_mode = BlendMode::kSrc; options.primitive_type = PrimitiveType::kTriangleStrip; pass.SetCommandLabel("Framebuffer Advanced Blend Filter"); @@ -978,7 +978,7 @@ std::optional BlendFilterContents::RenderFilter( if (inputs.size() == 1 && !foreground_color_.has_value()) { // Nothing to blend. - return PipelineBlend(inputs, renderer, entity, coverage, BlendMode::kSource, + return PipelineBlend(inputs, renderer, entity, coverage, BlendMode::kSrc, std::nullopt, GetAbsorbOpacity(), GetAlpha()); } diff --git a/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.h b/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.h index 468ff18ae0e..9d4fcee8209 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.h +++ b/engine/src/flutter/impeller/entity/contents/filters/blend_filter_contents.h @@ -109,7 +109,7 @@ class BlendFilterContents : public ColorFilterContents { std::optional alpha, ColorFilterContents::AbsorbOpacity absorb_opacity) const; - BlendMode blend_mode_ = BlendMode::kSourceOver; + BlendMode blend_mode_ = BlendMode::kSrcOver; AdvancedBlendProc advanced_blend_proc_; std::optional foreground_color_; diff --git a/engine/src/flutter/impeller/entity/contents/filters/gaussian_blur_filter_contents_unittests.cc b/engine/src/flutter/impeller/entity/contents/filters/gaussian_blur_filter_contents_unittests.cc index 26449a2573d..84f3c00aa46 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/gaussian_blur_filter_contents_unittests.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/gaussian_blur_filter_contents_unittests.cc @@ -251,7 +251,7 @@ TEST_P(GaussianBlurFilterContentsTest, RenderCoverageMatchesGetCoverage) { contents->GetEntity(*renderer, entity, /*coverage_hint=*/{}); EXPECT_TRUE(result.has_value()); if (result.has_value()) { - EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSourceOver); + EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSrcOver); std::optional result_coverage = result.value().GetCoverage(); std::optional contents_coverage = contents->GetCoverage(entity); EXPECT_TRUE(result_coverage.has_value()); @@ -284,7 +284,7 @@ TEST_P(GaussianBlurFilterContentsTest, EXPECT_TRUE(result.has_value()); if (result.has_value()) { - EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSourceOver); + EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSrcOver); std::optional result_coverage = result.value().GetCoverage(); std::optional contents_coverage = contents->GetCoverage(entity); EXPECT_TRUE(result_coverage.has_value()); @@ -317,7 +317,7 @@ TEST_P(GaussianBlurFilterContentsTest, contents->GetEntity(*renderer, entity, /*coverage_hint=*/{}); EXPECT_TRUE(result.has_value()); if (result.has_value()) { - EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSourceOver); + EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSrcOver); std::optional result_coverage = result.value().GetCoverage(); std::optional contents_coverage = contents->GetCoverage(entity); EXPECT_TRUE(result_coverage.has_value()); @@ -365,7 +365,7 @@ TEST_P(GaussianBlurFilterContentsTest, TextureContentsWithDestinationRect) { contents->GetEntity(*renderer, entity, /*coverage_hint=*/{}); EXPECT_TRUE(result.has_value()); if (result.has_value()) { - EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSourceOver); + EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSrcOver); std::optional result_coverage = result.value().GetCoverage(); std::optional contents_coverage = contents->GetCoverage(entity); EXPECT_TRUE(result_coverage.has_value()); @@ -402,7 +402,7 @@ TEST_P(GaussianBlurFilterContentsTest, contents->GetEntity(*renderer, entity, /*coverage_hint=*/{}); EXPECT_TRUE(result.has_value()); if (result.has_value()) { - EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSourceOver); + EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSrcOver); std::optional result_coverage = result.value().GetCoverage(); std::optional contents_coverage = contents->GetCoverage(entity); EXPECT_TRUE(result_coverage.has_value()); @@ -442,7 +442,7 @@ TEST_P(GaussianBlurFilterContentsTest, TextureContentsWithEffectTransform) { contents->GetEntity(*renderer, entity, /*coverage_hint=*/{}); EXPECT_TRUE(result.has_value()); if (result.has_value()) { - EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSourceOver); + EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSrcOver); std::optional result_coverage = result.value().GetCoverage(); std::optional contents_coverage = contents->GetCoverage(entity); EXPECT_TRUE(result_coverage.has_value()); diff --git a/engine/src/flutter/impeller/entity/contents/filters/matrix_filter_contents_unittests.cc b/engine/src/flutter/impeller/entity/contents/filters/matrix_filter_contents_unittests.cc index c57ae258fc9..4c33ed379a7 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/matrix_filter_contents_unittests.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/matrix_filter_contents_unittests.cc @@ -91,7 +91,7 @@ void expectRenderCoverageEqual(const std::optional& result, const Rect& expected) { EXPECT_TRUE(result.has_value()); if (result.has_value()) { - EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSourceOver); + EXPECT_EQ(result.value().GetBlendMode(), BlendMode::kSrcOver); std::optional result_coverage = result.value().GetCoverage(); EXPECT_TRUE(result_coverage.has_value()); EXPECT_TRUE(contents_coverage.has_value()); diff --git a/engine/src/flutter/impeller/entity/contents/filters/morphology_filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/morphology_filter_contents.cc index 87c0706deb7..a87d5298c6c 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/morphology_filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/morphology_filter_contents.cc @@ -113,7 +113,7 @@ std::optional DirectionalMorphologyFilterContents::RenderFilter( pass.SetCommandLabel("Morphology Filter"); auto options = OptionsFromPass(pass); options.primitive_type = PrimitiveType::kTriangleStrip; - options.blend_mode = BlendMode::kSource; + options.blend_mode = BlendMode::kSrc; pass.SetPipeline(renderer.GetMorphologyFilterPipeline(options)); pass.SetVertexBuffer(CreateVertexBuffer(vertices, host_buffer)); diff --git a/engine/src/flutter/impeller/entity/contents/framebuffer_blend_contents.cc b/engine/src/flutter/impeller/entity/contents/framebuffer_blend_contents.cc index 74a5d7cedb2..3d8e4cca85d 100644 --- a/engine/src/flutter/impeller/entity/contents/framebuffer_blend_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/framebuffer_blend_contents.cc @@ -63,7 +63,7 @@ bool FramebufferBlendContents::Render(const ContentContext& renderer, }; auto options = OptionsFromPass(pass); - options.blend_mode = BlendMode::kSource; + options.blend_mode = BlendMode::kSrc; options.primitive_type = PrimitiveType::kTriangleStrip; pass.SetCommandLabel("Framebuffer Advanced Blend Filter"); diff --git a/engine/src/flutter/impeller/entity/contents/texture_contents.cc b/engine/src/flutter/impeller/entity/contents/texture_contents.cc index 26637a035be..3e370cdc9de 100644 --- a/engine/src/flutter/impeller/entity/contents/texture_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/texture_contents.cc @@ -156,7 +156,7 @@ bool TextureContents::Render(const ContentContext& renderer, pipeline_options.primitive_type = PrimitiveType::kTriangleStrip; pipeline_options.depth_write_enabled = - stencil_enabled_ && pipeline_options.blend_mode == BlendMode::kSource; + stencil_enabled_ && pipeline_options.blend_mode == BlendMode::kSrc; #ifdef IMPELLER_ENABLE_OPENGLES if (is_external_texture) { diff --git a/engine/src/flutter/impeller/entity/contents/vertices_contents.cc b/engine/src/flutter/impeller/entity/contents/vertices_contents.cc index 4bbe9d9fd99..1406560980a 100644 --- a/engine/src/flutter/impeller/entity/contents/vertices_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/vertices_contents.cc @@ -96,15 +96,14 @@ void VerticesSimpleBlendContents::SetLazyTextureCoverage(Rect rect) { bool VerticesSimpleBlendContents::Render(const ContentContext& renderer, const Entity& entity, RenderPass& pass) const { - FML_DCHECK(texture_ || lazy_texture_ || - blend_mode_ == BlendMode::kDestination); + FML_DCHECK(texture_ || lazy_texture_ || blend_mode_ == BlendMode::kDst); BlendMode blend_mode = blend_mode_; if (!geometry_->HasVertexColors()) { - blend_mode = BlendMode::kSource; + blend_mode = BlendMode::kSrc; } std::shared_ptr texture; - if (blend_mode != BlendMode::kDestination) { + if (blend_mode != BlendMode::kDst) { if (!texture_) { texture = lazy_texture_(renderer); } else { @@ -152,7 +151,7 @@ bool VerticesSimpleBlendContents::Render(const ContentContext& renderer, auto options = OptionsFromPassAndEntity(pass, entity); options.primitive_type = geometry_result.type; auto inverted_blend_mode = - InvertPorterDuffBlend(blend_mode).value_or(BlendMode::kSource); + InvertPorterDuffBlend(blend_mode).value_or(BlendMode::kSrc); pass.SetPipeline( renderer.GetPorterDuffPipeline(inverted_blend_mode, options)); diff --git a/engine/src/flutter/impeller/entity/contents/vertices_contents.h b/engine/src/flutter/impeller/entity/contents/vertices_contents.h index d1a30ec8aa8..2de134ea5ed 100644 --- a/engine/src/flutter/impeller/entity/contents/vertices_contents.h +++ b/engine/src/flutter/impeller/entity/contents/vertices_contents.h @@ -56,7 +56,7 @@ class VerticesSimpleBlendContents final : public Contents { Scalar alpha_ = 1.0; std::shared_ptr geometry_; std::shared_ptr texture_; - BlendMode blend_mode_ = BlendMode::kSource; + BlendMode blend_mode_ = BlendMode::kSrc; SamplerDescriptor descriptor_ = {}; Entity::TileMode tile_mode_x_ = Entity::TileMode::kClamp; Entity::TileMode tile_mode_y_ = Entity::TileMode::kClamp; diff --git a/engine/src/flutter/impeller/entity/entity.cc b/engine/src/flutter/impeller/entity/entity.cc index 92d6a10201c..e3c1f34f5dc 100644 --- a/engine/src/flutter/impeller/entity/entity.cc +++ b/engine/src/flutter/impeller/entity/entity.cc @@ -106,9 +106,8 @@ bool Entity::SetInheritedOpacity(Scalar alpha) { if (alpha >= 1.0) { return true; } - if (blend_mode_ == BlendMode::kSource && - contents_->IsOpaque(GetTransform())) { - blend_mode_ = BlendMode::kSourceOver; + if (blend_mode_ == BlendMode::kSrc && contents_->IsOpaque(GetTransform())) { + blend_mode_ = BlendMode::kSrcOver; } contents_->SetInheritedOpacity(alpha); return true; @@ -128,12 +127,12 @@ std::optional Entity::AsBackgroundColor(ISize target_size) const { bool Entity::IsBlendModeDestructive(BlendMode blend_mode) { switch (blend_mode) { case BlendMode::kClear: - case BlendMode::kSource: - case BlendMode::kSourceIn: - case BlendMode::kDestinationIn: - case BlendMode::kSourceOut: - case BlendMode::kDestinationOut: - case BlendMode::kDestinationATop: + case BlendMode::kSrc: + case BlendMode::kSrcIn: + case BlendMode::kDstIn: + case BlendMode::kSrcOut: + case BlendMode::kDstOut: + case BlendMode::kDstATop: case BlendMode::kXor: case BlendMode::kModulate: return true; diff --git a/engine/src/flutter/impeller/entity/entity.h b/engine/src/flutter/impeller/entity/entity.h index dd3cc6ad447..1d8cd80e8c7 100644 --- a/engine/src/flutter/impeller/entity/entity.h +++ b/engine/src/flutter/impeller/entity/entity.h @@ -65,7 +65,7 @@ class Entity { /// @brief Create an entity that can be used to render a given snapshot. static Entity FromSnapshot(const Snapshot& snapshot, - BlendMode blend_mode = BlendMode::kSourceOver); + BlendMode blend_mode = BlendMode::kSrcOver); Entity(); @@ -123,7 +123,7 @@ class Entity { Matrix transform_; std::shared_ptr contents_; - BlendMode blend_mode_ = BlendMode::kSourceOver; + BlendMode blend_mode_ = BlendMode::kSrcOver; uint32_t clip_depth_ = 1u; }; diff --git a/engine/src/flutter/impeller/entity/entity_unittests.cc b/engine/src/flutter/impeller/entity/entity_unittests.cc index 66b22708098..e4d3cb8c175 100644 --- a/engine/src/flutter/impeller/entity/entity_unittests.cc +++ b/engine/src/flutter/impeller/entity/entity_unittests.cc @@ -712,36 +712,36 @@ TEST_P(EntityTest, BlendingModeOptions) { case BlendMode::kClear: blend_mode_names.push_back("Clear"); blend_mode_values.push_back(BlendMode::kClear); - case BlendMode::kSource: + case BlendMode::kSrc: blend_mode_names.push_back("Source"); - blend_mode_values.push_back(BlendMode::kSource); - case BlendMode::kDestination: + blend_mode_values.push_back(BlendMode::kSrc); + case BlendMode::kDst: blend_mode_names.push_back("Destination"); - blend_mode_values.push_back(BlendMode::kDestination); - case BlendMode::kSourceOver: + blend_mode_values.push_back(BlendMode::kDst); + case BlendMode::kSrcOver: blend_mode_names.push_back("SourceOver"); - blend_mode_values.push_back(BlendMode::kSourceOver); - case BlendMode::kDestinationOver: + blend_mode_values.push_back(BlendMode::kSrcOver); + case BlendMode::kDstOver: blend_mode_names.push_back("DestinationOver"); - blend_mode_values.push_back(BlendMode::kDestinationOver); - case BlendMode::kSourceIn: + blend_mode_values.push_back(BlendMode::kDstOver); + case BlendMode::kSrcIn: blend_mode_names.push_back("SourceIn"); - blend_mode_values.push_back(BlendMode::kSourceIn); - case BlendMode::kDestinationIn: + blend_mode_values.push_back(BlendMode::kSrcIn); + case BlendMode::kDstIn: blend_mode_names.push_back("DestinationIn"); - blend_mode_values.push_back(BlendMode::kDestinationIn); - case BlendMode::kSourceOut: + blend_mode_values.push_back(BlendMode::kDstIn); + case BlendMode::kSrcOut: blend_mode_names.push_back("SourceOut"); - blend_mode_values.push_back(BlendMode::kSourceOut); - case BlendMode::kDestinationOut: + blend_mode_values.push_back(BlendMode::kSrcOut); + case BlendMode::kDstOut: blend_mode_names.push_back("DestinationOut"); - blend_mode_values.push_back(BlendMode::kDestinationOut); - case BlendMode::kSourceATop: + blend_mode_values.push_back(BlendMode::kDstOut); + case BlendMode::kSrcATop: blend_mode_names.push_back("SourceATop"); - blend_mode_values.push_back(BlendMode::kSourceATop); - case BlendMode::kDestinationATop: + blend_mode_values.push_back(BlendMode::kSrcATop); + case BlendMode::kDstATop: blend_mode_names.push_back("DestinationATop"); - blend_mode_values.push_back(BlendMode::kDestinationATop); + blend_mode_values.push_back(BlendMode::kDstATop); case BlendMode::kXor: blend_mode_names.push_back("Xor"); blend_mode_values.push_back(BlendMode::kXor); @@ -818,7 +818,7 @@ TEST_P(EntityTest, BlendingModeOptions) { pass.GetRenderTargetSize().height), Color(), BlendMode::kClear); result = result && draw_rect(Rect::MakeLTRB(a.x, a.y, b.x, b.y), color1, - BlendMode::kSourceOver); + BlendMode::kSrcOver); result = result && draw_rect(Rect::MakeLTRB(c.x, c.y, d.x, d.y), color2, selected_mode); return result; @@ -1188,7 +1188,7 @@ TEST_P(EntityTest, MorphologyFilter) { TEST_P(EntityTest, SetBlendMode) { Entity entity; - ASSERT_EQ(entity.GetBlendMode(), BlendMode::kSourceOver); + ASSERT_EQ(entity.GetBlendMode(), BlendMode::kSrcOver); entity.SetBlendMode(BlendMode::kClear); ASSERT_EQ(entity.GetBlendMode(), BlendMode::kClear); } @@ -1891,7 +1891,7 @@ TEST_P(EntityTest, ColorFilterWithForegroundColorClearBlend) { TEST_P(EntityTest, ColorFilterWithForegroundColorSrcBlend) { auto image = CreateTextureForFixture("boston.jpg"); auto filter = ColorFilterContents::MakeBlend( - BlendMode::kSource, FilterInput::Make({image}), Color::Red()); + BlendMode::kSrc, FilterInput::Make({image}), Color::Red()); auto callback = [&](ContentContext& context, RenderPass& pass) -> bool { Entity entity; @@ -1907,7 +1907,7 @@ TEST_P(EntityTest, ColorFilterWithForegroundColorSrcBlend) { TEST_P(EntityTest, ColorFilterWithForegroundColorDstBlend) { auto image = CreateTextureForFixture("boston.jpg"); auto filter = ColorFilterContents::MakeBlend( - BlendMode::kDestination, FilterInput::Make({image}), Color::Red()); + BlendMode::kDst, FilterInput::Make({image}), Color::Red()); auto callback = [&](ContentContext& context, RenderPass& pass) -> bool { Entity entity; @@ -1923,7 +1923,7 @@ TEST_P(EntityTest, ColorFilterWithForegroundColorDstBlend) { TEST_P(EntityTest, ColorFilterWithForegroundColorSrcInBlend) { auto image = CreateTextureForFixture("boston.jpg"); auto filter = ColorFilterContents::MakeBlend( - BlendMode::kSourceIn, FilterInput::Make({image}), Color::Red()); + BlendMode::kSrcIn, FilterInput::Make({image}), Color::Red()); auto callback = [&](ContentContext& context, RenderPass& pass) -> bool { Entity entity; @@ -2103,8 +2103,8 @@ TEST_P(EntityTest, ColorFilterContentsWithLargeGeometry) { dst_contents->SetColor(Color::Blue()); auto contents = ColorFilterContents::MakeBlend( - BlendMode::kSourceOver, {FilterInput::Make(dst_contents, false), - FilterInput::Make(src_contents, false)}); + BlendMode::kSrcOver, {FilterInput::Make(dst_contents, false), + FilterInput::Make(src_contents, false)}); entity.SetContents(std::move(contents)); ASSERT_TRUE(OpenPlaygroundHere(std::move(entity))); } diff --git a/engine/src/flutter/impeller/geometry/color.cc b/engine/src/flutter/impeller/geometry/color.cc index fc0c6241e60..aa77cda7e68 100644 --- a/engine/src/flutter/impeller/geometry/color.cc +++ b/engine/src/flutter/impeller/geometry/color.cc @@ -31,7 +31,7 @@ static constexpr inline bool ValidateBlendModes() { IMPELLER_FOR_EACH_BLEND_MODE(_IMPELLER_ASSERT_BLEND_MODE) // Ensure the total number of blend modes match. if (i - 1 != - static_cast>(BlendMode::kLast)) { + static_cast>(BlendMode::kLastMode)) { return false; } return true; @@ -160,36 +160,36 @@ Color Color::Blend(Color src, BlendMode blend_mode) const { switch (blend_mode) { case BlendMode::kClear: return Color::BlackTransparent(); - case BlendMode::kSource: + case BlendMode::kSrc: return src; - case BlendMode::kDestination: + case BlendMode::kDst: return dst; - case BlendMode::kSourceOver: + case BlendMode::kSrcOver: // r = s + (1-sa)*d return (src.Premultiply() + dst.Premultiply() * (1 - src.alpha)) .Unpremultiply(); - case BlendMode::kDestinationOver: + case BlendMode::kDstOver: // r = d + (1-da)*s return (dst.Premultiply() + src.Premultiply() * (1 - dst.alpha)) .Unpremultiply(); - case BlendMode::kSourceIn: + case BlendMode::kSrcIn: // r = s * da return (src.Premultiply() * dst.alpha).Unpremultiply(); - case BlendMode::kDestinationIn: + case BlendMode::kDstIn: // r = d * sa return (dst.Premultiply() * src.alpha).Unpremultiply(); - case BlendMode::kSourceOut: + case BlendMode::kSrcOut: // r = s * ( 1- da) return (src.Premultiply() * (1 - dst.alpha)).Unpremultiply(); - case BlendMode::kDestinationOut: + case BlendMode::kDstOut: // r = d * (1-sa) return (dst.Premultiply() * (1 - src.alpha)).Unpremultiply(); - case BlendMode::kSourceATop: + case BlendMode::kSrcATop: // r = s*da + d*(1-sa) return (src.Premultiply() * dst.alpha + dst.Premultiply() * (1 - src.alpha)) .Unpremultiply(); - case BlendMode::kDestinationATop: + case BlendMode::kDstATop: // r = d*sa + s*(1-da) return (dst.Premultiply() * src.alpha + src.Premultiply() * (1 - dst.alpha)) diff --git a/engine/src/flutter/impeller/geometry/color.h b/engine/src/flutter/impeller/geometry/color.h index b4e4005fe47..57c7c88e0c5 100644 --- a/engine/src/flutter/impeller/geometry/color.h +++ b/engine/src/flutter/impeller/geometry/color.h @@ -18,16 +18,16 @@ #define IMPELLER_FOR_EACH_BLEND_MODE(V) \ V(Clear) \ - V(Source) \ - V(Destination) \ - V(SourceOver) \ - V(DestinationOver) \ - V(SourceIn) \ - V(DestinationIn) \ - V(SourceOut) \ - V(DestinationOut) \ - V(SourceATop) \ - V(DestinationATop) \ + V(Src) \ + V(Dst) \ + V(SrcOver) \ + V(DstOver) \ + V(SrcIn) \ + V(DstIn) \ + V(SrcOut) \ + V(DstOut) \ + V(SrcATop) \ + V(DstATop) \ V(Xor) \ V(Plus) \ V(Modulate) \ @@ -59,16 +59,16 @@ enum class BlendMode : uint8_t { // The following blend modes are able to be used as pipeline blend modes or // via `BlendFilterContents`. kClear = 0, - kSource, - kDestination, - kSourceOver, - kDestinationOver, - kSourceIn, - kDestinationIn, - kSourceOut, - kDestinationOut, - kSourceATop, - kDestinationATop, + kSrc, + kDst, + kSrcOver, + kDstOver, + kSrcIn, + kDstIn, + kSrcOut, + kDstOut, + kSrcATop, + kDstATop, kXor, kPlus, kModulate, @@ -92,7 +92,8 @@ enum class BlendMode : uint8_t { kColor, kLuminosity, - kLast = kLuminosity, + kLastMode = kLuminosity, + kDefaultMode = kSrcOver, }; const char* BlendModeToString(BlendMode blend_mode); @@ -929,6 +930,12 @@ inline std::ostream& operator<<(std::ostream& out, const impeller::Color& c) { return out; } +inline std::ostream& operator<<(std::ostream& out, + const impeller::BlendMode& mode) { + out << "BlendMode::k" << BlendModeToString(mode); + return out; +} + } // namespace std #endif // FLUTTER_IMPELLER_GEOMETRY_COLOR_H_ diff --git a/engine/src/flutter/impeller/geometry/geometry_unittests.cc b/engine/src/flutter/impeller/geometry/geometry_unittests.cc index 1f30d464585..0e85fb6c6fc 100644 --- a/engine/src/flutter/impeller/geometry/geometry_unittests.cc +++ b/engine/src/flutter/impeller/geometry/geometry_unittests.cc @@ -1565,16 +1565,16 @@ const std::map ColorBlendTestData::kExpectedResults[sizeof( ColorBlendTestData::kSourceColors)] = { { {BlendMode::kClear, {0, 0, 0, 0}}, - {BlendMode::kSource, {1, 1, 1, 0.75}}, - {BlendMode::kDestination, {0.392157, 0.584314, 0.929412, 0.75}}, - {BlendMode::kSourceOver, {0.878431, 0.916863, 0.985882, 0.9375}}, - {BlendMode::kDestinationOver, {0.513726, 0.667451, 0.943529, 0.9375}}, - {BlendMode::kSourceIn, {1, 1, 1, 0.5625}}, - {BlendMode::kDestinationIn, {0.392157, 0.584314, 0.929412, 0.5625}}, - {BlendMode::kSourceOut, {1, 1, 1, 0.1875}}, - {BlendMode::kDestinationOut, {0.392157, 0.584314, 0.929412, 0.1875}}, - {BlendMode::kSourceATop, {0.848039, 0.896078, 0.982353, 0.75}}, - {BlendMode::kDestinationATop, {0.544118, 0.688235, 0.947059, 0.75}}, + {BlendMode::kSrc, {1, 1, 1, 0.75}}, + {BlendMode::kDst, {0.392157, 0.584314, 0.929412, 0.75}}, + {BlendMode::kSrcOver, {0.878431, 0.916863, 0.985882, 0.9375}}, + {BlendMode::kDstOver, {0.513726, 0.667451, 0.943529, 0.9375}}, + {BlendMode::kSrcIn, {1, 1, 1, 0.5625}}, + {BlendMode::kDstIn, {0.392157, 0.584314, 0.929412, 0.5625}}, + {BlendMode::kSrcOut, {1, 1, 1, 0.1875}}, + {BlendMode::kDstOut, {0.392157, 0.584314, 0.929412, 0.1875}}, + {BlendMode::kSrcATop, {0.848039, 0.896078, 0.982353, 0.75}}, + {BlendMode::kDstATop, {0.544118, 0.688235, 0.947059, 0.75}}, {BlendMode::kXor, {0.696078, 0.792157, 0.964706, 0.375}}, {BlendMode::kPlus, {1, 1, 1, 1}}, {BlendMode::kModulate, {0.392157, 0.584314, 0.929412, 0.5625}}, @@ -1596,16 +1596,16 @@ const std::map ColorBlendTestData::kExpectedResults[sizeof( }, { {BlendMode::kClear, {0, 0, 0, 0}}, - {BlendMode::kSource, {0.196078, 0.803922, 0.196078, 0.75}}, - {BlendMode::kDestination, {0.392157, 0.584314, 0.929412, 0.75}}, - {BlendMode::kSourceOver, {0.235294, 0.76, 0.342745, 0.9375}}, - {BlendMode::kDestinationOver, {0.352941, 0.628235, 0.782745, 0.9375}}, - {BlendMode::kSourceIn, {0.196078, 0.803922, 0.196078, 0.5625}}, - {BlendMode::kDestinationIn, {0.392157, 0.584314, 0.929412, 0.5625}}, - {BlendMode::kSourceOut, {0.196078, 0.803922, 0.196078, 0.1875}}, - {BlendMode::kDestinationOut, {0.392157, 0.584314, 0.929412, 0.1875}}, - {BlendMode::kSourceATop, {0.245098, 0.74902, 0.379412, 0.75}}, - {BlendMode::kDestinationATop, {0.343137, 0.639216, 0.746078, 0.75}}, + {BlendMode::kSrc, {0.196078, 0.803922, 0.196078, 0.75}}, + {BlendMode::kDst, {0.392157, 0.584314, 0.929412, 0.75}}, + {BlendMode::kSrcOver, {0.235294, 0.76, 0.342745, 0.9375}}, + {BlendMode::kDstOver, {0.352941, 0.628235, 0.782745, 0.9375}}, + {BlendMode::kSrcIn, {0.196078, 0.803922, 0.196078, 0.5625}}, + {BlendMode::kDstIn, {0.392157, 0.584314, 0.929412, 0.5625}}, + {BlendMode::kSrcOut, {0.196078, 0.803922, 0.196078, 0.1875}}, + {BlendMode::kDstOut, {0.392157, 0.584314, 0.929412, 0.1875}}, + {BlendMode::kSrcATop, {0.245098, 0.74902, 0.379412, 0.75}}, + {BlendMode::kDstATop, {0.343137, 0.639216, 0.746078, 0.75}}, {BlendMode::kXor, {0.294118, 0.694118, 0.562745, 0.375}}, {BlendMode::kPlus, {0.441176, 1, 0.844118, 1}}, {BlendMode::kModulate, {0.0768935, 0.469742, 0.182238, 0.5625}}, @@ -1627,16 +1627,16 @@ const std::map ColorBlendTestData::kExpectedResults[sizeof( }, { {BlendMode::kClear, {0, 0, 0, 0}}, - {BlendMode::kSource, {0, 0, 0, 0.75}}, - {BlendMode::kDestination, {0.392157, 0.584314, 0.929412, 0.75}}, - {BlendMode::kSourceOver, {0.0784314, 0.116863, 0.185882, 0.9375}}, - {BlendMode::kDestinationOver, {0.313726, 0.467451, 0.743529, 0.9375}}, - {BlendMode::kSourceIn, {0, 0, 0, 0.5625}}, - {BlendMode::kDestinationIn, {0.392157, 0.584314, 0.929412, 0.5625}}, - {BlendMode::kSourceOut, {0, 0, 0, 0.1875}}, - {BlendMode::kDestinationOut, {0.392157, 0.584314, 0.929412, 0.1875}}, - {BlendMode::kSourceATop, {0.0980392, 0.146078, 0.232353, 0.75}}, - {BlendMode::kDestinationATop, {0.294118, 0.438235, 0.697059, 0.75}}, + {BlendMode::kSrc, {0, 0, 0, 0.75}}, + {BlendMode::kDst, {0.392157, 0.584314, 0.929412, 0.75}}, + {BlendMode::kSrcOver, {0.0784314, 0.116863, 0.185882, 0.9375}}, + {BlendMode::kDstOver, {0.313726, 0.467451, 0.743529, 0.9375}}, + {BlendMode::kSrcIn, {0, 0, 0, 0.5625}}, + {BlendMode::kDstIn, {0.392157, 0.584314, 0.929412, 0.5625}}, + {BlendMode::kSrcOut, {0, 0, 0, 0.1875}}, + {BlendMode::kDstOut, {0.392157, 0.584314, 0.929412, 0.1875}}, + {BlendMode::kSrcATop, {0.0980392, 0.146078, 0.232353, 0.75}}, + {BlendMode::kDstATop, {0.294118, 0.438235, 0.697059, 0.75}}, {BlendMode::kXor, {0.196078, 0.292157, 0.464706, 0.375}}, {BlendMode::kPlus, {0.294118, 0.438235, 0.697059, 1}}, {BlendMode::kModulate, {0, 0, 0, 0.5625}}, @@ -1708,7 +1708,7 @@ TEST(GeometryTest, ColorBlendReturnsExpectedResults) { TEST(GeometryTest, BlendModeToString) { using BlendT = std::underlying_type_t; - for (BlendT i = 0; i <= static_cast(BlendMode::kLast); i++) { + for (BlendT i = 0; i <= static_cast(BlendMode::kLastMode); i++) { auto mode = static_cast(i); auto result = BlendModeToString(mode); switch (mode) { IMPELLER_FOR_EACH_BLEND_MODE(_BLEND_MODE_NAME_CHECK) } diff --git a/engine/src/flutter/impeller/toolkit/interop/formats.h b/engine/src/flutter/impeller/toolkit/interop/formats.h index a96e04aafda..e90dd92e270 100644 --- a/engine/src/flutter/impeller/toolkit/interop/formats.h +++ b/engine/src/flutter/impeller/toolkit/interop/formats.h @@ -126,25 +126,25 @@ constexpr flutter::DlBlendMode ToDisplayListType(BlendMode mode) { switch (mode) { case BlendMode::kClear: return Mode::kClear; - case BlendMode::kSource: + case BlendMode::kSrc: return Mode::kSrc; - case BlendMode::kDestination: + case BlendMode::kDst: return Mode::kDst; - case BlendMode::kSourceOver: + case BlendMode::kSrcOver: return Mode::kSrcOver; - case BlendMode::kDestinationOver: + case BlendMode::kDstOver: return Mode::kDstOver; - case BlendMode::kSourceIn: + case BlendMode::kSrcIn: return Mode::kSrcIn; - case BlendMode::kDestinationIn: + case BlendMode::kDstIn: return Mode::kDstIn; - case BlendMode::kSourceOut: + case BlendMode::kSrcOut: return Mode::kSrcOut; - case BlendMode::kDestinationOut: + case BlendMode::kDstOut: return Mode::kDstOut; - case BlendMode::kSourceATop: + case BlendMode::kSrcATop: return Mode::kSrcATop; - case BlendMode::kDestinationATop: + case BlendMode::kDstATop: return Mode::kDstATop; case BlendMode::kXor: return Mode::kXor; @@ -298,25 +298,25 @@ constexpr BlendMode ToImpellerType(ImpellerBlendMode mode) { case kImpellerBlendModeClear: return BlendMode::kClear; case kImpellerBlendModeSource: - return BlendMode::kSource; + return BlendMode::kSrc; case kImpellerBlendModeDestination: - return BlendMode::kDestination; + return BlendMode::kDst; case kImpellerBlendModeSourceOver: - return BlendMode::kSourceOver; + return BlendMode::kSrcOver; case kImpellerBlendModeDestinationOver: - return BlendMode::kDestinationOver; + return BlendMode::kDstOver; case kImpellerBlendModeSourceIn: - return BlendMode::kSourceIn; + return BlendMode::kSrcIn; case kImpellerBlendModeDestinationIn: - return BlendMode::kDestinationIn; + return BlendMode::kDstIn; case kImpellerBlendModeSourceOut: - return BlendMode::kSourceOut; + return BlendMode::kSrcOut; case kImpellerBlendModeDestinationOut: - return BlendMode::kDestinationOut; + return BlendMode::kDstOut; case kImpellerBlendModeSourceATop: - return BlendMode::kSourceATop; + return BlendMode::kSrcATop; case kImpellerBlendModeDestinationATop: - return BlendMode::kDestinationATop; + return BlendMode::kDstATop; case kImpellerBlendModeXor: return BlendMode::kXor; case kImpellerBlendModePlus: @@ -354,7 +354,7 @@ constexpr BlendMode ToImpellerType(ImpellerBlendMode mode) { case kImpellerBlendModeLuminosity: return BlendMode::kLuminosity; } - return BlendMode::kSourceOver; + return BlendMode::kSrcOver; } constexpr flutter::DlDrawStyle ToDisplayListType(ImpellerDrawStyle style) { diff --git a/engine/src/flutter/testing/display_list_testing.cc b/engine/src/flutter/testing/display_list_testing.cc index 1fa32453874..f921a68fe3f 100644 --- a/engine/src/flutter/testing/display_list_testing.cc +++ b/engine/src/flutter/testing/display_list_testing.cc @@ -107,44 +107,6 @@ std::ostream& operator<<(std::ostream& os, const DlPaint& paint) { #define DLT_OSTREAM_CASE(enum_name, value_name) \ case enum_name::k##value_name: return os << #enum_name "::k" #value_name -std::ostream& operator<<(std::ostream& os, const DlBlendMode& mode) { - switch (mode) { - DLT_OSTREAM_CASE(DlBlendMode, Clear); - DLT_OSTREAM_CASE(DlBlendMode, Src); - DLT_OSTREAM_CASE(DlBlendMode, Dst); - DLT_OSTREAM_CASE(DlBlendMode, SrcOver); - DLT_OSTREAM_CASE(DlBlendMode, DstOver); - DLT_OSTREAM_CASE(DlBlendMode, SrcIn); - DLT_OSTREAM_CASE(DlBlendMode, DstIn); - DLT_OSTREAM_CASE(DlBlendMode, SrcOut); - DLT_OSTREAM_CASE(DlBlendMode, DstOut); - DLT_OSTREAM_CASE(DlBlendMode, SrcATop); - DLT_OSTREAM_CASE(DlBlendMode, DstATop); - DLT_OSTREAM_CASE(DlBlendMode, Xor); - DLT_OSTREAM_CASE(DlBlendMode, Plus); - DLT_OSTREAM_CASE(DlBlendMode, Modulate); - DLT_OSTREAM_CASE(DlBlendMode, Screen); - - DLT_OSTREAM_CASE(DlBlendMode, Overlay); - DLT_OSTREAM_CASE(DlBlendMode, Darken); - DLT_OSTREAM_CASE(DlBlendMode, Lighten); - DLT_OSTREAM_CASE(DlBlendMode, ColorDodge); - DLT_OSTREAM_CASE(DlBlendMode, ColorBurn); - DLT_OSTREAM_CASE(DlBlendMode, HardLight); - DLT_OSTREAM_CASE(DlBlendMode, SoftLight); - DLT_OSTREAM_CASE(DlBlendMode, Difference); - DLT_OSTREAM_CASE(DlBlendMode, Exclusion); - DLT_OSTREAM_CASE(DlBlendMode, Multiply); - - DLT_OSTREAM_CASE(DlBlendMode, Hue); - DLT_OSTREAM_CASE(DlBlendMode, Saturation); - DLT_OSTREAM_CASE(DlBlendMode, Color); - DLT_OSTREAM_CASE(DlBlendMode, Luminosity); - } - // Not a valid enum, should never happen, but in case we encounter bad data. - return os << "DlBlendMode::????"; -} - extern std::ostream& operator<<(std::ostream& os, const flutter::DisplayListOpType& type) { switch (type) { diff --git a/engine/src/flutter/testing/display_list_testing.h b/engine/src/flutter/testing/display_list_testing.h index 18ff7a94c50..7b53354a57b 100644 --- a/engine/src/flutter/testing/display_list_testing.h +++ b/engine/src/flutter/testing/display_list_testing.h @@ -44,8 +44,6 @@ extern std::ostream& operator<<(std::ostream& os, const flutter::DisplayList& display_list); extern std::ostream& operator<<(std::ostream& os, const flutter::DlPaint& paint); -extern std::ostream& operator<<(std::ostream& os, - const flutter::DlBlendMode& mode); extern std::ostream& operator<<(std::ostream& os, const flutter::DlClipOp& op); extern std::ostream& operator<<(std::ostream& os, const flutter::DlPointMode& op); diff --git a/engine/src/flutter/testing/impeller_golden_tests_output.txt b/engine/src/flutter/testing/impeller_golden_tests_output.txt index 32bcc2e45e2..a4e7071fec4 100644 --- a/engine/src/flutter/testing/impeller_golden_tests_output.txt +++ b/engine/src/flutter/testing/impeller_golden_tests_output.txt @@ -24,24 +24,24 @@ impeller_Play_AiksTest_BlendModeColor_Vulkan.png impeller_Play_AiksTest_BlendModeDarken_Metal.png impeller_Play_AiksTest_BlendModeDarken_OpenGLES.png impeller_Play_AiksTest_BlendModeDarken_Vulkan.png -impeller_Play_AiksTest_BlendModeDestinationATop_Metal.png -impeller_Play_AiksTest_BlendModeDestinationATop_OpenGLES.png -impeller_Play_AiksTest_BlendModeDestinationATop_Vulkan.png -impeller_Play_AiksTest_BlendModeDestinationIn_Metal.png -impeller_Play_AiksTest_BlendModeDestinationIn_OpenGLES.png -impeller_Play_AiksTest_BlendModeDestinationIn_Vulkan.png -impeller_Play_AiksTest_BlendModeDestinationOut_Metal.png -impeller_Play_AiksTest_BlendModeDestinationOut_OpenGLES.png -impeller_Play_AiksTest_BlendModeDestinationOut_Vulkan.png -impeller_Play_AiksTest_BlendModeDestinationOver_Metal.png -impeller_Play_AiksTest_BlendModeDestinationOver_OpenGLES.png -impeller_Play_AiksTest_BlendModeDestinationOver_Vulkan.png -impeller_Play_AiksTest_BlendModeDestination_Metal.png -impeller_Play_AiksTest_BlendModeDestination_OpenGLES.png -impeller_Play_AiksTest_BlendModeDestination_Vulkan.png impeller_Play_AiksTest_BlendModeDifference_Metal.png impeller_Play_AiksTest_BlendModeDifference_OpenGLES.png impeller_Play_AiksTest_BlendModeDifference_Vulkan.png +impeller_Play_AiksTest_BlendModeDstATop_Metal.png +impeller_Play_AiksTest_BlendModeDstATop_OpenGLES.png +impeller_Play_AiksTest_BlendModeDstATop_Vulkan.png +impeller_Play_AiksTest_BlendModeDstIn_Metal.png +impeller_Play_AiksTest_BlendModeDstIn_OpenGLES.png +impeller_Play_AiksTest_BlendModeDstIn_Vulkan.png +impeller_Play_AiksTest_BlendModeDstOut_Metal.png +impeller_Play_AiksTest_BlendModeDstOut_OpenGLES.png +impeller_Play_AiksTest_BlendModeDstOut_Vulkan.png +impeller_Play_AiksTest_BlendModeDstOver_Metal.png +impeller_Play_AiksTest_BlendModeDstOver_OpenGLES.png +impeller_Play_AiksTest_BlendModeDstOver_Vulkan.png +impeller_Play_AiksTest_BlendModeDst_Metal.png +impeller_Play_AiksTest_BlendModeDst_OpenGLES.png +impeller_Play_AiksTest_BlendModeDst_Vulkan.png impeller_Play_AiksTest_BlendModeExclusion_Metal.png impeller_Play_AiksTest_BlendModeExclusion_OpenGLES.png impeller_Play_AiksTest_BlendModeExclusion_Vulkan.png @@ -83,21 +83,9 @@ impeller_Play_AiksTest_BlendModeShouldCoverWholeScreen_Vulkan.png impeller_Play_AiksTest_BlendModeSoftLight_Metal.png impeller_Play_AiksTest_BlendModeSoftLight_OpenGLES.png impeller_Play_AiksTest_BlendModeSoftLight_Vulkan.png -impeller_Play_AiksTest_BlendModeSourceATop_Metal.png -impeller_Play_AiksTest_BlendModeSourceATop_OpenGLES.png -impeller_Play_AiksTest_BlendModeSourceATop_Vulkan.png -impeller_Play_AiksTest_BlendModeSourceIn_Metal.png -impeller_Play_AiksTest_BlendModeSourceIn_OpenGLES.png -impeller_Play_AiksTest_BlendModeSourceIn_Vulkan.png -impeller_Play_AiksTest_BlendModeSourceOut_Metal.png -impeller_Play_AiksTest_BlendModeSourceOut_OpenGLES.png -impeller_Play_AiksTest_BlendModeSourceOut_Vulkan.png -impeller_Play_AiksTest_BlendModeSourceOver_Metal.png -impeller_Play_AiksTest_BlendModeSourceOver_OpenGLES.png -impeller_Play_AiksTest_BlendModeSourceOver_Vulkan.png -impeller_Play_AiksTest_BlendModeSource_Metal.png -impeller_Play_AiksTest_BlendModeSource_OpenGLES.png -impeller_Play_AiksTest_BlendModeSource_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcATop_Metal.png +impeller_Play_AiksTest_BlendModeSrcATop_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcATop_Vulkan.png impeller_Play_AiksTest_BlendModeSrcAlphaClear_Metal.png impeller_Play_AiksTest_BlendModeSrcAlphaClear_OpenGLES.png impeller_Play_AiksTest_BlendModeSrcAlphaClear_Vulkan.png @@ -113,24 +101,24 @@ impeller_Play_AiksTest_BlendModeSrcAlphaColor_Vulkan.png impeller_Play_AiksTest_BlendModeSrcAlphaDarken_Metal.png impeller_Play_AiksTest_BlendModeSrcAlphaDarken_OpenGLES.png impeller_Play_AiksTest_BlendModeSrcAlphaDarken_Vulkan.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationATop_Metal.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationATop_OpenGLES.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationATop_Vulkan.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationIn_Metal.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationIn_OpenGLES.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationIn_Vulkan.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationOut_Metal.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationOut_OpenGLES.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationOut_Vulkan.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationOver_Metal.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationOver_OpenGLES.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestinationOver_Vulkan.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestination_Metal.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestination_OpenGLES.png -impeller_Play_AiksTest_BlendModeSrcAlphaDestination_Vulkan.png impeller_Play_AiksTest_BlendModeSrcAlphaDifference_Metal.png impeller_Play_AiksTest_BlendModeSrcAlphaDifference_OpenGLES.png impeller_Play_AiksTest_BlendModeSrcAlphaDifference_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstATop_Metal.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstATop_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstATop_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstIn_Metal.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstIn_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstIn_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstOut_Metal.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstOut_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstOut_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstOver_Metal.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstOver_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcAlphaDstOver_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcAlphaDst_Metal.png +impeller_Play_AiksTest_BlendModeSrcAlphaDst_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcAlphaDst_Vulkan.png impeller_Play_AiksTest_BlendModeSrcAlphaExclusion_Metal.png impeller_Play_AiksTest_BlendModeSrcAlphaExclusion_OpenGLES.png impeller_Play_AiksTest_BlendModeSrcAlphaExclusion_Vulkan.png @@ -167,24 +155,36 @@ impeller_Play_AiksTest_BlendModeSrcAlphaScreen_Vulkan.png impeller_Play_AiksTest_BlendModeSrcAlphaSoftLight_Metal.png impeller_Play_AiksTest_BlendModeSrcAlphaSoftLight_OpenGLES.png impeller_Play_AiksTest_BlendModeSrcAlphaSoftLight_Vulkan.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceATop_Metal.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceATop_OpenGLES.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceATop_Vulkan.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceIn_Metal.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceIn_OpenGLES.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceIn_Vulkan.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceOut_Metal.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceOut_OpenGLES.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceOut_Vulkan.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceOver_Metal.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceOver_OpenGLES.png -impeller_Play_AiksTest_BlendModeSrcAlphaSourceOver_Vulkan.png -impeller_Play_AiksTest_BlendModeSrcAlphaSource_Metal.png -impeller_Play_AiksTest_BlendModeSrcAlphaSource_OpenGLES.png -impeller_Play_AiksTest_BlendModeSrcAlphaSource_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcATop_Metal.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcATop_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcATop_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcIn_Metal.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcIn_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcIn_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcOut_Metal.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcOut_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcOut_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcOver_Metal.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcOver_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrcOver_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrc_Metal.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrc_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcAlphaSrc_Vulkan.png impeller_Play_AiksTest_BlendModeSrcAlphaXor_Metal.png impeller_Play_AiksTest_BlendModeSrcAlphaXor_OpenGLES.png impeller_Play_AiksTest_BlendModeSrcAlphaXor_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcIn_Metal.png +impeller_Play_AiksTest_BlendModeSrcIn_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcIn_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcOut_Metal.png +impeller_Play_AiksTest_BlendModeSrcOut_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcOut_Vulkan.png +impeller_Play_AiksTest_BlendModeSrcOver_Metal.png +impeller_Play_AiksTest_BlendModeSrcOver_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrcOver_Vulkan.png +impeller_Play_AiksTest_BlendModeSrc_Metal.png +impeller_Play_AiksTest_BlendModeSrc_OpenGLES.png +impeller_Play_AiksTest_BlendModeSrc_Vulkan.png impeller_Play_AiksTest_BlendModeXor_Metal.png impeller_Play_AiksTest_BlendModeXor_OpenGLES.png impeller_Play_AiksTest_BlendModeXor_Vulkan.png