Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::ContentContext Class Reference

#include <content_context.h>

Inheritance diagram for impeller::ContentContext:
impeller::testing::FlushTestContentContext

Classes

struct  Pipelines
 

Public Types

using SubpassCallback = std::function< bool(const ContentContext &, RenderPass &)>
 

Public Member Functions

 ContentContext (std::shared_ptr< Context > context, std::shared_ptr< TypographerContext > typographer_context, std::shared_ptr< RenderTargetAllocator > render_target_allocator=nullptr)
 
 ~ContentContext ()
 
bool IsValid () const
 
TessellatorGetTessellator () const
 
PipelineRef GetBlendColorBurnPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendColorDodgePipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendColorPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendDarkenPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendDifferencePipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendExclusionPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendHardLightPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendHuePipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendLightenPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendLuminosityPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendMultiplyPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendOverlayPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendSaturationPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendScreenPipeline (ContentContextOptions opts) const
 
PipelineRef GetBlendSoftLightPipeline (ContentContextOptions opts) const
 
PipelineRef GetBorderMaskBlurPipeline (ContentContextOptions opts) const
 
PipelineRef GetCirclePipeline (ContentContextOptions opts) const
 
PipelineRef GetClearBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetClipPipeline (ContentContextOptions opts) const
 
PipelineRef GetColorMatrixColorFilterPipeline (ContentContextOptions opts) const
 
PipelineRef GetConicalGradientFillPipeline (ContentContextOptions opts, ConicalKind kind) const
 
PipelineRef GetConicalGradientSSBOFillPipeline (ContentContextOptions opts, ConicalKind kind) const
 
PipelineRef GetConicalGradientUniformFillPipeline (ContentContextOptions opts, ConicalKind kind) const
 
PipelineRef GetDestinationATopBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetDestinationBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetDestinationInBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetDestinationOutBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetDestinationOverBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetDownsamplePipeline (ContentContextOptions opts) const
 
PipelineRef GetDrawVerticesUberPipeline (BlendMode blend_mode, ContentContextOptions opts) const
 
PipelineRef GetFastGradientPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendColorBurnPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendColorDodgePipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendColorPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendDarkenPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendDifferencePipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendExclusionPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendHardLightPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendHuePipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendLightenPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendLuminosityPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendMultiplyPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendOverlayPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendSaturationPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendScreenPipeline (ContentContextOptions opts) const
 
PipelineRef GetFramebufferBlendSoftLightPipeline (ContentContextOptions opts) const
 
PipelineRef GetGaussianBlurPipeline (ContentContextOptions opts) const
 
PipelineRef GetGlyphAtlasPipeline (ContentContextOptions opts) const
 
PipelineRef GetLinePipeline (ContentContextOptions opts) const
 
PipelineRef GetLinearGradientFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetLinearGradientSSBOFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetLinearGradientUniformFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetLinearToSrgbFilterPipeline (ContentContextOptions opts) const
 
PipelineRef GetModulateBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetMorphologyFilterPipeline (ContentContextOptions opts) const
 
PipelineRef GetPlusBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetPorterDuffPipeline (BlendMode mode, ContentContextOptions opts) const
 
PipelineRef GetRadialGradientFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetRadialGradientSSBOFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetRadialGradientUniformFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetRRectBlurPipeline (ContentContextOptions opts) const
 
PipelineRef GetRSuperellipseBlurPipeline (ContentContextOptions opts) const
 
PipelineRef GetScreenBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSolidFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetSourceATopBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSourceBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSourceInBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSourceOutBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSourceOverBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetSrgbToLinearFilterPipeline (ContentContextOptions opts) const
 
PipelineRef GetSweepGradientFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetSweepGradientSSBOFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetSweepGradientUniformFillPipeline (ContentContextOptions opts) const
 
PipelineRef GetTexturePipeline (ContentContextOptions opts) const
 
PipelineRef GetTextureStrictSrcPipeline (ContentContextOptions opts) const
 
PipelineRef GetTiledTexturePipeline (ContentContextOptions opts) const
 
PipelineRef GetXorBlendPipeline (ContentContextOptions opts) const
 
PipelineRef GetYUVToRGBFilterPipeline (ContentContextOptions opts) const
 
std::shared_ptr< TextureGetEmptyTexture () const
 
std::shared_ptr< ContextGetContext () const
 
const CapabilitiesGetDeviceCapabilities () const
 
fml::StatusOr< RenderTargetMakeSubpass (std::string_view label, ISize texture_size, const std::shared_ptr< CommandBuffer > &command_buffer, const SubpassCallback &subpass_callback, bool msaa_enabled=true, bool depth_stencil_enabled=false, int32_t mip_count=1) const
 Creates a new texture of size texture_size and calls subpass_callback with a RenderPass for drawing to the texture.
 
fml::StatusOr< RenderTargetMakeSubpass (std::string_view label, const RenderTarget &subpass_target, const std::shared_ptr< CommandBuffer > &command_buffer, const SubpassCallback &subpass_callback) const
 Makes a subpass that will render to subpass_target.
 
const std::shared_ptr< LazyGlyphAtlas > & GetLazyGlyphAtlas () const
 
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache () const
 
PipelineRef GetCachedRuntimeEffectPipeline (const std::string &unique_entrypoint_name, const ContentContextOptions &options, const std::function< std::shared_ptr< Pipeline< PipelineDescriptor > >()> &create_callback) const
 
void ClearCachedRuntimeEffectPipeline (const std::string &unique_entrypoint_name) const
 
HostBufferGetTransientsIndexesBuffer () const
 Retrieve the current host buffer for transient storage of indexes used for indexed draws.
 
HostBufferGetTransientsDataBuffer () const
 Retrieve the current host buffer for transient storage of other non-index data.
 
void ResetTransientsBuffers ()
 Resets the transients buffers held onto by the content context.
 
TextShadowCacheGetTextShadowCache () const
 

Protected Member Functions

void SetTransientsIndexesBuffer (std::shared_ptr< HostBuffer > host_buffer)
 
void SetTransientsDataBuffer (std::shared_ptr< HostBuffer > host_buffer)
 

Detailed Description

Definition at line 138 of file content_context.h.

Member Typedef Documentation

◆ SubpassCallback

Definition at line 245 of file content_context.h.

Constructor & Destructor Documentation

◆ ContentContext()

impeller::ContentContext::ContentContext ( std::shared_ptr< Context context,
std::shared_ptr< TypographerContext typographer_context,
std::shared_ptr< RenderTargetAllocator render_target_allocator = nullptr 
)
explicit

Setup default clip pipeline.

Definition at line 547 of file content_context.cc.

