19 auto contents = std::make_shared<FramebufferBlendContents>();
20 contents->SetChildContents(src_contents);
37 const Color& clear_color) {
38 const std::shared_ptr<Context>& context = renderer.GetContext();
52 if (context->GetCapabilities()->SupportsOffscreenMSAA()) {
53 target = renderer.GetRenderTargetCache()->CreateOffscreenMSAA(
64 .clear_color = clear_color},
68 target = renderer.GetRenderTargetCache()->CreateOffscreen(
77 .clear_color = clear_color,
83 return std::make_unique<EntityPassTarget>(
84 target, renderer.GetDeviceCapabilities().SupportsReadFromResolve(),
85 renderer.GetDeviceCapabilities().SupportsImplicitResolvingMSAA());
90 :
Canvas(), renderer_(renderer), render_target_(render_target) {
97 :
Canvas(cull_rect), renderer_(renderer), render_target_(render_target) {
104 :
Canvas(cull_rect), renderer_(renderer), render_target_(render_target) {
108void ExperimentalCanvas::SetupRenderPass() {
113 if (!stencil_attachment.has_value() || !depth_attachment.has_value()) {
118 *renderer_.
GetContext()->GetResourceAllocator(),
119 color0.texture->GetSize(),
120 renderer_.
GetContext()->GetCapabilities()->SupportsOffscreenMSAA(),
128 entity_pass_targets_.push_back(std::make_unique<EntityPassTarget>(
133 auto inline_pass = std::make_unique<InlinePassContext>(
134 renderer_, *entity_pass_targets_.back(), 0);
135 inline_pass_contexts_.emplace_back(std::move(inline_pass));
136 auto result = inline_pass_contexts_.back()->GetRenderPass(0u);
137 render_passes_.push_back(
result.pass);
149 <<
" after allocating " << total_content_depth;
157 std::optional<Rect> bounds,
158 const std::shared_ptr<ImageFilter>& backdrop_filter,
160 uint32_t total_content_depth) {
163 if (!bounds.has_value()) {
170 subpass_coverage.
GetSize().height),
172 entity_pass_targets_.push_back(std::move(
target));
181 <<
" after allocating " << total_content_depth;
186 auto inline_pass = std::make_unique<InlinePassContext>(
187 renderer_, *entity_pass_targets_.back(), 0);
188 inline_pass_contexts_.emplace_back(std::move(inline_pass));
190 auto result = inline_pass_contexts_.back()->GetRenderPass(0u);
191 render_passes_.push_back(
result.pass);
219 auto inline_pass = std::move(inline_pass_contexts_.back());
222 save_layer_state_.pop_back();
224 std::shared_ptr<Contents> contents =
229 inline_pass->EndPass();
230 render_passes_.pop_back();
231 inline_pass_contexts_.pop_back();
244 VALIDATION_LOG <<
"Emulated advanced blends are currently unsupported.";
249 element_entity.
Render(renderer_, *render_passes_.back());
258 const std::shared_ptr<TextFrame>& text_frame,
265 auto text_contents = std::make_shared<TextContents>();
266 text_contents->SetTextFrame(text_frame);
267 text_contents->SetColor(
paint.color);
268 text_contents->SetForceTextColor(
paint.mask_blur_descriptor.has_value());
281 paint.WithFilters(
paint.WithMaskBlur(std::move(text_contents),
true)));
305 VALIDATION_LOG <<
"Emulated advanced blends are currently unsupported.";
310 entity.
Render(renderer_, *render_passes_.back());
330 entity.
Render(renderer_, *render_passes_.back());
const Matrix & GetCurrentTransform() const
size_t GetClipHeight() const
std::deque< CanvasStackEntry > transform_stack_
virtual bool SupportsImplicitResolvingMSAA() const =0
Whether the context backend supports multisampled rendering to the on-screen surface without requirin...
virtual bool SupportsFramebufferFetch() const =0
Whether the context backend is able to support pipelines with shaders that read from the framebuffer ...
virtual bool SupportsReadFromResolve() const =0
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
const Capabilities & GetDeviceCapabilities() const
std::shared_ptr< Context > GetContext() const
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
const std::shared_ptr< Contents > & GetContents() const
void SetClipDepth(uint32_t clip_depth)
BlendMode GetBlendMode() const
void SetContents(std::shared_ptr< Contents > contents)
void SetBlendMode(BlendMode blend_mode)
bool Render(const ContentContext &renderer, RenderPass &parent_pass) const
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
static constexpr BlendMode kLastPipelineBlendMode
void DrawTextFrame(const std::shared_ptr< TextFrame > &text_frame, Point position, const Paint &paint) override
void SaveLayer(const Paint &paint, std::optional< Rect > bounds, const std::shared_ptr< ImageFilter > &backdrop_filter, ContentBoundsPromise bounds_promise, uint32_t total_content_depth) override
void Save(uint32_t total_content_depth) override
ExperimentalCanvas(ContentContext &renderer, RenderTarget &render_target)
void AddClipEntityToCurrentPass(Entity entity) override
void AddRenderEntityToCurrentPass(Entity entity, bool reuse_depth) override
std::shared_ptr< Contents > CreateContentsForSubpassTarget(std::shared_ptr< Texture > target, const Matrix &effect_transform) override
const std::map< size_t, ColorAttachment > & GetColorAttachments() const
RenderTarget & SetColorAttachment(const ColorAttachment &attachment, size_t index)
void SetupDepthStencilAttachments(const Context &context, Allocator &allocator, ISize size, bool msaa, const std::string &label="Offscreen", RenderTarget::AttachmentConfig stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &depth_stencil_texture=nullptr)
ISize GetRenderTargetSize() const
const std::optional< DepthAttachment > & GetDepthAttachment() const
const std::optional< StencilAttachment > & GetStencilAttachment() const
#define FML_CHECK(condition)
#define FML_DCHECK(condition)
static std::unique_ptr< EntityPassTarget > CreateRenderTarget(ContentContext &renderer, ISize size, int mip_count, const Color &clear_color)
static void ApplyFramebufferBlend(Entity &entity)
static const constexpr RenderTarget::AttachmentConfig kDefaultStencilConfig
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Entity::RenderingMode rendering_mode
std::optional< Rect > cull_rect
static constexpr Color BlackTransparent()
static constexpr Matrix MakeTranslation(const Vector3 &t)
constexpr TSize< Type > GetSize() const
Returns the size of the rectangle which may be negative in either width or height and may have been c...
static constexpr TRect MakeSize(const TSize< U > &size)
constexpr TPoint< Type > GetOrigin() const
Returns the upper left corner of the rectangle as specified by the left/top or x/y values when it was...
static constexpr TSize MakeWH(Type width, Type height)