[Impeller] read from framebuffer for advanced blends on iOS. (flutter/engine#39567)
* [impeller] read from framebuffer for advanced blends * ++ * update to contents * move to separate contents * ++ * set stencil depth duh * ++ * ++ * remove debug info * update licenses * Add FML_OS_PHYSICAL_IOS * ++ * ++
This commit is contained in:
@@ -1156,6 +1156,8 @@ ORIGIN: ../../../flutter/impeller/entity/contents/filters/srgb_to_linear_filter_
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/filters/srgb_to_linear_filter_contents.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/framebuffer_blend_contents.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/framebuffer_blend_contents.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/gradient_generator.cc + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/gradient_generator.h + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/contents/linear_gradient_contents.cc + ../../../flutter/LICENSE
|
||||
@@ -1211,6 +1213,23 @@ ORIGIN: ../../../flutter/impeller/entity/shaders/blending/advanced_blend_screen.
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/advanced_blend_softlight.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/blend.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/blend.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend.glsl + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_color.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_colorburn.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_colordodge.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_darken.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_difference.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_exclusion.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_hardlight.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_hue.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_lighten.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_luminosity.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_multiply.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_overlay.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_saturation.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_screen.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_softlight.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/border_mask_blur.frag + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/border_mask_blur.vert + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/impeller/entity/shaders/color_matrix_color_filter.frag + ../../../flutter/LICENSE
|
||||
@@ -3634,6 +3653,8 @@ FILE: ../../../flutter/impeller/entity/contents/filters/srgb_to_linear_filter_co
|
||||
FILE: ../../../flutter/impeller/entity/contents/filters/srgb_to_linear_filter_contents.h
|
||||
FILE: ../../../flutter/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.cc
|
||||
FILE: ../../../flutter/impeller/entity/contents/filters/yuv_to_rgb_filter_contents.h
|
||||
FILE: ../../../flutter/impeller/entity/contents/framebuffer_blend_contents.cc
|
||||
FILE: ../../../flutter/impeller/entity/contents/framebuffer_blend_contents.h
|
||||
FILE: ../../../flutter/impeller/entity/contents/gradient_generator.cc
|
||||
FILE: ../../../flutter/impeller/entity/contents/gradient_generator.h
|
||||
FILE: ../../../flutter/impeller/entity/contents/linear_gradient_contents.cc
|
||||
@@ -3689,6 +3710,23 @@ FILE: ../../../flutter/impeller/entity/shaders/blending/advanced_blend_screen.fr
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/advanced_blend_softlight.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/blend.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/blend.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend.glsl
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_color.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_colorburn.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_colordodge.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_darken.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_difference.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_exclusion.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_hardlight.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_hue.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_lighten.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_luminosity.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_multiply.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_overlay.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_saturation.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_screen.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/blending/ios/framebuffer_blend_softlight.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/border_mask_blur.frag
|
||||
FILE: ../../../flutter/impeller/entity/shaders/border_mask_blur.vert
|
||||
FILE: ../../../flutter/impeller/entity/shaders/color_matrix_color_filter.frag
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
||||
#define FML_OS_IOS 1
|
||||
#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
||||
#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
|
||||
#define FML_OS_IOS_SIMULATOR 1
|
||||
#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
||||
#elif defined(__linux__)
|
||||
#define FML_OS_LINUX 1
|
||||
// include a system header to pull in features.h for glibc/uclibc macros.
|
||||
@@ -97,4 +100,10 @@
|
||||
#error Please add support for your architecture in flutter/fml/build_config.h
|
||||
#endif
|
||||
|
||||
#if defined(FML_OS_IOS)
|
||||
#if !defined(FML_OS_IOS_SIMULATOR)
|
||||
#define FML_OS_PHYSICAL_IOS 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // FLUTTER_FML_BUILD_CONFIG_H_
|
||||
|
||||
@@ -35,6 +35,7 @@ static CompilerBackend CreateMSLCompiler(const spirv_cross::ParsedIR& ir,
|
||||
// Metal to AIR must be updated as well.
|
||||
sl_options.msl_version =
|
||||
spirv_cross::CompilerMSL::Options::make_msl_version(1, 2);
|
||||
sl_options.use_framebuffer_fetch_subpasses = true;
|
||||
sl_compiler->set_msl_options(sl_options);
|
||||
|
||||
// Sort the float and sampler uniforms according to their declared/decorated
|
||||
|
||||
@@ -77,6 +77,26 @@ impeller_shaders("modern_entity_shaders") {
|
||||
"shaders/radial_gradient_ssbo_fill.frag",
|
||||
"shaders/sweep_gradient_ssbo_fill.frag",
|
||||
]
|
||||
if (is_ios && !use_ios_simulator) {
|
||||
shaders += [
|
||||
"shaders/blending/ios/framebuffer_blend.vert",
|
||||
"shaders/blending/ios/framebuffer_blend_color.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_colorburn.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_colordodge.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_darken.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_difference.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_exclusion.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_hardlight.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_hue.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_lighten.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_luminosity.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_multiply.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_overlay.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_saturation.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_screen.frag",
|
||||
"shaders/blending/ios/framebuffer_blend_softlight.frag",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
impeller_component("entity") {
|
||||
@@ -159,6 +179,13 @@ impeller_component("entity") {
|
||||
"inline_pass_context.h",
|
||||
]
|
||||
|
||||
if (is_ios && !use_ios_simulator) {
|
||||
sources += [
|
||||
"contents/framebuffer_blend_contents.cc",
|
||||
"contents/framebuffer_blend_contents.h",
|
||||
]
|
||||
}
|
||||
|
||||
public_deps = [
|
||||
":entity_shaders",
|
||||
":modern_entity_shaders",
|
||||
|
||||
@@ -172,12 +172,7 @@ ContentContext::ContentContext(std::shared_ptr<Context> context)
|
||||
sweep_gradient_ssbo_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<SweepGradientSSBOFillPipeline>(*context_);
|
||||
}
|
||||
sweep_gradient_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<SweepGradientFillPipeline>(*context_);
|
||||
rrect_blur_pipelines_[{}] =
|
||||
CreateDefaultPipeline<RRectBlurPipeline>(*context_);
|
||||
texture_blend_pipelines_[{}] =
|
||||
CreateDefaultPipeline<BlendPipeline>(*context_);
|
||||
|
||||
blend_color_pipelines_[{}] =
|
||||
CreateDefaultPipeline<BlendColorPipeline>(*context_);
|
||||
blend_colorburn_pipelines_[{}] =
|
||||
@@ -207,6 +202,45 @@ ContentContext::ContentContext(std::shared_ptr<Context> context)
|
||||
CreateDefaultPipeline<BlendScreenPipeline>(*context_);
|
||||
blend_softlight_pipelines_[{}] =
|
||||
CreateDefaultPipeline<BlendSoftLightPipeline>(*context_);
|
||||
#if FML_OS_PHYSICAL_IOS
|
||||
framebuffer_blend_color_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendColorPipeline>(*context_);
|
||||
framebuffer_blend_colorburn_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendColorBurnPipeline>(*context_);
|
||||
framebuffer_blend_colordodge_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendColorDodgePipeline>(*context_);
|
||||
framebuffer_blend_darken_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendDarkenPipeline>(*context_);
|
||||
framebuffer_blend_difference_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendDifferencePipeline>(*context_);
|
||||
framebuffer_blend_exclusion_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendExclusionPipeline>(*context_);
|
||||
framebuffer_blend_hardlight_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendHardLightPipeline>(*context_);
|
||||
framebuffer_blend_hue_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendHuePipeline>(*context_);
|
||||
framebuffer_blend_lighten_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendLightenPipeline>(*context_);
|
||||
framebuffer_blend_luminosity_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendLuminosityPipeline>(*context_);
|
||||
framebuffer_blend_multiply_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendMultiplyPipeline>(*context_);
|
||||
framebuffer_blend_overlay_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendOverlayPipeline>(*context_);
|
||||
framebuffer_blend_saturation_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendSaturationPipeline>(*context_);
|
||||
framebuffer_blend_screen_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendScreenPipeline>(*context_);
|
||||
framebuffer_blend_softlight_pipelines_[{}] =
|
||||
CreateDefaultPipeline<FramebufferBlendSoftLightPipeline>(*context_);
|
||||
#endif // FML_OS_PHYSICAL_IOS
|
||||
|
||||
sweep_gradient_fill_pipelines_[{}] =
|
||||
CreateDefaultPipeline<SweepGradientFillPipeline>(*context_);
|
||||
rrect_blur_pipelines_[{}] =
|
||||
CreateDefaultPipeline<RRectBlurPipeline>(*context_);
|
||||
texture_blend_pipelines_[{}] =
|
||||
CreateDefaultPipeline<BlendPipeline>(*context_);
|
||||
texture_pipelines_[{}] = CreateDefaultPipeline<TexturePipeline>(*context_);
|
||||
tiled_texture_pipelines_[{}] =
|
||||
CreateDefaultPipeline<TiledTexturePipeline>(*context_);
|
||||
|
||||
@@ -11,22 +11,6 @@
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "impeller/base/validation.h"
|
||||
#include "impeller/entity/advanced_blend.vert.h"
|
||||
#include "impeller/entity/advanced_blend_color.frag.h"
|
||||
#include "impeller/entity/advanced_blend_colorburn.frag.h"
|
||||
#include "impeller/entity/advanced_blend_colordodge.frag.h"
|
||||
#include "impeller/entity/advanced_blend_darken.frag.h"
|
||||
#include "impeller/entity/advanced_blend_difference.frag.h"
|
||||
#include "impeller/entity/advanced_blend_exclusion.frag.h"
|
||||
#include "impeller/entity/advanced_blend_hardlight.frag.h"
|
||||
#include "impeller/entity/advanced_blend_hue.frag.h"
|
||||
#include "impeller/entity/advanced_blend_lighten.frag.h"
|
||||
#include "impeller/entity/advanced_blend_luminosity.frag.h"
|
||||
#include "impeller/entity/advanced_blend_multiply.frag.h"
|
||||
#include "impeller/entity/advanced_blend_overlay.frag.h"
|
||||
#include "impeller/entity/advanced_blend_saturation.frag.h"
|
||||
#include "impeller/entity/advanced_blend_screen.frag.h"
|
||||
#include "impeller/entity/advanced_blend_softlight.frag.h"
|
||||
#include "impeller/entity/blend.frag.h"
|
||||
#include "impeller/entity/blend.vert.h"
|
||||
#include "impeller/entity/border_mask_blur.frag.h"
|
||||
@@ -78,6 +62,41 @@
|
||||
#include "impeller/entity/radial_gradient_ssbo_fill.frag.h"
|
||||
#include "impeller/entity/sweep_gradient_ssbo_fill.frag.h"
|
||||
|
||||
#include "impeller/entity/advanced_blend.vert.h"
|
||||
#include "impeller/entity/advanced_blend_color.frag.h"
|
||||
#include "impeller/entity/advanced_blend_colorburn.frag.h"
|
||||
#include "impeller/entity/advanced_blend_colordodge.frag.h"
|
||||
#include "impeller/entity/advanced_blend_darken.frag.h"
|
||||
#include "impeller/entity/advanced_blend_difference.frag.h"
|
||||
#include "impeller/entity/advanced_blend_exclusion.frag.h"
|
||||
#include "impeller/entity/advanced_blend_hardlight.frag.h"
|
||||
#include "impeller/entity/advanced_blend_hue.frag.h"
|
||||
#include "impeller/entity/advanced_blend_lighten.frag.h"
|
||||
#include "impeller/entity/advanced_blend_luminosity.frag.h"
|
||||
#include "impeller/entity/advanced_blend_multiply.frag.h"
|
||||
#include "impeller/entity/advanced_blend_overlay.frag.h"
|
||||
#include "impeller/entity/advanced_blend_saturation.frag.h"
|
||||
#include "impeller/entity/advanced_blend_screen.frag.h"
|
||||
#include "impeller/entity/advanced_blend_softlight.frag.h"
|
||||
#if FML_OS_PHYSICAL_IOS
|
||||
#include "impeller/entity/framebuffer_blend.vert.h"
|
||||
#include "impeller/entity/framebuffer_blend_color.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_colorburn.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_colordodge.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_darken.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_difference.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_exclusion.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_hardlight.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_hue.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_lighten.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_luminosity.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_multiply.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_overlay.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_saturation.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_screen.frag.h"
|
||||
#include "impeller/entity/framebuffer_blend_softlight.frag.h"
|
||||
#endif // FML_OS_PHYSICAL_IOS
|
||||
|
||||
namespace impeller {
|
||||
|
||||
using LinearGradientFillPipeline =
|
||||
@@ -101,6 +120,45 @@ using BlendPipeline = RenderPipelineT<BlendVertexShader, BlendFragmentShader>;
|
||||
using RRectBlurPipeline =
|
||||
RenderPipelineT<RrectBlurVertexShader, RrectBlurFragmentShader>;
|
||||
using BlendPipeline = RenderPipelineT<BlendVertexShader, BlendFragmentShader>;
|
||||
using TexturePipeline =
|
||||
RenderPipelineT<TextureFillVertexShader, TextureFillFragmentShader>;
|
||||
using TiledTexturePipeline = RenderPipelineT<TiledTextureFillVertexShader,
|
||||
TiledTextureFillFragmentShader>;
|
||||
using GaussianBlurPipeline =
|
||||
RenderPipelineT<GaussianBlurVertexShader, GaussianBlurFragmentShader>;
|
||||
using GaussianBlurDecalPipeline =
|
||||
RenderPipelineT<GaussianBlurVertexShader, GaussianBlurDecalFragmentShader>;
|
||||
using BorderMaskBlurPipeline =
|
||||
RenderPipelineT<BorderMaskBlurVertexShader, BorderMaskBlurFragmentShader>;
|
||||
using MorphologyFilterPipeline =
|
||||
RenderPipelineT<MorphologyFilterVertexShader,
|
||||
MorphologyFilterFragmentShader>;
|
||||
using ColorMatrixColorFilterPipeline =
|
||||
RenderPipelineT<ColorMatrixColorFilterVertexShader,
|
||||
ColorMatrixColorFilterFragmentShader>;
|
||||
using LinearToSrgbFilterPipeline =
|
||||
RenderPipelineT<LinearToSrgbFilterVertexShader,
|
||||
LinearToSrgbFilterFragmentShader>;
|
||||
using SrgbToLinearFilterPipeline =
|
||||
RenderPipelineT<SrgbToLinearFilterVertexShader,
|
||||
SrgbToLinearFilterFragmentShader>;
|
||||
using GlyphAtlasPipeline =
|
||||
RenderPipelineT<GlyphAtlasVertexShader, GlyphAtlasFragmentShader>;
|
||||
using GlyphAtlasSdfPipeline =
|
||||
RenderPipelineT<GlyphAtlasSdfVertexShader, GlyphAtlasSdfFragmentShader>;
|
||||
// Instead of requiring new shaders for clips, the solid fill stages are used
|
||||
// to redirect writing to the stencil instead of color attachments.
|
||||
using ClipPipeline =
|
||||
RenderPipelineT<SolidFillVertexShader, SolidFillFragmentShader>;
|
||||
|
||||
using GeometryPositionPipeline =
|
||||
RenderPipelineT<PositionVertexShader, VerticesFragmentShader>;
|
||||
using GeometryColorPipeline =
|
||||
RenderPipelineT<PositionColorVertexShader, VerticesFragmentShader>;
|
||||
using YUVToRGBFilterPipeline =
|
||||
RenderPipelineT<YuvToRgbFilterVertexShader, YuvToRgbFilterFragmentShader>;
|
||||
|
||||
// Advanced blends
|
||||
using BlendColorPipeline = RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendColorFragmentShader>;
|
||||
using BlendColorBurnPipeline =
|
||||
@@ -142,43 +200,54 @@ using BlendScreenPipeline = RenderPipelineT<AdvancedBlendVertexShader,
|
||||
using BlendSoftLightPipeline =
|
||||
RenderPipelineT<AdvancedBlendVertexShader,
|
||||
AdvancedBlendSoftlightFragmentShader>;
|
||||
using TexturePipeline =
|
||||
RenderPipelineT<TextureFillVertexShader, TextureFillFragmentShader>;
|
||||
using TiledTexturePipeline = RenderPipelineT<TiledTextureFillVertexShader,
|
||||
TiledTextureFillFragmentShader>;
|
||||
using GaussianBlurPipeline =
|
||||
RenderPipelineT<GaussianBlurVertexShader, GaussianBlurFragmentShader>;
|
||||
using GaussianBlurDecalPipeline =
|
||||
RenderPipelineT<GaussianBlurVertexShader, GaussianBlurDecalFragmentShader>;
|
||||
using BorderMaskBlurPipeline =
|
||||
RenderPipelineT<BorderMaskBlurVertexShader, BorderMaskBlurFragmentShader>;
|
||||
using MorphologyFilterPipeline =
|
||||
RenderPipelineT<MorphologyFilterVertexShader,
|
||||
MorphologyFilterFragmentShader>;
|
||||
using ColorMatrixColorFilterPipeline =
|
||||
RenderPipelineT<ColorMatrixColorFilterVertexShader,
|
||||
ColorMatrixColorFilterFragmentShader>;
|
||||
using LinearToSrgbFilterPipeline =
|
||||
RenderPipelineT<LinearToSrgbFilterVertexShader,
|
||||
LinearToSrgbFilterFragmentShader>;
|
||||
using SrgbToLinearFilterPipeline =
|
||||
RenderPipelineT<SrgbToLinearFilterVertexShader,
|
||||
SrgbToLinearFilterFragmentShader>;
|
||||
using GlyphAtlasPipeline =
|
||||
RenderPipelineT<GlyphAtlasVertexShader, GlyphAtlasFragmentShader>;
|
||||
using GlyphAtlasSdfPipeline =
|
||||
RenderPipelineT<GlyphAtlasSdfVertexShader, GlyphAtlasSdfFragmentShader>;
|
||||
// Instead of requiring new shaders for clips, the solid fill stages are used
|
||||
// to redirect writing to the stencil instead of color attachments.
|
||||
using ClipPipeline =
|
||||
RenderPipelineT<SolidFillVertexShader, SolidFillFragmentShader>;
|
||||
|
||||
using GeometryPositionPipeline =
|
||||
RenderPipelineT<PositionVertexShader, VerticesFragmentShader>;
|
||||
using GeometryColorPipeline =
|
||||
RenderPipelineT<PositionColorVertexShader, VerticesFragmentShader>;
|
||||
using YUVToRGBFilterPipeline =
|
||||
RenderPipelineT<YuvToRgbFilterVertexShader, YuvToRgbFilterFragmentShader>;
|
||||
#if FML_OS_PHYSICAL_IOS
|
||||
// iOS only advanced blends.
|
||||
using FramebufferBlendColorPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendColorFragmentShader>;
|
||||
using FramebufferBlendColorBurnPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendColorburnFragmentShader>;
|
||||
using FramebufferBlendColorDodgePipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendColordodgeFragmentShader>;
|
||||
using FramebufferBlendDarkenPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendDarkenFragmentShader>;
|
||||
using FramebufferBlendDifferencePipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendDifferenceFragmentShader>;
|
||||
using FramebufferBlendExclusionPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendExclusionFragmentShader>;
|
||||
using FramebufferBlendHardLightPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendHardlightFragmentShader>;
|
||||
using FramebufferBlendHuePipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendHueFragmentShader>;
|
||||
using FramebufferBlendLightenPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendLightenFragmentShader>;
|
||||
using FramebufferBlendLuminosityPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendLuminosityFragmentShader>;
|
||||
using FramebufferBlendMultiplyPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendMultiplyFragmentShader>;
|
||||
using FramebufferBlendOverlayPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendOverlayFragmentShader>;
|
||||
using FramebufferBlendSaturationPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendSaturationFragmentShader>;
|
||||
using FramebufferBlendScreenPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendScreenFragmentShader>;
|
||||
using FramebufferBlendSoftLightPipeline =
|
||||
RenderPipelineT<FramebufferBlendVertexShader,
|
||||
FramebufferBlendSoftlightFragmentShader>;
|
||||
#endif // FML_OS_PHYSICAL_IOS
|
||||
|
||||
/// Pipeline state configuration.
|
||||
///
|
||||
@@ -438,6 +507,83 @@ class ContentContext {
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(blend_softlight_pipelines_, opts);
|
||||
}
|
||||
#if FML_OS_PHYSICAL_IOS
|
||||
// iOS advanced blends.
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendColorPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_color_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendColorBurnPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_colorburn_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendColorDodgePipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_colordodge_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendDarkenPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_darken_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendDifferencePipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_difference_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendExclusionPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_exclusion_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendHardLightPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_hardlight_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetFramebufferBlendHuePipeline(
|
||||
ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_hue_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendLightenPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_lighten_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendLuminosityPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_luminosity_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendMultiplyPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_multiply_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendOverlayPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_overlay_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendSaturationPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_saturation_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendScreenPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_screen_pipelines_, opts);
|
||||
}
|
||||
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>>
|
||||
GetFramebufferBlendSoftLightPipeline(ContentContextOptions opts) const {
|
||||
return GetPipeline(framebuffer_blend_softlight_pipelines_, opts);
|
||||
}
|
||||
#endif // FML_OS_PHYSICAL_IOS
|
||||
|
||||
std::shared_ptr<Context> GetContext() const;
|
||||
|
||||
@@ -510,6 +656,38 @@ class ContentContext {
|
||||
mutable Variants<BlendSaturationPipeline> blend_saturation_pipelines_;
|
||||
mutable Variants<BlendScreenPipeline> blend_screen_pipelines_;
|
||||
mutable Variants<BlendSoftLightPipeline> blend_softlight_pipelines_;
|
||||
#if FML_OS_PHYSICAL_IOS
|
||||
mutable Variants<FramebufferBlendColorPipeline>
|
||||
framebuffer_blend_color_pipelines_;
|
||||
mutable Variants<FramebufferBlendColorBurnPipeline>
|
||||
framebuffer_blend_colorburn_pipelines_;
|
||||
mutable Variants<FramebufferBlendColorDodgePipeline>
|
||||
framebuffer_blend_colordodge_pipelines_;
|
||||
mutable Variants<FramebufferBlendDarkenPipeline>
|
||||
framebuffer_blend_darken_pipelines_;
|
||||
mutable Variants<FramebufferBlendDifferencePipeline>
|
||||
framebuffer_blend_difference_pipelines_;
|
||||
mutable Variants<FramebufferBlendExclusionPipeline>
|
||||
framebuffer_blend_exclusion_pipelines_;
|
||||
mutable Variants<FramebufferBlendHardLightPipeline>
|
||||
framebuffer_blend_hardlight_pipelines_;
|
||||
mutable Variants<FramebufferBlendHuePipeline>
|
||||
framebuffer_blend_hue_pipelines_;
|
||||
mutable Variants<FramebufferBlendLightenPipeline>
|
||||
framebuffer_blend_lighten_pipelines_;
|
||||
mutable Variants<FramebufferBlendLuminosityPipeline>
|
||||
framebuffer_blend_luminosity_pipelines_;
|
||||
mutable Variants<FramebufferBlendMultiplyPipeline>
|
||||
framebuffer_blend_multiply_pipelines_;
|
||||
mutable Variants<FramebufferBlendOverlayPipeline>
|
||||
framebuffer_blend_overlay_pipelines_;
|
||||
mutable Variants<FramebufferBlendSaturationPipeline>
|
||||
framebuffer_blend_saturation_pipelines_;
|
||||
mutable Variants<FramebufferBlendScreenPipeline>
|
||||
framebuffer_blend_screen_pipelines_;
|
||||
mutable Variants<FramebufferBlendSoftLightPipeline>
|
||||
framebuffer_blend_softlight_pipelines_;
|
||||
#endif // FML_OS_PHYSICAL_IOS
|
||||
|
||||
template <class TypedPipeline>
|
||||
std::shared_ptr<Pipeline<PipelineDescriptor>> GetPipeline(
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
// 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 "framebuffer_blend_contents.h"
|
||||
|
||||
#include "impeller/entity/contents/content_context.h"
|
||||
#include "impeller/renderer/render_pass.h"
|
||||
#include "impeller/renderer/sampler_library.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
FramebufferBlendContents::FramebufferBlendContents() = default;
|
||||
|
||||
FramebufferBlendContents::~FramebufferBlendContents() = default;
|
||||
|
||||
void FramebufferBlendContents::SetBlendMode(BlendMode blend_mode) {
|
||||
blend_mode_ = blend_mode;
|
||||
}
|
||||
|
||||
void FramebufferBlendContents::SetChildContents(
|
||||
std::shared_ptr<Contents> child_contents) {
|
||||
child_contents_ = std::move(child_contents);
|
||||
}
|
||||
|
||||
// |Contents|
|
||||
std::optional<Rect> FramebufferBlendContents::GetCoverage(
|
||||
const Entity& entity) const {
|
||||
return child_contents_->GetCoverage(entity);
|
||||
}
|
||||
|
||||
bool FramebufferBlendContents::Render(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const {
|
||||
using VS = FramebufferBlendScreenPipeline::VertexShader;
|
||||
using FS = FramebufferBlendScreenPipeline::FragmentShader;
|
||||
|
||||
auto& host_buffer = pass.GetTransientsBuffer();
|
||||
|
||||
auto src_snapshot = child_contents_->RenderToSnapshot(renderer, entity);
|
||||
if (!src_snapshot.has_value()) {
|
||||
return true;
|
||||
}
|
||||
auto coverage = src_snapshot->GetCoverage();
|
||||
if (!coverage.has_value()) {
|
||||
return true;
|
||||
}
|
||||
Rect src_coverage = coverage.value();
|
||||
auto maybe_src_uvs = src_snapshot->GetCoverageUVs(src_coverage);
|
||||
if (!maybe_src_uvs.has_value()) {
|
||||
return true;
|
||||
}
|
||||
std::array<Point, 4> src_uvs = maybe_src_uvs.value();
|
||||
|
||||
auto size = src_coverage.size;
|
||||
VertexBufferBuilder<VS::PerVertexData> vtx_builder;
|
||||
vtx_builder.AddVertices({
|
||||
{Point(0, 0), src_uvs[0]},
|
||||
{Point(size.width, 0), src_uvs[1]},
|
||||
{Point(size.width, size.height), src_uvs[3]},
|
||||
{Point(0, 0), src_uvs[0]},
|
||||
{Point(size.width, size.height), src_uvs[3]},
|
||||
{Point(0, size.height), src_uvs[2]},
|
||||
});
|
||||
auto vtx_buffer = vtx_builder.CreateVertexBuffer(host_buffer);
|
||||
|
||||
auto options = OptionsFromPass(pass);
|
||||
options.blend_mode = BlendMode::kSource;
|
||||
|
||||
Command cmd;
|
||||
cmd.label = "Framebuffer Advanced Blend Filter";
|
||||
cmd.BindVertices(vtx_buffer);
|
||||
cmd.stencil_reference = entity.GetStencilDepth();
|
||||
|
||||
switch (blend_mode_) {
|
||||
case BlendMode::kScreen:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendScreenPipeline(options);
|
||||
break;
|
||||
case BlendMode::kOverlay:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendOverlayPipeline(options);
|
||||
break;
|
||||
case BlendMode::kDarken:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendDarkenPipeline(options);
|
||||
break;
|
||||
case BlendMode::kLighten:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendLightenPipeline(options);
|
||||
break;
|
||||
case BlendMode::kColorDodge:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendColorDodgePipeline(options);
|
||||
break;
|
||||
case BlendMode::kColorBurn:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendColorBurnPipeline(options);
|
||||
break;
|
||||
case BlendMode::kHardLight:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendHardLightPipeline(options);
|
||||
break;
|
||||
case BlendMode::kSoftLight:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendSoftLightPipeline(options);
|
||||
break;
|
||||
case BlendMode::kDifference:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendDifferencePipeline(options);
|
||||
break;
|
||||
case BlendMode::kExclusion:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendExclusionPipeline(options);
|
||||
break;
|
||||
case BlendMode::kMultiply:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendMultiplyPipeline(options);
|
||||
break;
|
||||
case BlendMode::kHue:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendHuePipeline(options);
|
||||
break;
|
||||
case BlendMode::kSaturation:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendSaturationPipeline(options);
|
||||
break;
|
||||
case BlendMode::kColor:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendColorPipeline(options);
|
||||
break;
|
||||
case BlendMode::kLuminosity:
|
||||
cmd.pipeline = renderer.GetFramebufferBlendLuminosityPipeline(options);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
FS::BlendInfo blend_info;
|
||||
VS::FrameInfo frame_info;
|
||||
|
||||
auto src_sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler(
|
||||
src_snapshot->sampler_descriptor);
|
||||
FS::BindTextureSamplerSrc(cmd, src_snapshot->texture, src_sampler);
|
||||
blend_info.src_y_coord_scale = src_snapshot->texture->GetYCoordScale();
|
||||
|
||||
auto blend_uniform = host_buffer.EmplaceUniform(blend_info);
|
||||
FS::BindBlendInfo(cmd, blend_uniform);
|
||||
|
||||
frame_info.mvp = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) *
|
||||
src_snapshot->transform;
|
||||
|
||||
auto uniform_view = host_buffer.EmplaceUniform(frame_info);
|
||||
VS::BindFrameInfo(cmd, uniform_view);
|
||||
|
||||
return pass.AddCommand(cmd);
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
@@ -0,0 +1,43 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/impeller/renderer/texture.h"
|
||||
#include "impeller/entity/contents/color_source_contents.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class FramebufferBlendContents final : public ColorSourceContents {
|
||||
public:
|
||||
FramebufferBlendContents();
|
||||
|
||||
~FramebufferBlendContents() override;
|
||||
|
||||
void SetBlendMode(BlendMode blend_mode);
|
||||
|
||||
void SetChildContents(std::shared_ptr<Contents> child_contents);
|
||||
|
||||
private:
|
||||
// |Contents|
|
||||
std::optional<Rect> GetCoverage(const Entity& entity) const override;
|
||||
|
||||
// |Contents|
|
||||
bool Render(const ContentContext& renderer,
|
||||
const Entity& entity,
|
||||
RenderPass& pass) const override;
|
||||
|
||||
BlendMode blend_mode_;
|
||||
std::shared_ptr<Contents> child_contents_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(FramebufferBlendContents);
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
@@ -16,6 +16,9 @@
|
||||
#include "impeller/entity/contents/content_context.h"
|
||||
#include "impeller/entity/contents/filters/color_filter_contents.h"
|
||||
#include "impeller/entity/contents/filters/inputs/filter_input.h"
|
||||
#if FML_OS_PHYSICAL_IOS
|
||||
#include "impeller/entity/contents/framebuffer_blend_contents.h"
|
||||
#endif
|
||||
#include "impeller/entity/contents/texture_contents.h"
|
||||
#include "impeller/entity/entity.h"
|
||||
#include "impeller/entity/inline_pass_context.h"
|
||||
@@ -41,9 +44,11 @@ void EntityPass::SetDelegate(std::unique_ptr<EntityPassDelegate> delegate) {
|
||||
}
|
||||
|
||||
void EntityPass::AddEntity(Entity entity) {
|
||||
#ifndef FML_OS_PHYSICAL_IOS
|
||||
if (entity.GetBlendMode() > Entity::kLastPipelineBlendMode) {
|
||||
reads_from_pass_texture_ += 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
elements_.emplace_back(std::move(entity));
|
||||
}
|
||||
@@ -134,10 +139,16 @@ EntityPass* EntityPass::AddSubpass(std::unique_ptr<EntityPass> pass) {
|
||||
FML_DCHECK(pass->superpass_ == nullptr);
|
||||
pass->superpass_ = this;
|
||||
|
||||
#if FML_OS_PHYSICAL_IOS
|
||||
if (pass->backdrop_filter_proc_.has_value()) {
|
||||
reads_from_pass_texture_ += 1;
|
||||
}
|
||||
#else
|
||||
if (pass->blend_mode_ > Entity::kLastPipelineBlendMode ||
|
||||
pass->backdrop_filter_proc_.has_value()) {
|
||||
reads_from_pass_texture_ += 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
auto subpass_pointer = pass.get();
|
||||
elements_.emplace_back(std::move(pass));
|
||||
@@ -527,6 +538,15 @@ bool EntityPass::OnRender(
|
||||
///
|
||||
|
||||
if (result.entity.GetBlendMode() > Entity::kLastPipelineBlendMode) {
|
||||
#if FML_OS_PHYSICAL_IOS
|
||||
auto src_contents = result.entity.GetContents();
|
||||
auto contents = std::make_shared<FramebufferBlendContents>();
|
||||
contents->SetChildContents(src_contents);
|
||||
contents->SetBlendMode(result.entity.GetBlendMode());
|
||||
result.entity.SetContents(std::move(contents));
|
||||
result.entity.SetBlendMode(BlendMode::kSource);
|
||||
|
||||
#else
|
||||
// End the active pass and flush the buffer before rendering "advanced"
|
||||
// blends. Advanced blends work by binding the current render target
|
||||
// texture as an input ("destination"), blending with a second texture
|
||||
@@ -536,6 +556,7 @@ bool EntityPass::OnRender(
|
||||
// to the render target texture so far need to execute before it's bound
|
||||
// for blending (otherwise the blend pass will end up executing before
|
||||
// all the previous commands in the active pass).
|
||||
|
||||
if (!pass_context.EndPass()) {
|
||||
return false;
|
||||
}
|
||||
@@ -556,6 +577,7 @@ bool EntityPass::OnRender(
|
||||
contents->SetCoverageCrop(result.entity.GetCoverage());
|
||||
result.entity.SetContents(std::move(contents));
|
||||
result.entity.SetBlendMode(BlendMode::kSource);
|
||||
#endif // FML_OS_PHYSICAL_IOS
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#version 450
|
||||
|
||||
// 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 <impeller/blending.glsl>
|
||||
#include <impeller/color.glsl>
|
||||
#include <impeller/texture.glsl>
|
||||
#include <impeller/types.glsl>
|
||||
|
||||
#ifdef IMPELLER_TARGET_METAL_IOS
|
||||
layout(set = 0,
|
||||
binding = 0,
|
||||
input_attachment_index = 0) uniform subpassInput uSub;
|
||||
|
||||
vec4 ReadDestination() {
|
||||
return subpassLoad(uSub);
|
||||
}
|
||||
#else
|
||||
|
||||
vec4 ReadDestination() {
|
||||
return vec4(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
uniform BlendInfo {
|
||||
float dst_input_alpha;
|
||||
float src_y_coord_scale;
|
||||
}
|
||||
blend_info;
|
||||
|
||||
uniform sampler2D texture_sampler_src;
|
||||
|
||||
in vec2 v_src_texture_coords;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
vec4 dst_sample = ReadDestination();
|
||||
vec4 dst = IPUnpremultiply(dst_sample);
|
||||
vec4 src = IPUnpremultiply(IPSampleWithTileMode(
|
||||
texture_sampler_src, // sampler
|
||||
v_src_texture_coords, // texture coordinates
|
||||
blend_info.src_y_coord_scale, // y coordinate scale
|
||||
kTileModeDecal // tile mode
|
||||
));
|
||||
|
||||
vec4 blended = vec4(Blend(dst.rgb, src.rgb), 1) * dst.a;
|
||||
|
||||
frag_color = mix(dst_sample, blended, src.a);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// 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 <impeller/types.glsl>
|
||||
|
||||
uniform FrameInfo {
|
||||
mat4 mvp;
|
||||
}
|
||||
frame_info;
|
||||
|
||||
in vec2 vertices;
|
||||
in vec2 src_texture_coords;
|
||||
|
||||
out vec2 v_src_texture_coords;
|
||||
|
||||
void main() {
|
||||
gl_Position = frame_info.mvp * vec4(vertices, 0.0, 1.0);
|
||||
v_src_texture_coords = src_texture_coords;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendColor(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendColorBurn(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendColorDodge(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendDarken(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendDifference(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendExclusion(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendHardLight(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendHue(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendLighten(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendLuminosity(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendMultiply(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendOverlay(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendSaturation(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendScreen(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
@@ -0,0 +1,11 @@
|
||||
// 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 <impeller/blending.glsl>
|
||||
|
||||
vec3 Blend(vec3 dst, vec3 src) {
|
||||
return IPBlendSoftLight(dst, src);
|
||||
}
|
||||
|
||||
#include "framebuffer_blend.glsl"
|
||||
Reference in New Issue
Block a user