551 : context_(std::move(context)),
552 lazy_glyph_atlas_(
553 std::make_shared<LazyGlyphAtlas>(std::move(typographer_context))),
554 pipelines_(new Pipelines()),
555 tessellator_(std::make_shared<Tessellator>(
556 context_->GetCapabilities()->Supports32BitPrimitiveIndices())),
557 render_target_cache_(render_target_allocator == nullptr
558 ? std::make_shared<RenderTargetCache>(
559 context_->GetResourceAllocator())
560 : std::move(render_target_allocator)),
561 data_host_buffer_(HostBuffer::Create(
562 context_->GetResourceAllocator(),
563 context_->GetIdleWaiter(),
564 context_->GetCapabilities()->GetMinimumUniformAlignment())),
565 text_shadow_cache_(std::make_unique<TextShadowCache>()) {
566 if (!context_ || !context_->IsValid()) {
567 return;
568 }
569
570 // On most backends, indexes and other data can be allocated into the same
571 // buffers. However, some backends (namely WebGL) require indexes used in
572 // indexed draws to be allocated separately from other data. For those
573 // backends, we allocate a separate host buffer just for indexes.
574 indexes_host_buffer_ =
575 context_->GetCapabilities()->NeedsPartitionedHostBuffer()
577 context_->GetResourceAllocator(), context_->GetIdleWaiter(),
578 context_->GetCapabilities()->GetMinimumUniformAlignment())
579 : data_host_buffer_;
580 {
581 TextureDescriptor desc;
582 desc.storage_mode = StorageMode::kDevicePrivate;
583 desc.format = PixelFormat::kR8G8B8A8UNormInt;
584 desc.size = ISize{1, 1};
585 empty_texture_ = GetContext()->GetResourceAllocator()->CreateTexture(desc);
586
587 std::array<uint8_t, 4> data = Color::BlackTransparent().ToR8G8B8A8();
588 std::shared_ptr<CommandBuffer> cmd_buffer =
589 GetContext()->CreateCommandBuffer();
590 std::shared_ptr<BlitPass> blit_pass = cmd_buffer->CreateBlitPass();
591 HostBuffer& data_host_buffer = GetTransientsDataBuffer();
592 BufferView buffer_view = data_host_buffer.Emplace(data);
593 blit_pass->AddCopy(buffer_view, empty_texture_);
594
595 if (!blit_pass->EncodeCommands() || !GetContext()
596 ->GetCommandQueue()
597 ->Submit({std::move(cmd_buffer)})
598 .ok()) {
599 VALIDATION_LOG << "Failed to create empty texture.";
600 }
601 }
602
603 auto options = ContentContextOptions{
604 .sample_count = SampleCount::kCount4,
605 .color_attachment_pixel_format =
606 context_->GetCapabilities()->GetDefaultColorFormat()};
607 auto options_trianglestrip = ContentContextOptions{
608 .sample_count = SampleCount::kCount4,
609 .primitive_type = PrimitiveType::kTriangleStrip,
610 .color_attachment_pixel_format =
611 context_->GetCapabilities()->GetDefaultColorFormat()};
612 auto options_no_msaa_no_depth_stencil = ContentContextOptions{
613 .sample_count = SampleCount::kCount1,
614 .primitive_type = PrimitiveType::kTriangleStrip,
615 .color_attachment_pixel_format =
616 context_->GetCapabilities()->GetDefaultColorFormat(),
617 .has_depth_stencil_attachments = false};
618 const auto supports_decal = static_cast<Scalar>(
619 context_->GetCapabilities()->SupportsDecalSamplerAddressMode());
620
621 // Futures for the following pipelines may block in case the first frame is
622 // rendered without the pipelines being ready. Put pipelines that are more
623 // likely to be used first.
624 {
625 pipelines_->glyph_atlas.CreateDefault(
626 *context_, options,
627 {static_cast<Scalar>(
628 GetContext()->GetCapabilities()->GetDefaultGlyphAtlasFormat() ==
630 pipelines_->solid_fill.CreateDefault(*context_, options);
631 pipelines_->texture.CreateDefault(*context_, options);
632 pipelines_->fast_gradient.CreateDefault(*context_, options);
633 pipelines_->line.CreateDefault(*context_, options);
634 pipelines_->circle.CreateDefault(*context_, options);
635
636 if (context_->GetCapabilities()->SupportsSSBO()) {
637 pipelines_->linear_gradient_ssbo_fill.CreateDefault(*context_, options);
638 pipelines_->radial_gradient_ssbo_fill.CreateDefault(*context_, options);
639 pipelines_->conical_gradient_ssbo_fill.CreateDefault(*context_, options,
640 {3.0});
641 pipelines_->conical_gradient_ssbo_fill_radial.CreateDefault(
642 *context_, options, {1.0});
643 pipelines_->conical_gradient_ssbo_fill_strip.CreateDefault(
644 *context_, options, {2.0});
645 pipelines_->conical_gradient_ssbo_fill_strip_and_radial.CreateDefault(
646 *context_, options, {0.0});
647 pipelines_->sweep_gradient_ssbo_fill.CreateDefault(*context_, options);
648 } else {
649 pipelines_->linear_gradient_uniform_fill.CreateDefault(*context_,
650 options);
651 pipelines_->radial_gradient_uniform_fill.CreateDefault(*context_,
652 options);
653 pipelines_->conical_gradient_uniform_fill.CreateDefault(*context_,
654 options);
655 pipelines_->conical_gradient_uniform_fill_radial.CreateDefault(*context_,
656 options);
657 pipelines_->conical_gradient_uniform_fill_strip.CreateDefault(*context_,
658 options);
659 pipelines_->conical_gradient_uniform_fill_strip_and_radial.CreateDefault(
660 *context_, options);
661 pipelines_->sweep_gradient_uniform_fill.CreateDefault(*context_, options);
662
663 pipelines_->linear_gradient_fill.CreateDefault(*context_, options);
664 pipelines_->radial_gradient_fill.CreateDefault(*context_, options);
665 pipelines_->conical_gradient_fill.CreateDefault(*context_, options);
666 pipelines_->conical_gradient_fill_radial.CreateDefault(*context_,
667 options);
668 pipelines_->conical_gradient_fill_strip.CreateDefault(*context_, options);
669 pipelines_->conical_gradient_fill_strip_and_radial.CreateDefault(
670 *context_, options);
671 pipelines_->sweep_gradient_fill.CreateDefault(*context_, options);
672 }
673
674 /// Setup default clip pipeline.
675 auto clip_pipeline_descriptor =
676 ClipPipeline::Builder::MakeDefaultPipelineDescriptor(*context_);
677 if (!clip_pipeline_descriptor.has_value()) {
678 return;
679 }
680 ContentContextOptions{
681 .sample_count = SampleCount::kCount4,
682 .color_attachment_pixel_format =
683 context_->GetCapabilities()->GetDefaultColorFormat()}
684 .ApplyToPipelineDescriptor(*clip_pipeline_descriptor);
685 // Disable write to all color attachments.
686 auto clip_color_attachments =
687 clip_pipeline_descriptor->GetColorAttachmentDescriptors();
688 for (auto& color_attachment : clip_color_attachments) {
689 color_attachment.second.write_mask = ColorWriteMaskBits::kNone;
690 }
691 clip_pipeline_descriptor->SetColorAttachmentDescriptors(
692 std::move(clip_color_attachments));
693 if (GetContext()->GetFlags().lazy_shader_mode) {
694 pipelines_->clip.SetDefaultDescriptor(clip_pipeline_descriptor);
695 pipelines_->clip.SetDefault(options, nullptr);
696 } else {
697 pipelines_->clip.SetDefault(
698 options,
699 std::make_unique<ClipPipeline>(*context_, clip_pipeline_descriptor));
700 }
701 pipelines_->texture_downsample.CreateDefault(
702 *context_, options_no_msaa_no_depth_stencil);
703 pipelines_->rrect_blur.CreateDefault(*context_, options_trianglestrip);
704 pipelines_->rsuperellipse_blur.CreateDefault(*context_,
705 options_trianglestrip);
706 pipelines_->texture_strict_src.CreateDefault(*context_, options);
707 pipelines_->tiled_texture.CreateDefault(*context_, options,
708 {supports_decal});
709 pipelines_->gaussian_blur.CreateDefault(
710 *context_, options_no_msaa_no_depth_stencil, {supports_decal});
711 pipelines_->border_mask_blur.CreateDefault(*context_,
712 options_trianglestrip);
713 pipelines_->color_matrix_color_filter.CreateDefault(*context_,
714 options_trianglestrip);
715 pipelines_->vertices_uber_1_.CreateDefault(*context_, options,
716 {supports_decal});
717 pipelines_->vertices_uber_2_.CreateDefault(*context_, options,
718 {supports_decal});
719
720 const std::array<std::vector<Scalar>, 15> porter_duff_constants =
721 GetPorterDuffSpecConstants(supports_decal);
722 pipelines_->clear_blend.CreateDefault(*context_, options_trianglestrip,
723 porter_duff_constants[0]);
724 pipelines_->source_blend.CreateDefault(*context_, options_trianglestrip,
725 porter_duff_constants[1]);
726 pipelines_->destination_blend.CreateDefault(
727 *context_, options_trianglestrip, porter_duff_constants[2]);
728 pipelines_->source_over_blend.CreateDefault(
729 *context_, options_trianglestrip, porter_duff_constants[3]);
730 pipelines_->destination_over_blend.CreateDefault(
731 *context_, options_trianglestrip, porter_duff_constants[4]);
732 pipelines_->source_in_blend.CreateDefault(*context_, options_trianglestrip,
733 porter_duff_constants[5]);
734 pipelines_->destination_in_blend.CreateDefault(
735 *context_, options_trianglestrip, porter_duff_constants[6]);
736 pipelines_->source_out_blend.CreateDefault(*context_, options_trianglestrip,
737 porter_duff_constants[7]);
738 pipelines_->destination_out_blend.CreateDefault(
739 *context_, options_trianglestrip, porter_duff_constants[8]);
740 pipelines_->source_a_top_blend.CreateDefault(
741 *context_, options_trianglestrip, porter_duff_constants[9]);
742 pipelines_->destination_a_top_blend.CreateDefault(
743 *context_, options_trianglestrip, porter_duff_constants[10]);
744 pipelines_->xor_blend.CreateDefault(*context_, options_trianglestrip,
745 porter_duff_constants[11]);
746 pipelines_->plus_blend.CreateDefault(*context_, options_trianglestrip,
747 porter_duff_constants[12]);
748 pipelines_->modulate_blend.CreateDefault(*context_, options_trianglestrip,
749 porter_duff_constants[13]);
750 pipelines_->screen_blend.CreateDefault(*context_, options_trianglestrip,
751 porter_duff_constants[14]);
752 }
753
754 if (context_->GetCapabilities()->SupportsFramebufferFetch()) {
755 pipelines_->framebuffer_blend_color.CreateDefault(
756 *context_, options_trianglestrip,
757 {static_cast<Scalar>(BlendSelectValues::kColor), supports_decal});
758 pipelines_->framebuffer_blend_colorburn.CreateDefault(
759 *context_, options_trianglestrip,
760 {static_cast<Scalar>(BlendSelectValues::kColorBurn), supports_decal});
761 pipelines_->framebuffer_blend_colordodge.CreateDefault(
762 *context_, options_trianglestrip,
763 {static_cast<Scalar>(BlendSelectValues::kColorDodge), supports_decal});
764 pipelines_->framebuffer_blend_darken.CreateDefault(
765 *context_, options_trianglestrip,
766 {static_cast<Scalar>(BlendSelectValues::kDarken), supports_decal});
767 pipelines_->framebuffer_blend_difference.CreateDefault(
768 *context_, options_trianglestrip,
769 {static_cast<Scalar>(BlendSelectValues::kDifference), supports_decal});
770 pipelines_->framebuffer_blend_exclusion.CreateDefault(
771 *context_, options_trianglestrip,
772 {static_cast<Scalar>(BlendSelectValues::kExclusion), supports_decal});
773 pipelines_->framebuffer_blend_hardlight.CreateDefault(
774 *context_, options_trianglestrip,
775 {static_cast<Scalar>(BlendSelectValues::kHardLight), supports_decal});
776 pipelines_->framebuffer_blend_hue.CreateDefault(
777 *context_, options_trianglestrip,
778 {static_cast<Scalar>(BlendSelectValues::kHue), supports_decal});
779 pipelines_->framebuffer_blend_lighten.CreateDefault(
780 *context_, options_trianglestrip,
781 {static_cast<Scalar>(BlendSelectValues::kLighten), supports_decal});
782 pipelines_->framebuffer_blend_luminosity.CreateDefault(
783 *context_, options_trianglestrip,
784 {static_cast<Scalar>(BlendSelectValues::kLuminosity), supports_decal});
785 pipelines_->framebuffer_blend_multiply.CreateDefault(
786 *context_, options_trianglestrip,
787 {static_cast<Scalar>(BlendSelectValues::kMultiply), supports_decal});
788 pipelines_->framebuffer_blend_overlay.CreateDefault(
789 *context_, options_trianglestrip,
790 {static_cast<Scalar>(BlendSelectValues::kOverlay), supports_decal});
791 pipelines_->framebuffer_blend_saturation.CreateDefault(
792 *context_, options_trianglestrip,
793 {static_cast<Scalar>(BlendSelectValues::kSaturation), supports_decal});
794 pipelines_->framebuffer_blend_screen.CreateDefault(
795 *context_, options_trianglestrip,
796 {static_cast<Scalar>(BlendSelectValues::kScreen), supports_decal});
797 pipelines_->framebuffer_blend_softlight.CreateDefault(
798 *context_, options_trianglestrip,
799 {static_cast<Scalar>(BlendSelectValues::kSoftLight), supports_decal});
800 } else {
801 pipelines_->blend_color.CreateDefault(
802 *context_, options_trianglestrip,
803 {static_cast<Scalar>(BlendSelectValues::kColor), supports_decal});
804 pipelines_->blend_colorburn.CreateDefault(
805 *context_, options_trianglestrip,
806 {static_cast<Scalar>(BlendSelectValues::kColorBurn), supports_decal});
807 pipelines_->blend_colordodge.CreateDefault(
808 *context_, options_trianglestrip,
809 {static_cast<Scalar>(BlendSelectValues::kColorDodge), supports_decal});
810 pipelines_->blend_darken.CreateDefault(
811 *context_, options_trianglestrip,
812 {static_cast<Scalar>(BlendSelectValues::kDarken), supports_decal});
813 pipelines_->blend_difference.CreateDefault(
814 *context_, options_trianglestrip,
815 {static_cast<Scalar>(BlendSelectValues::kDifference), supports_decal});
816 pipelines_->blend_exclusion.CreateDefault(
817 *context_, options_trianglestrip,
818 {static_cast<Scalar>(BlendSelectValues::kExclusion), supports_decal});
819 pipelines_->blend_hardlight.CreateDefault(
820 *context_, options_trianglestrip,
821 {static_cast<Scalar>(BlendSelectValues::kHardLight), supports_decal});
822 pipelines_->blend_hue.CreateDefault(
823 *context_, options_trianglestrip,
824 {static_cast<Scalar>(BlendSelectValues::kHue), supports_decal});
825 pipelines_->blend_lighten.CreateDefault(
826 *context_, options_trianglestrip,
827 {static_cast<Scalar>(BlendSelectValues::kLighten), supports_decal});
828 pipelines_->blend_luminosity.CreateDefault(
829 *context_, options_trianglestrip,
830 {static_cast<Scalar>(BlendSelectValues::kLuminosity), supports_decal});
831 pipelines_->blend_multiply.CreateDefault(
832 *context_, options_trianglestrip,
833 {static_cast<Scalar>(BlendSelectValues::kMultiply), supports_decal});
834 pipelines_->blend_overlay.CreateDefault(
835 *context_, options_trianglestrip,
836 {static_cast<Scalar>(BlendSelectValues::kOverlay), supports_decal});
837 pipelines_->blend_saturation.CreateDefault(
838 *context_, options_trianglestrip,
839 {static_cast<Scalar>(BlendSelectValues::kSaturation), supports_decal});
840 pipelines_->blend_screen.CreateDefault(
841 *context_, options_trianglestrip,
842 {static_cast<Scalar>(BlendSelectValues::kScreen), supports_decal});
843 pipelines_->blend_softlight.CreateDefault(
844 *context_, options_trianglestrip,
845 {static_cast<Scalar>(BlendSelectValues::kSoftLight), supports_decal});
846 }
847
848 pipelines_->morphology_filter.CreateDefault(*context_, options_trianglestrip,
849 {supports_decal});
850 pipelines_->linear_to_srgb_filter.CreateDefault(*context_,
851 options_trianglestrip);
852 pipelines_->srgb_to_linear_filter.CreateDefault(*context_,
853 options_trianglestrip);
854 pipelines_->yuv_to_rgb_filter.CreateDefault(*context_, options_trianglestrip);
855
856#if defined(IMPELLER_ENABLE_OPENGLES)
857 if (GetContext()->GetBackendType() == Context::BackendType::kOpenGLES) {
858#if !defined(FML_OS_MACOSX)
859 // GLES only shader that is unsupported on macOS.
860 pipelines_->tiled_texture_external.CreateDefault(*context_, options);
861 pipelines_->tiled_texture_uv_external.CreateDefault(*context_, options);
862#endif // !defined(FML_OS_MACOSX)
863 pipelines_->texture_downsample_gles.CreateDefault(*context_,
864 options_trianglestrip);
865 }
866#endif // IMPELLER_ENABLE_OPENGLES
867
868 is_valid_ = true;
869 InitializeCommonlyUsedShadersIfNeeded();
870}
BufferView buffer_view
HostBuffer & GetTransientsDataBuffer() const
Retrieve the current host buffer for transient storage of other non-index data.
std::shared_ptr< Context > GetContext() const
static std::shared_ptr< HostBuffer > Create(const std::shared_ptr< Allocator > &allocator, const std::shared_ptr< const IdleWaiter > &idle_waiter, size_t minimum_uniform_alignment)
ScopedObject< Object > Create(CtorArgs &&... args)
Definition object.h:161
std::array< std::vector< Scalar >, 15 > GetPorterDuffSpecConstants(bool supports_decal)
float Scalar
Definition scalar.h:19
ISize64 ISize
Definition size.h:162
Definition ref_ptr.h:261
static constexpr Color BlackTransparent()
Definition color.h:270
std::array< uint8_t, 4 > ToR8G8B8A8() const
Convert to R8G8B8A8 representation.
Definition color.h:246
std::shared_ptr< const fml::Mapping > data
#define VALIDATION_LOG
Definition validation.h:91

References impeller::Color::BlackTransparent(), buffer_view, impeller::HostBuffer::Create(), data, impeller::HostBuffer::Emplace(), impeller::TextureDescriptor::format, GetContext(), impeller::GetPorterDuffSpecConstants(), GetTransientsDataBuffer(), impeller::kA8UNormInt, impeller::kColor, impeller::kColorBurn, impeller::kColorDodge, impeller::kCount1, impeller::kCount4, impeller::kDarken, impeller::kDevicePrivate, impeller::kDifference, impeller::kExclusion, impeller::kHardLight, impeller::kHue, impeller::kLighten, impeller::kLuminosity, impeller::kMultiply, impeller::kNone, impeller::Context::kOpenGLES, impeller::kOverlay, impeller::kR8G8B8A8UNormInt, impeller::kSaturation, impeller::kScreen, impeller::kSoftLight, impeller::kTriangleStrip, impeller::ContentContextOptions::sample_count, impeller::TextureDescriptor::size, impeller::TextureDescriptor::storage_mode, impeller::Color::ToR8G8B8A8(), and VALIDATION_LOG.

◆ ~ContentContext()

impeller::ContentContext::~ContentContext ( )
default

Member Function Documentation

◆ ClearCachedRuntimeEffectPipeline()

void impeller::ContentContext::ClearCachedRuntimeEffectPipeline ( const std::string &  unique_entrypoint_name) const

Used by hot reload/hot restart to clear a cached pipeline from GetCachedRuntimeEffectPipeline.

Definition at line 975 of file content_context.cc.

976 {
977#ifdef IMPELLER_DEBUG
978 // destroying in-use pipleines is a validation error.
979 const auto& idle_waiter = GetContext()->GetIdleWaiter();
980 if (idle_waiter) {
981 idle_waiter->WaitIdle();
982 }
983#endif // IMPELLER_DEBUG
984 for (auto it = runtime_effect_pipelines_.begin();
985 it != runtime_effect_pipelines_.end();) {
986 if (it->first.unique_entrypoint_name == unique_entrypoint_name) {
987 it = runtime_effect_pipelines_.erase(it);
988 } else {
989 it++;
990 }
991 }
992}

References GetContext().

◆ GetBlendColorBurnPipeline()

PipelineRef impeller::ContentContext::GetBlendColorBurnPipeline ( ContentContextOptions  opts) const

Definition at line 1328 of file content_context.cc.

1329 {
1330 return GetPipeline(this, pipelines_->blend_colorburn, opts);
1331}

◆ GetBlendColorDodgePipeline()

PipelineRef impeller::ContentContext::GetBlendColorDodgePipeline ( ContentContextOptions  opts) const

Definition at line 1333 of file content_context.cc.

1334 {
1335 return GetPipeline(this, pipelines_->blend_colordodge, opts);
1336}

◆ GetBlendColorPipeline()

PipelineRef impeller::ContentContext::GetBlendColorPipeline ( ContentContextOptions  opts) const

Definition at line 1323 of file content_context.cc.

1324 {
1325 return GetPipeline(this, pipelines_->blend_color, opts);
1326}

◆ GetBlendDarkenPipeline()

PipelineRef impeller::ContentContext::GetBlendDarkenPipeline ( ContentContextOptions  opts) const

Definition at line 1338 of file content_context.cc.

1339 {
1340 return GetPipeline(this, pipelines_->blend_darken, opts);
1341}

◆ GetBlendDifferencePipeline()

PipelineRef impeller::ContentContext::GetBlendDifferencePipeline ( ContentContextOptions  opts) const

Definition at line 1343 of file content_context.cc.

1344 {
1345 return GetPipeline(this, pipelines_->blend_difference, opts);
1346}

◆ GetBlendExclusionPipeline()

PipelineRef impeller::ContentContext::GetBlendExclusionPipeline ( ContentContextOptions  opts) const

Definition at line 1348 of file content_context.cc.

1349 {
1350 return GetPipeline(this, pipelines_->blend_exclusion, opts);
1351}

◆ GetBlendHardLightPipeline()

PipelineRef impeller::ContentContext::GetBlendHardLightPipeline ( ContentContextOptions  opts) const

Definition at line 1353 of file content_context.cc.

1354 {
1355 return GetPipeline(this, pipelines_->blend_hardlight, opts);
1356}

◆ GetBlendHuePipeline()

PipelineRef impeller::ContentContext::GetBlendHuePipeline ( ContentContextOptions  opts) const

Definition at line 1358 of file content_context.cc.

1359 {
1360 return GetPipeline(this, pipelines_->blend_hue, opts);
1361}

◆ GetBlendLightenPipeline()

PipelineRef impeller::ContentContext::GetBlendLightenPipeline ( ContentContextOptions  opts) const

Definition at line 1363 of file content_context.cc.

1364 {
1365 return GetPipeline(this, pipelines_->blend_lighten, opts);
1366}

◆ GetBlendLuminosityPipeline()

PipelineRef impeller::ContentContext::GetBlendLuminosityPipeline ( ContentContextOptions  opts) const

Definition at line 1368 of file content_context.cc.

1369 {
1370 return GetPipeline(this, pipelines_->blend_luminosity, opts);
1371}

◆ GetBlendMultiplyPipeline()

PipelineRef impeller::ContentContext::GetBlendMultiplyPipeline ( ContentContextOptions  opts) const

Definition at line 1373 of file content_context.cc.

1374 {
1375 return GetPipeline(this, pipelines_->blend_multiply, opts);
1376}

◆ GetBlendOverlayPipeline()

PipelineRef impeller::ContentContext::GetBlendOverlayPipeline ( ContentContextOptions  opts) const

Definition at line 1378 of file content_context.cc.

1379 {
1380 return GetPipeline(this, pipelines_->blend_overlay, opts);
1381}

◆ GetBlendSaturationPipeline()

PipelineRef impeller::ContentContext::GetBlendSaturationPipeline ( ContentContextOptions  opts) const

Definition at line 1383 of file content_context.cc.

1384 {
1385 return GetPipeline(this, pipelines_->blend_saturation, opts);
1386}

◆ GetBlendScreenPipeline()

PipelineRef impeller::ContentContext::GetBlendScreenPipeline ( ContentContextOptions  opts) const

Definition at line 1388 of file content_context.cc.

1389 {
1390 return GetPipeline(this, pipelines_->blend_screen, opts);
1391}

◆ GetBlendSoftLightPipeline()

PipelineRef impeller::ContentContext::GetBlendSoftLightPipeline ( ContentContextOptions  opts) const

Definition at line 1393 of file content_context.cc.

1394 {
1395 return GetPipeline(this, pipelines_->blend_softlight, opts);
1396}

◆ GetBorderMaskBlurPipeline()

PipelineRef impeller::ContentContext::GetBorderMaskBlurPipeline ( ContentContextOptions  opts) const

Definition at line 1154 of file content_context.cc.

1155 {
1156 return GetPipeline(this, pipelines_->border_mask_blur, opts);
1157}

◆ GetCachedRuntimeEffectPipeline()

PipelineRef impeller::ContentContext::GetCachedRuntimeEffectPipeline ( const std::string &  unique_entrypoint_name,
const ContentContextOptions options,
const std::function< std::shared_ptr< Pipeline< PipelineDescriptor > >()> &  create_callback 
) const

RuntimeEffect pipelines must be obtained via this method to avoid re-creating them every frame.

The unique_entrypoint_name comes from RuntimeEffect::GetEntrypoint. Impellerc generates a unique entrypoint name for runtime effect shaders based on the input file name and shader stage.

The create_callback is synchronously invoked exactly once if a cached pipeline is not found.

Definition at line 962 of file content_context.cc.

966 {
967 RuntimeEffectPipelineKey key{unique_entrypoint_name, options};
968 auto it = runtime_effect_pipelines_.find(key);
969 if (it == runtime_effect_pipelines_.end()) {
970 it = runtime_effect_pipelines_.insert(it, {key, create_callback()});
971 }
972 return raw_ptr(it->second);
973}

References key.

Referenced by impeller::RuntimeEffectContents::Render().

◆ GetCirclePipeline()

PipelineRef impeller::ContentContext::GetCirclePipeline ( ContentContextOptions  opts) const

Definition at line 1503 of file content_context.cc.

1504 {
1505 return GetPipeline(this, pipelines_->circle, opts);
1506}

Referenced by impeller::CircleContents::Render().

◆ GetClearBlendPipeline()

PipelineRef impeller::ContentContext::GetClearBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1248 of file content_context.cc.

1249 {
1250 return GetPipeline(this, pipelines_->clear_blend, opts);
1251}

Referenced by GetPorterDuffPipeline().

◆ GetClipPipeline()

PipelineRef impeller::ContentContext::GetClipPipeline ( ContentContextOptions  opts) const

Definition at line 1179 of file content_context.cc.

1179 {
1180 return GetPipeline(this, pipelines_->clip, opts);
1181}

Referenced by impeller::ColorSourceContents::DrawGeometry(), impeller::ClipContents::Render(), and impeller::RenderClipRestore().

◆ GetColorMatrixColorFilterPipeline()

PipelineRef impeller::ContentContext::GetColorMatrixColorFilterPipeline ( ContentContextOptions  opts) const

Definition at line 1164 of file content_context.cc.

1165 {
1166 return GetPipeline(this, pipelines_->color_matrix_color_filter, opts);
1167}

Referenced by impeller::ColorFilterAtlasContents::Render().

◆ GetConicalGradientFillPipeline()

PipelineRef impeller::ContentContext::GetConicalGradientFillPipeline ( ContentContextOptions  opts,
ConicalKind  kind 
) const

Definition at line 1098 of file content_context.cc.

1100 {
1101 switch (kind) {
1103 return GetPipeline(this, pipelines_->conical_gradient_fill, opts);
1105 return GetPipeline(this, pipelines_->conical_gradient_fill_radial, opts);
1107 return GetPipeline(this, pipelines_->conical_gradient_fill_strip, opts);
1109 return GetPipeline(
1110 this, pipelines_->conical_gradient_fill_strip_and_radial, opts);
1111 }
1112}

References impeller::kConical, impeller::kRadial, impeller::kStrip, and impeller::kStripAndRadial.

◆ GetConicalGradientSSBOFillPipeline()

PipelineRef impeller::ContentContext::GetConicalGradientSSBOFillPipeline ( ContentContextOptions  opts,
ConicalKind  kind 
) const

Definition at line 1068 of file content_context.cc.

1070 {
1071 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1072 switch (kind) {
1074 return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill, opts);
1076 return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill_radial,
1077 opts);
1079 return GetPipeline(this, pipelines_->conical_gradient_ssbo_fill_strip,
1080 opts);
1082 return GetPipeline(
1083 this, pipelines_->conical_gradient_ssbo_fill_strip_and_radial, opts);
1084 }
1085}
const Capabilities & GetDeviceCapabilities() const
#define FML_DCHECK(condition)
Definition logging.h:122

References FML_DCHECK, GetDeviceCapabilities(), impeller::kConical, impeller::kRadial, impeller::kStrip, and impeller::kStripAndRadial.

◆ GetConicalGradientUniformFillPipeline()

PipelineRef impeller::ContentContext::GetConicalGradientUniformFillPipeline ( ContentContextOptions  opts,
ConicalKind  kind 
) const

Definition at line 1049 of file content_context.cc.

1051 {
1052 switch (kind) {
1054 return GetPipeline(this, pipelines_->conical_gradient_uniform_fill, opts);
1056 return GetPipeline(this, pipelines_->conical_gradient_uniform_fill_radial,
1057 opts);
1059 return GetPipeline(this, pipelines_->conical_gradient_uniform_fill_strip,
1060 opts);
1062 return GetPipeline(
1063 this, pipelines_->conical_gradient_uniform_fill_strip_and_radial,
1064 opts);
1065 }
1066}

References impeller::kConical, impeller::kRadial, impeller::kStrip, and impeller::kStripAndRadial.

◆ GetContext()

◆ GetDestinationATopBlendPipeline()

PipelineRef impeller::ContentContext::GetDestinationATopBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1298 of file content_context.cc.

1299 {
1300 return GetPipeline(this, pipelines_->destination_a_top_blend, opts);
1301}

Referenced by GetPorterDuffPipeline().

◆ GetDestinationBlendPipeline()

PipelineRef impeller::ContentContext::GetDestinationBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1258 of file content_context.cc.

1259 {
1260 return GetPipeline(this, pipelines_->destination_blend, opts);
1261}

Referenced by GetPorterDuffPipeline().

◆ GetDestinationInBlendPipeline()

PipelineRef impeller::ContentContext::GetDestinationInBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1278 of file content_context.cc.

1279 {
1280 return GetPipeline(this, pipelines_->destination_in_blend, opts);
1281}

Referenced by GetPorterDuffPipeline().

◆ GetDestinationOutBlendPipeline()

PipelineRef impeller::ContentContext::GetDestinationOutBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1288 of file content_context.cc.

1289 {
1290 return GetPipeline(this, pipelines_->destination_out_blend, opts);
1291}

Referenced by GetPorterDuffPipeline().

◆ GetDestinationOverBlendPipeline()

PipelineRef impeller::ContentContext::GetDestinationOverBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1268 of file content_context.cc.

1269 {
1270 return GetPipeline(this, pipelines_->destination_over_blend, opts);
1271}

Referenced by GetPorterDuffPipeline().

◆ GetDeviceCapabilities()

◆ GetDownsamplePipeline()

PipelineRef impeller::ContentContext::GetDownsamplePipeline ( ContentContextOptions  opts) const

Definition at line 1398 of file content_context.cc.

1399 {
1400 return GetPipeline(this, pipelines_->texture_downsample, opts);
1401}

◆ GetDrawVerticesUberPipeline()

PipelineRef impeller::ContentContext::GetDrawVerticesUberPipeline ( BlendMode  blend_mode,
ContentContextOptions  opts 
) const

Definition at line 1493 of file content_context.cc.

1495 {
1496 if (blend_mode <= BlendMode::kHardLight) {
1497 return GetPipeline(this, pipelines_->vertices_uber_1_, opts);
1498 } else {
1499 return GetPipeline(this, pipelines_->vertices_uber_2_, opts);
1500 }
1501}

References impeller::kHardLight.

Referenced by impeller::AtlasContents::Render(), and impeller::VerticesSimpleBlendContents::Render().

◆ GetEmptyTexture()

std::shared_ptr< Texture > impeller::ContentContext::GetEmptyTexture ( ) const

Definition at line 878 of file content_context.cc.

878 {
879 return empty_texture_;
880}

Referenced by impeller::VerticesSimpleBlendContents::Render().

◆ GetFastGradientPipeline()

PipelineRef impeller::ContentContext::GetFastGradientPipeline ( ContentContextOptions  opts) const

Definition at line 1012 of file content_context.cc.

1013 {
1014 return GetPipeline(this, pipelines_->fast_gradient, opts);
1015}

◆ GetFramebufferBlendColorBurnPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendColorBurnPipeline ( ContentContextOptions  opts) const

Definition at line 1409 of file content_context.cc.

1410 {
1411 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1412 return GetPipeline(this, pipelines_->framebuffer_blend_colorburn, opts);
1413}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendColorDodgePipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendColorDodgePipeline ( ContentContextOptions  opts) const

Definition at line 1415 of file content_context.cc.

1416 {
1417 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1418 return GetPipeline(this, pipelines_->framebuffer_blend_colordodge, opts);
1419}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendColorPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendColorPipeline ( ContentContextOptions  opts) const

Definition at line 1403 of file content_context.cc.

1404 {
1405 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1406 return GetPipeline(this, pipelines_->framebuffer_blend_color, opts);
1407}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendDarkenPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendDarkenPipeline ( ContentContextOptions  opts) const

Definition at line 1421 of file content_context.cc.

1422 {
1423 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1424 return GetPipeline(this, pipelines_->framebuffer_blend_darken, opts);
1425}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendDifferencePipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendDifferencePipeline ( ContentContextOptions  opts) const

Definition at line 1427 of file content_context.cc.

1428 {
1429 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1430 return GetPipeline(this, pipelines_->framebuffer_blend_difference, opts);
1431}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendExclusionPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendExclusionPipeline ( ContentContextOptions  opts) const

Definition at line 1433 of file content_context.cc.

1434 {
1435 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1436 return GetPipeline(this, pipelines_->framebuffer_blend_exclusion, opts);
1437}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendHardLightPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendHardLightPipeline ( ContentContextOptions  opts) const

Definition at line 1439 of file content_context.cc.

1440 {
1441 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1442 return GetPipeline(this, pipelines_->framebuffer_blend_hardlight, opts);
1443}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendHuePipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendHuePipeline ( ContentContextOptions  opts) const

Definition at line 1445 of file content_context.cc.

1446 {
1447 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1448 return GetPipeline(this, pipelines_->framebuffer_blend_hue, opts);
1449}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendLightenPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendLightenPipeline ( ContentContextOptions  opts) const

Definition at line 1451 of file content_context.cc.

1452 {
1453 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1454 return GetPipeline(this, pipelines_->framebuffer_blend_lighten, opts);
1455}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendLuminosityPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendLuminosityPipeline ( ContentContextOptions  opts) const

Definition at line 1457 of file content_context.cc.

1458 {
1459 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1460 return GetPipeline(this, pipelines_->framebuffer_blend_luminosity, opts);
1461}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendMultiplyPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendMultiplyPipeline ( ContentContextOptions  opts) const

Definition at line 1463 of file content_context.cc.

1464 {
1465 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1466 return GetPipeline(this, pipelines_->framebuffer_blend_multiply, opts);
1467}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendOverlayPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendOverlayPipeline ( ContentContextOptions  opts) const

Definition at line 1469 of file content_context.cc.

1470 {
1471 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1472 return GetPipeline(this, pipelines_->framebuffer_blend_overlay, opts);
1473}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendSaturationPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendSaturationPipeline ( ContentContextOptions  opts) const

Definition at line 1475 of file content_context.cc.

1476 {
1477 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1478 return GetPipeline(this, pipelines_->framebuffer_blend_saturation, opts);
1479}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendScreenPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendScreenPipeline ( ContentContextOptions  opts) const

Definition at line 1481 of file content_context.cc.

1482 {
1483 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1484 return GetPipeline(this, pipelines_->framebuffer_blend_screen, opts);
1485}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetFramebufferBlendSoftLightPipeline()

PipelineRef impeller::ContentContext::GetFramebufferBlendSoftLightPipeline ( ContentContextOptions  opts) const

Definition at line 1487 of file content_context.cc.

1488 {
1489 FML_DCHECK(GetDeviceCapabilities().SupportsFramebufferFetch());
1490 return GetPipeline(this, pipelines_->framebuffer_blend_softlight, opts);
1491}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetGaussianBlurPipeline()

PipelineRef impeller::ContentContext::GetGaussianBlurPipeline ( ContentContextOptions  opts) const

Definition at line 1149 of file content_context.cc.

1150 {
1151 return GetPipeline(this, pipelines_->gaussian_blur, opts);
1152}

◆ GetGlyphAtlasPipeline()

PipelineRef impeller::ContentContext::GetGlyphAtlasPipeline ( ContentContextOptions  opts) const

Definition at line 1183 of file content_context.cc.

1184 {
1185 return GetPipeline(this, pipelines_->glyph_atlas, opts);
1186}

Referenced by impeller::TextContents::Render().

◆ GetLazyGlyphAtlas()

const std::shared_ptr< LazyGlyphAtlas > & impeller::ContentContext::GetLazyGlyphAtlas ( ) const
inline

Definition at line 266 of file content_context.h.

266 {
267 return lazy_glyph_atlas_;
268 }

Referenced by impeller::FirstPassDispatcher::drawText(), impeller::TextContents::Render(), impeller::RenderToTarget(), and impeller::testing::TEST_P().

◆ GetLinearGradientFillPipeline()

PipelineRef impeller::ContentContext::GetLinearGradientFillPipeline ( ContentContextOptions  opts) const

Definition at line 1017 of file content_context.cc.

1018 {
1019 return GetPipeline(this, pipelines_->linear_gradient_fill, opts);
1020}

◆ GetLinearGradientSSBOFillPipeline()

PipelineRef impeller::ContentContext::GetLinearGradientSSBOFillPipeline ( ContentContextOptions  opts) const

Definition at line 1037 of file content_context.cc.

1038 {
1039 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1040 return GetPipeline(this, pipelines_->linear_gradient_ssbo_fill, opts);
1041}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetLinearGradientUniformFillPipeline()

PipelineRef impeller::ContentContext::GetLinearGradientUniformFillPipeline ( ContentContextOptions  opts) const

Definition at line 1022 of file content_context.cc.

1023 {
1024 return GetPipeline(this, pipelines_->linear_gradient_uniform_fill, opts);
1025}

◆ GetLinearToSrgbFilterPipeline()

PipelineRef impeller::ContentContext::GetLinearToSrgbFilterPipeline ( ContentContextOptions  opts) const

Definition at line 1169 of file content_context.cc.

1170 {
1171 return GetPipeline(this, pipelines_->linear_to_srgb_filter, opts);
1172}

◆ GetLinePipeline()

PipelineRef impeller::ContentContext::GetLinePipeline ( ContentContextOptions  opts) const

Definition at line 1508 of file content_context.cc.

1508 {
1509 return GetPipeline(this, pipelines_->line, opts);
1510}

Referenced by impeller::LineContents::Render().

◆ GetModulateBlendPipeline()

PipelineRef impeller::ContentContext::GetModulateBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1313 of file content_context.cc.

1314 {
1315 return GetPipeline(this, pipelines_->modulate_blend, opts);
1316}

Referenced by GetPorterDuffPipeline().

◆ GetMorphologyFilterPipeline()

PipelineRef impeller::ContentContext::GetMorphologyFilterPipeline ( ContentContextOptions  opts) const

Definition at line 1159 of file content_context.cc.

1160 {
1161 return GetPipeline(this, pipelines_->morphology_filter, opts);
1162}

◆ GetPlusBlendPipeline()

PipelineRef impeller::ContentContext::GetPlusBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1308 of file content_context.cc.

1309 {
1310 return GetPipeline(this, pipelines_->plus_blend, opts);
1311}

Referenced by GetPorterDuffPipeline().

◆ GetPorterDuffPipeline()

PipelineRef impeller::ContentContext::GetPorterDuffPipeline ( BlendMode  mode,
ContentContextOptions  opts 
) const

Definition at line 1193 of file content_context.cc.

1195 {
1196 switch (mode) {
1197 case BlendMode::kClear:
1198 return GetClearBlendPipeline(opts);
1199 case BlendMode::kSrc:
1200 return GetSourceBlendPipeline(opts);
1201 case BlendMode::kDst:
1202 return GetDestinationBlendPipeline(opts);
1204 return GetSourceOverBlendPipeline(opts);
1207 case BlendMode::kSrcIn:
1208 return GetSourceInBlendPipeline(opts);
1209 case BlendMode::kDstIn:
1210 return GetDestinationInBlendPipeline(opts);
1211 case BlendMode::kSrcOut:
1212 return GetSourceOutBlendPipeline(opts);
1213 case BlendMode::kDstOut:
1214 return GetDestinationOutBlendPipeline(opts);
1216 return GetSourceATopBlendPipeline(opts);
1219 case BlendMode::kXor:
1220 return GetXorBlendPipeline(opts);
1221 case BlendMode::kPlus:
1222 return GetPlusBlendPipeline(opts);
1224 return GetModulateBlendPipeline(opts);
1225 case BlendMode::kScreen:
1226 return GetScreenBlendPipeline(opts);
1228 case BlendMode::kDarken:
1237 case BlendMode::kHue:
1239 case BlendMode::kColor:
1241 VALIDATION_LOG << "Invalid porter duff blend mode "
1242 << BlendModeToString(mode);
1243 return GetClearBlendPipeline(opts);
1244 break;
1245 }
1246}
PipelineRef GetSourceInBlendPipeline(ContentContextOptions opts) const
PipelineRef GetSourceOutBlendPipeline(ContentContextOptions opts) const
PipelineRef GetScreenBlendPipeline(ContentContextOptions opts) const
PipelineRef GetPlusBlendPipeline(ContentContextOptions opts) const
PipelineRef GetModulateBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationATopBlendPipeline(ContentContextOptions opts) const
PipelineRef GetClearBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationOutBlendPipeline(ContentContextOptions opts) const
PipelineRef GetSourceATopBlendPipeline(ContentContextOptions opts) const
PipelineRef GetXorBlendPipeline(ContentContextOptions opts) const
PipelineRef GetSourceBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationOverBlendPipeline(ContentContextOptions opts) const
PipelineRef GetSourceOverBlendPipeline(ContentContextOptions opts) const
PipelineRef GetDestinationInBlendPipeline(ContentContextOptions opts) const
const char * BlendModeToString(BlendMode blend_mode)
Definition color.cc:47

References impeller::BlendModeToString(), GetClearBlendPipeline(), GetDestinationATopBlendPipeline(), GetDestinationBlendPipeline(), GetDestinationInBlendPipeline(), GetDestinationOutBlendPipeline(), GetDestinationOverBlendPipeline(), GetModulateBlendPipeline(), GetPlusBlendPipeline(), GetScreenBlendPipeline(), GetSourceATopBlendPipeline(), GetSourceBlendPipeline(), GetSourceInBlendPipeline(), GetSourceOutBlendPipeline(), GetSourceOverBlendPipeline(), GetXorBlendPipeline(), impeller::kClear, impeller::kColor, impeller::kColorBurn, impeller::kColorDodge, impeller::kDarken, impeller::kDifference, impeller::kDst, impeller::kDstATop, impeller::kDstIn, impeller::kDstOut, impeller::kDstOver, impeller::kExclusion, impeller::kHardLight, impeller::kHue, impeller::kLighten, impeller::kLuminosity, impeller::kModulate, impeller::kMultiply, impeller::kOverlay, impeller::kPlus, impeller::kSaturation, impeller::kScreen, impeller::kSoftLight, impeller::kSrc, impeller::kSrcATop, impeller::kSrcIn, impeller::kSrcOut, impeller::kSrcOver, impeller::kXor, and VALIDATION_LOG.

Referenced by impeller::AtlasContents::Render(), and impeller::VerticesSimpleBlendContents::Render().

◆ GetRadialGradientFillPipeline()

PipelineRef impeller::ContentContext::GetRadialGradientFillPipeline ( ContentContextOptions  opts) const

Definition at line 1093 of file content_context.cc.

1094 {
1095 return GetPipeline(this, pipelines_->radial_gradient_fill, opts);
1096}

◆ GetRadialGradientSSBOFillPipeline()

PipelineRef impeller::ContentContext::GetRadialGradientSSBOFillPipeline ( ContentContextOptions  opts) const

Definition at line 1043 of file content_context.cc.

1044 {
1045 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1046 return GetPipeline(this, pipelines_->radial_gradient_ssbo_fill, opts);
1047}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetRadialGradientUniformFillPipeline()

PipelineRef impeller::ContentContext::GetRadialGradientUniformFillPipeline ( ContentContextOptions  opts) const

Definition at line 1027 of file content_context.cc.

1028 {
1029 return GetPipeline(this, pipelines_->radial_gradient_uniform_fill, opts);
1030}

◆ GetRenderTargetCache()

const std::shared_ptr< RenderTargetAllocator > & impeller::ContentContext::GetRenderTargetCache ( ) const
inline

◆ GetRRectBlurPipeline()

PipelineRef impeller::ContentContext::GetRRectBlurPipeline ( ContentContextOptions  opts) const

Definition at line 1114 of file content_context.cc.

1115 {
1116 return GetPipeline(this, pipelines_->rrect_blur, opts);
1117}

Referenced by impeller::SolidRRectBlurContents::SetPassInfo().

◆ GetRSuperellipseBlurPipeline()

PipelineRef impeller::ContentContext::GetRSuperellipseBlurPipeline ( ContentContextOptions  opts) const

Definition at line 1119 of file content_context.cc.

1120 {
1121 return GetPipeline(this, pipelines_->rsuperellipse_blur, opts);
1122}

◆ GetScreenBlendPipeline()

PipelineRef impeller::ContentContext::GetScreenBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1318 of file content_context.cc.

1319 {
1320 return GetPipeline(this, pipelines_->screen_blend, opts);
1321}

Referenced by GetPorterDuffPipeline().

◆ GetSolidFillPipeline()

PipelineRef impeller::ContentContext::GetSolidFillPipeline ( ContentContextOptions  opts) const

Definition at line 1129 of file content_context.cc.

1130 {
1131 return GetPipeline(this, pipelines_->solid_fill, opts);
1132}

Referenced by impeller::SolidColorContents::Render(), and impeller::testing::TEST_P().

◆ GetSourceATopBlendPipeline()

PipelineRef impeller::ContentContext::GetSourceATopBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1293 of file content_context.cc.

1294 {
1295 return GetPipeline(this, pipelines_->source_a_top_blend, opts);
1296}

Referenced by GetPorterDuffPipeline().

◆ GetSourceBlendPipeline()

PipelineRef impeller::ContentContext::GetSourceBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1253 of file content_context.cc.

1254 {
1255 return GetPipeline(this, pipelines_->source_blend, opts);
1256}

Referenced by GetPorterDuffPipeline().

◆ GetSourceInBlendPipeline()

PipelineRef impeller::ContentContext::GetSourceInBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1273 of file content_context.cc.

1274 {
1275 return GetPipeline(this, pipelines_->source_in_blend, opts);
1276}

Referenced by GetPorterDuffPipeline().

◆ GetSourceOutBlendPipeline()

PipelineRef impeller::ContentContext::GetSourceOutBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1283 of file content_context.cc.

1284 {
1285 return GetPipeline(this, pipelines_->source_out_blend, opts);
1286}

Referenced by GetPorterDuffPipeline().

◆ GetSourceOverBlendPipeline()

PipelineRef impeller::ContentContext::GetSourceOverBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1263 of file content_context.cc.

1264 {
1265 return GetPipeline(this, pipelines_->source_over_blend, opts);
1266}

Referenced by GetPorterDuffPipeline().

◆ GetSrgbToLinearFilterPipeline()

PipelineRef impeller::ContentContext::GetSrgbToLinearFilterPipeline ( ContentContextOptions  opts) const

Definition at line 1174 of file content_context.cc.

1175 {
1176 return GetPipeline(this, pipelines_->srgb_to_linear_filter, opts);
1177}

◆ GetSweepGradientFillPipeline()

PipelineRef impeller::ContentContext::GetSweepGradientFillPipeline ( ContentContextOptions  opts) const

Definition at line 1124 of file content_context.cc.

1125 {
1126 return GetPipeline(this, pipelines_->sweep_gradient_fill, opts);
1127}

◆ GetSweepGradientSSBOFillPipeline()

PipelineRef impeller::ContentContext::GetSweepGradientSSBOFillPipeline ( ContentContextOptions  opts) const

Definition at line 1087 of file content_context.cc.

1088 {
1089 FML_DCHECK(GetDeviceCapabilities().SupportsSSBO());
1090 return GetPipeline(this, pipelines_->sweep_gradient_ssbo_fill, opts);
1091}

References FML_DCHECK, and GetDeviceCapabilities().

◆ GetSweepGradientUniformFillPipeline()

PipelineRef impeller::ContentContext::GetSweepGradientUniformFillPipeline ( ContentContextOptions  opts) const

Definition at line 1032 of file content_context.cc.

1033 {
1034 return GetPipeline(this, pipelines_->sweep_gradient_uniform_fill, opts);
1035}

◆ GetTessellator()

Tessellator & impeller::ContentContext::GetTessellator ( ) const

Definition at line 950 of file content_context.cc.

950 {
951 return *tessellator_;
952}

Referenced by impeller::CircleGeometry::GetPositionBuffer(), and impeller::StrokeRectGeometry::GetPositionBuffer().

◆ GetTextShadowCache()

TextShadowCache & impeller::ContentContext::GetTextShadowCache ( ) const
inline

◆ GetTexturePipeline()

PipelineRef impeller::ContentContext::GetTexturePipeline ( ContentContextOptions  opts) const

Definition at line 1134 of file content_context.cc.

1135 {
1136 return GetPipeline(this, pipelines_->texture, opts);
1137}

Referenced by impeller::PipelineBlend(), impeller::AtlasContents::Render(), and impeller::TextureContents::Render().

◆ GetTextureStrictSrcPipeline()

PipelineRef impeller::ContentContext::GetTextureStrictSrcPipeline ( ContentContextOptions  opts) const

Definition at line 1139 of file content_context.cc.

1140 {
1141 return GetPipeline(this, pipelines_->texture_strict_src, opts);
1142}

Referenced by impeller::TextureContents::Render().

◆ GetTiledTexturePipeline()

PipelineRef impeller::ContentContext::GetTiledTexturePipeline ( ContentContextOptions  opts) const

Definition at line 1144 of file content_context.cc.

1145 {
1146 return GetPipeline(this, pipelines_->tiled_texture, opts);
1147}

Referenced by impeller::TiledTextureContents::Render().

◆ GetTransientsDataBuffer()

◆ GetTransientsIndexesBuffer()

HostBuffer & impeller::ContentContext::GetTransientsIndexesBuffer ( ) const
inline

Retrieve the current host buffer for transient storage of indexes used for indexed draws.

This may or may not return the same value as GetTransientsDataBuffer depending on the backend.

This is only safe to use from the raster threads. Other threads should allocate their own device buffers.

Definition at line 302 of file content_context.h.

302 {
303 return *indexes_host_buffer_;
304 }

Referenced by impeller::DlVerticesGeometry::GetPositionBuffer(), impeller::DlVerticesGeometry::GetPositionUVColorBuffer(), impeller::EntityPlayground::OpenPlaygroundHere(), impeller::TextContents::Render(), and impeller::testing::TEST_P().

◆ GetXorBlendPipeline()

PipelineRef impeller::ContentContext::GetXorBlendPipeline ( ContentContextOptions  opts) const

Definition at line 1303 of file content_context.cc.

1304 {
1305 return GetPipeline(this, pipelines_->xor_blend, opts);
1306}

Referenced by GetPorterDuffPipeline().

◆ GetYUVToRGBFilterPipeline()

PipelineRef impeller::ContentContext::GetYUVToRGBFilterPipeline ( ContentContextOptions  opts) const

Definition at line 1188 of file content_context.cc.

1189 {
1190 return GetPipeline(this, pipelines_->yuv_to_rgb_filter, opts);
1191}

◆ IsValid()

bool impeller::ContentContext::IsValid ( ) const

Definition at line 874 of file content_context.cc.

874 {
875 return is_valid_;
876}

Referenced by impeller::EntityPlayground::OpenPlaygroundHere().

◆ MakeSubpass() [1/2]

fml::StatusOr< RenderTarget > impeller::ContentContext::MakeSubpass ( std::string_view  label,
const RenderTarget subpass_target,
const std::shared_ptr< CommandBuffer > &  command_buffer,
const SubpassCallback subpass_callback 
) const

Makes a subpass that will render to subpass_target.

Definition at line 911 of file content_context.cc.

915 {
916 const std::shared_ptr<Context>& context = GetContext();
917
918 auto subpass_texture = subpass_target.GetRenderTargetTexture();
919 if (!subpass_texture) {
921 }
922
923 auto sub_renderpass = command_buffer->CreateRenderPass(subpass_target);
924 if (!sub_renderpass) {
926 }
927 sub_renderpass->SetLabel(label);
928
929 if (!subpass_callback(*this, *sub_renderpass)) {
931 }
932
933 if (!sub_renderpass->EncodeCommands()) {
935 }
936
937 const std::shared_ptr<Texture>& target_texture =
938 subpass_target.GetRenderTargetTexture();
939 if (target_texture->GetMipCount() > 1) {
940 fml::Status mipmap_status =
941 AddMipmapGeneration(command_buffer, context, target_texture);
942 if (!mipmap_status.ok()) {
943 return mipmap_status;
944 }
945 }
946
947 return subpass_target;
948}
bool ok() const
Definition status.h:71
fml::Status AddMipmapGeneration(const std::shared_ptr< CommandBuffer > &command_buffer, const std::shared_ptr< Context > &context, const std::shared_ptr< Texture > &texture)
Adds a blit command to the render pass.

References impeller::AddMipmapGeneration(), GetContext(), impeller::RenderTarget::GetRenderTargetTexture(), fml::kUnknown, and fml::Status::ok().

◆ MakeSubpass() [2/2]

fml::StatusOr< RenderTarget > impeller::ContentContext::MakeSubpass ( std::string_view  label,
ISize  texture_size,
const std::shared_ptr< CommandBuffer > &  command_buffer,
const SubpassCallback subpass_callback,
bool  msaa_enabled = true,
bool  depth_stencil_enabled = false,
int32_t  mip_count = 1 
) const

Creates a new texture of size texture_size and calls subpass_callback with a RenderPass for drawing to the texture.

Definition at line 882 of file content_context.cc.

889 {
890 const std::shared_ptr<Context>& context = GetContext();
891 RenderTarget subpass_target;
892
893 std::optional<RenderTarget::AttachmentConfig> depth_stencil_config =
895 : std::optional<RenderTarget::AttachmentConfig>();
896
897 if (context->GetCapabilities()->SupportsOffscreenMSAA() && msaa_enabled) {
898 subpass_target = GetRenderTargetCache()->CreateOffscreenMSAA(
899 *context, texture_size,
900 /*mip_count=*/mip_count, label,
902 } else {
903 subpass_target = GetRenderTargetCache()->CreateOffscreen(
904 *context, texture_size,
905 /*mip_count=*/mip_count, label,
906 RenderTarget::kDefaultColorAttachmentConfig, depth_stencil_config);
907 }
908 return MakeSubpass(label, subpass_target, command_buffer, subpass_callback);
909}
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
fml::StatusOr< RenderTarget > MakeSubpass(std::string_view label, ISize texture_size, const std::shared_ptr< CommandBuffer > &command_buffer, const SubpassCallback &subpass_callback, bool msaa_enabled=true, bool depth_stencil_enabled=false, int32_t mip_count=1) const
Creates a new texture of size texture_size and calls subpass_callback with a RenderPass for drawing t...
static constexpr AttachmentConfig kDefaultColorAttachmentConfig
static constexpr AttachmentConfigMSAA kDefaultColorAttachmentConfigMSAA
static constexpr AttachmentConfig kDefaultStencilAttachmentConfig

References GetContext(), GetRenderTargetCache(), impeller::RenderTarget::kDefaultColorAttachmentConfig, impeller::RenderTarget::kDefaultColorAttachmentConfigMSAA, impeller::RenderTarget::kDefaultStencilAttachmentConfig, and MakeSubpass().

Referenced by impeller::AdvancedBlend(), MakeSubpass(), impeller::PipelineBlend(), and impeller::Contents::RenderToSnapshot().

◆ ResetTransientsBuffers()

void impeller::ContentContext::ResetTransientsBuffers ( )

Resets the transients buffers held onto by the content context.

Definition at line 994 of file content_context.cc.

994 {
995 data_host_buffer_->Reset();
996
997 // We should only reset the indexes host buffer if it is actually different
998 // from the data host buffer. Otherwise we'll end up resetting the same host
999 // buffer twice.
1000 if (data_host_buffer_ != indexes_host_buffer_) {
1001 indexes_host_buffer_->Reset();
1002 }
1003}

Referenced by impeller::RenderToTarget().

◆ SetTransientsDataBuffer()

void impeller::ContentContext::SetTransientsDataBuffer ( std::shared_ptr< HostBuffer host_buffer)
inlineprotected

Definition at line 325 of file content_context.h.

325 {
326 data_host_buffer_ = std::move(host_buffer);
327 }

Referenced by impeller::testing::FlushTestContentContext::FlushTestContentContext().

◆ SetTransientsIndexesBuffer()

void impeller::ContentContext::SetTransientsIndexesBuffer ( std::shared_ptr< HostBuffer host_buffer)
inlineprotected

Definition at line 320 of file content_context.h.

320 {
321 indexes_host_buffer_ = std::move(host_buffer);
322 }

Referenced by impeller::testing::FlushTestContentContext::FlushTestContentContext().


The documentation for this class was generated from the following files: