| Flutter Impeller |

canvas.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/display_list/canvas.h"
6
7 #include <memory>
8 #include <optional>
9 #include <unordered_map>
10 #include <utility>
11
12 #include "display_list/effects/color_filters/dl_blend_color_filter.h"
13 #include "display_list/effects/color_filters/dl_matrix_color_filter.h"
14 #include "display_list/effects/dl_color_filter.h"
15 #include "display_list/effects/dl_color_source.h"
16 #include "display_list/effects/dl_image_filter.h"
17 #include "display_list/image/dl_image.h"
18 #include "flutter/fml/logging.h"
19 #include "flutter/fml/trace_event.h"
20 #include "impeller/base/validation.h"
21 #include "impeller/core/formats.h"
22 #include "impeller/display_list/color_filter.h"
23 #include "impeller/display_list/image_filter.h"
24 #include "impeller/display_list/skia_conversions.h"
25 #include "impeller/entity/contents/atlas_contents.h"
26 #include "impeller/entity/contents/clip_contents.h"
27 #include "impeller/entity/contents/color_source_contents.h"
28 #include "impeller/entity/contents/content_context.h"
29 #include "impeller/entity/contents/filters/filter_contents.h"
30 #include "impeller/entity/contents/framebuffer_blend_contents.h"
31 #include "impeller/entity/contents/line_contents.h"
32 #include "impeller/entity/contents/solid_rrect_blur_contents.h"
33 #include "impeller/entity/contents/solid_rsuperellipse_blur_contents.h"
34 #include "impeller/entity/contents/text_contents.h"
35 #include "impeller/entity/contents/text_shadow_cache.h"
36 #include "impeller/entity/contents/texture_contents.h"
37 #include "impeller/entity/contents/vertices_contents.h"
38 #include "impeller/entity/geometry/arc_geometry.h"
39 #include "impeller/entity/geometry/circle_geometry.h"
40 #include "impeller/entity/geometry/cover_geometry.h"
41 #include "impeller/entity/geometry/ellipse_geometry.h"
42 #include "impeller/entity/geometry/fill_path_geometry.h"
43 #include "impeller/entity/geometry/geometry.h"
44 #include "impeller/entity/geometry/line_geometry.h"
45 #include "impeller/entity/geometry/point_field_geometry.h"
46 #include "impeller/entity/geometry/rect_geometry.h"
47 #include "impeller/entity/geometry/stroke_path_geometry.h"
48 #include "impeller/entity/save_layer_utils.h"
49 #include "impeller/geometry/color.h"
50 #include "impeller/geometry/constants.h"
51 #include "impeller/geometry/rstransform.h"
52 #include "impeller/renderer/command_buffer.h"
53
54 namespace impeller {
55
56 namespace {
57
58 bool IsPipelineBlendOrMatrixFilter(const flutter::DlColorFilter* filter) {
59 return filter->type() == flutter::DlColorFilterType::kMatrix ||
60 (filter->type() == flutter::DlColorFilterType::kBlend &&
61 filter->asBlend()->mode() <= Entity::kLastPipelineBlendMode);
62 }
63
64 static bool UseColorSourceContents(
65 const std::shared_ptr<VerticesGeometry>& vertices,
66 const Paint& paint) {
67 // If there are no vertex color or texture coordinates. Or if there
68 // are vertex coordinates but its just a color.
69 if (vertices->HasVertexColors()) {
70 return false;
71 }
72 if (vertices->HasTextureCoordinates() && !paint.color_source) {
73 return true;
74 }
75 return !vertices->HasTextureCoordinates();
76 }
77
78 static void SetClipScissor(std::optional<Rect> clip_coverage,
79 RenderPass& pass,
80 Point global_pass_position) {
81 // Set the scissor to the clip coverage area. We do this prior to rendering
82 // the clip itself and all its contents.
83 IRect scissor;
84 if (clip_coverage.has_value()) {
85 clip_coverage = clip_coverage->Shift(-global_pass_position);
86 scissor = IRect::RoundOut(clip_coverage.value());
87 // The scissor rect must not exceed the size of the render target.
88 scissor = scissor.Intersection(IRect::MakeSize(pass.GetRenderTargetSize()))
89 .value_or(IRect());
90 }
91 pass.SetScissor(scissor);
92 }
93
94 static void ApplyFramebufferBlend(Entity& entity) {
95 auto src_contents = entity.GetContents();
96 auto contents = std::make_shared<FramebufferBlendContents>();
97 contents->SetChildContents(src_contents);
98 contents->SetBlendMode(entity.GetBlendMode());
99 entity.SetContents(std::move(contents));
100 entity.SetBlendMode(BlendMode::kSrc);
101 }
102
103 /// @brief Create the subpass restore contents, appling any filters or opacity
104 /// from the provided paint object.
105 static std::shared_ptr<Contents> CreateContentsForSubpassTarget(
106 const Paint& paint,
107 const std::shared_ptr<Texture>& target,
108 const Matrix& effect_transform) {
109 auto contents = TextureContents::MakeRect(Rect::MakeSize(target->GetSize()));
110 contents->SetTexture(target);
111 contents->SetLabel("Subpass");
112 contents->SetSourceRect(Rect::MakeSize(target->GetSize()));
113 contents->SetOpacity(paint.color.alpha);
114 contents->SetDeferApplyingOpacity(true);
115
116 return paint.WithFiltersForSubpassTarget(std::move(contents),
117 effect_transform);
118 }
119
120 static const constexpr RenderTarget::AttachmentConfig kDefaultStencilConfig =
121 RenderTarget::AttachmentConfig{
122 .storage_mode = StorageMode::kDeviceTransient,
123 .load_action = LoadAction::kDontCare,
124 .store_action = StoreAction::kDontCare,
125 };
126
127 static std::unique_ptr<EntityPassTarget> CreateRenderTarget(
128 ContentContext& renderer,
129 ISize size,
130 const Color& clear_color) {
131 const std::shared_ptr<Context>& context = renderer.GetContext();
132
133 /// All of the load/store actions are managed by `InlinePassContext` when
134 /// `RenderPasses` are created, so we just set them to `kDontCare` here.
135 /// What's important is the `StorageMode` of the textures, which cannot be
136 /// changed for the lifetime of the textures.
137
138 RenderTarget target;
139 if (context->GetCapabilities()->SupportsOffscreenMSAA()) {
140 target = renderer.GetRenderTargetCache()->CreateOffscreenMSAA(
141 /*context=*/*context,
142 /*size=*/size,
143 /*mip_count=*/1,
144 /*label=*/"EntityPass",
145 /*color_attachment_config=*/
146 RenderTarget::AttachmentConfigMSAA{
147 .storage_mode = StorageMode::kDeviceTransient,
148 .resolve_storage_mode = StorageMode::kDevicePrivate,
149 .load_action = LoadAction::kDontCare,
150 .store_action = StoreAction::kMultisampleResolve,
151 .clear_color = clear_color},
152 /*stencil_attachment_config=*/kDefaultStencilConfig);
153 } else {
154 target = renderer.GetRenderTargetCache()->CreateOffscreen(
155 *context, // context
156 size, // size
157 /*mip_count=*/1,
158 "EntityPass", // label
159 RenderTarget::AttachmentConfig{
160 .storage_mode = StorageMode::kDevicePrivate,
161 .load_action = LoadAction::kDontCare,
162 .store_action = StoreAction::kDontCare,
163 .clear_color = clear_color,
164 }, // color_attachment_config
165 kDefaultStencilConfig //
166 );
167 }
168
169 return std::make_unique<EntityPassTarget>(
170 target, //
171 renderer.GetDeviceCapabilities().SupportsReadFromResolve(), //
172 renderer.GetDeviceCapabilities().SupportsImplicitResolvingMSAA() //
173 );
174 }
175
176 } // namespace
177
178 std::shared_ptr<SolidRRectLikeBlurContents>
179 Canvas::RRectBlurShape::BuildBlurContent() {
180 return std::make_shared<SolidRRectBlurContents>();
181 }
182
183 Geometry& Canvas::RRectBlurShape::BuildGeometry(Rect rect, Scalar radius) {
184 return geom_.emplace(rect, Size{radius, radius});
185 }
186
187 std::shared_ptr<SolidRRectLikeBlurContents>
188 Canvas::RSuperellipseBlurShape::BuildBlurContent() {
189 return std::make_shared<SolidRSuperellipseBlurContents>();
190 }
191
192 Geometry& Canvas::RSuperellipseBlurShape::BuildGeometry(Rect rect,
193 Scalar radius) {
194 return geom_.emplace(rect, radius);
195 }
196
197 Canvas::Canvas(ContentContext& renderer,
198 const RenderTarget& render_target,
199 bool is_onscreen,
200 bool requires_readback)
201 : renderer_(renderer),
202 render_target_(render_target),
203 is_onscreen_(is_onscreen),
204 requires_readback_(requires_readback),
205 clip_coverage_stack_(EntityPassClipStack(
206 Rect::MakeSize(render_target.GetRenderTargetSize()))) {
207 Initialize(std::nullopt);
208 SetupRenderPass();
209 }
210
211 Canvas::Canvas(ContentContext& renderer,
212 const RenderTarget& render_target,
213 bool is_onscreen,
214 bool requires_readback,
215 Rect cull_rect)
216 : renderer_(renderer),
217 render_target_(render_target),
218 is_onscreen_(is_onscreen),
219 requires_readback_(requires_readback),
220 clip_coverage_stack_(EntityPassClipStack(
221 Rect::MakeSize(render_target.GetRenderTargetSize()))) {
222 Initialize(cull_rect);
223 SetupRenderPass();
224 }
225
226 Canvas::Canvas(ContentContext& renderer,
227 const RenderTarget& render_target,
228 bool is_onscreen,
229 bool requires_readback,
230 IRect cull_rect)
231 : renderer_(renderer),
232 render_target_(render_target),
233 is_onscreen_(is_onscreen),
234 requires_readback_(requires_readback),
235 clip_coverage_stack_(EntityPassClipStack(
236 Rect::MakeSize(render_target.GetRenderTargetSize()))) {
237 Initialize(Rect::MakeLTRB(cull_rect.GetLeft(), cull_rect.GetTop(),
238 cull_rect.GetRight(), cull_rect.GetBottom()));
239 SetupRenderPass();
240 }
241
242 void Canvas::Initialize(std::optional<Rect> cull_rect) {
243 initial_cull_rect_ = cull_rect;
244 transform_stack_.emplace_back(CanvasStackEntry{
245 .clip_depth = kMaxDepth,
246 });
247 FML_DCHECK(GetSaveCount() == 1u);
248 }
249
250 void Canvas::Reset() {
251 current_depth_ = 0u;
252 transform_stack_ = {};
253 }
254
255 void Canvas::Concat(const Matrix& transform) {
256 transform_stack_.back().transform = GetCurrentTransform() * transform;
257 }
258
259 void Canvas::PreConcat(const Matrix& transform) {
260 transform_stack_.back().transform = transform * GetCurrentTransform();
261 }
262
263 void Canvas::ResetTransform() {
264 transform_stack_.back().transform = {};
265 }
266
267 void Canvas::Transform(const Matrix& transform) {
268 Concat(transform);
269 }
270
271 const Matrix& Canvas::GetCurrentTransform() const {
272 return transform_stack_.back().transform;
273 }
274
275 void Canvas::Translate(const Vector3& offset) {
276 Concat(Matrix::MakeTranslation(offset));
277 }
278
279 void Canvas::Scale(const Vector2& scale) {
280 Concat(Matrix::MakeScale(scale));
281 }
282
283 void Canvas::Scale(const Vector3& scale) {
284 Concat(Matrix::MakeScale(scale));
285 }
286
287 void Canvas::Skew(Scalar sx, Scalar sy) {
288 Concat(Matrix::MakeSkew(sx, sy));
289 }
290
291 void Canvas::Rotate(Radians radians) {
292 Concat(Matrix::MakeRotationZ(radians));
293 }
294
295 Point Canvas::GetGlobalPassPosition() const {
296 if (save_layer_state_.empty()) {
297 return Point(0, 0);
298 }
299 return save_layer_state_.back().coverage.GetOrigin();
300 }
301
302 // clip depth of the previous save or 0.
303 size_t Canvas::GetClipHeightFloor() const {
304 if (transform_stack_.size() > 1) {
305 return transform_stack_[transform_stack_.size() - 2].clip_height;
306 }
307 return 0;
308 }
309
310 size_t Canvas::GetSaveCount() const {
311 return transform_stack_.size();
312 }
313
314 bool Canvas::IsSkipping() const {
315 return transform_stack_.back().skipping;
316 }
317
318 void Canvas::RestoreToCount(size_t count) {
319 while (GetSaveCount() > count) {
320 if (!Restore()) {
321 return;
322 }
323 }
324 }
325
326 void Canvas::DrawPath(const flutter::DlPath& path, const Paint& paint) {
327 Entity entity;
328 entity.SetTransform(GetCurrentTransform());
329 entity.SetBlendMode(paint.blend_mode);
330
331 if (paint.style == Paint::Style::kFill) {
332 FillPathGeometry geom(path);
333 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
334 } else {
335 StrokePathGeometry geom(path, paint.stroke);
336 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
337 }
338 }
339
340 void Canvas::DrawPaint(const Paint& paint) {
341 Entity entity;
342 entity.SetTransform(GetCurrentTransform());
343 entity.SetBlendMode(paint.blend_mode);
344
345 CoverGeometry geom;
346 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
347 }
348
349 // Optimization: if the texture has a color filter that is a simple
350 // porter-duff blend or matrix filter, then instead of performing a save layer
351 // we should swap out the shader for the porter duff blend shader and avoid a
352 // saveLayer. This optimization is important for Flame.
353 bool Canvas::AttemptColorFilterOptimization(
354 const std::shared_ptr<Texture>& image,
355 Rect source,
356 Rect dest,
357 const Paint& paint,
358 const SamplerDescriptor& sampler,
359 SourceRectConstraint src_rect_constraint) {
360 if (!paint.color_filter || //
361 paint.image_filter != nullptr || //
362 paint.invert_colors || //
363 paint.mask_blur_descriptor.has_value() || //
364 !IsPipelineBlendOrMatrixFilter(paint.color_filter)) {
365 return false;
366 }
367
368 if (paint.color_filter->type() == flutter::DlColorFilterType::kBlend) {
369 const flutter::DlBlendColorFilter* blend_filter =
370 paint.color_filter->asBlend();
371 DrawImageRectAtlasGeometry geometry = DrawImageRectAtlasGeometry(
372 /*texture=*/image,
373 /*source=*/source,
374 /*destination=*/dest,
375 /*color=*/skia_conversions::ToColor(blend_filter->color()),
376 /*blend_mode=*/blend_filter->mode(),
377 /*desc=*/sampler,
378 /*use_strict_src_rect=*/src_rect_constraint ==
379 SourceRectConstraint::kStrict);
380
381 auto atlas_contents = std::make_shared<AtlasContents>();
382 atlas_contents->SetGeometry(&geometry);
383 atlas_contents->SetAlpha(paint.color.alpha);
384
385 Entity entity;
386 entity.SetTransform(GetCurrentTransform());
387 entity.SetBlendMode(paint.blend_mode);
388 entity.SetContents(atlas_contents);
389
390 AddRenderEntityToCurrentPass(entity);
391 } else {
392 // src_rect_constraint is only supported in the porter-duff mode
393 // for now.
394 if (src_rect_constraint == SourceRectConstraint::kStrict) {
395 return false;
396 }
397
398 const flutter::DlMatrixColorFilter* matrix_filter =
399 paint.color_filter->asMatrix();
400
401 DrawImageRectAtlasGeometry geometry = DrawImageRectAtlasGeometry(
402 /*texture=*/image,
403 /*source=*/source,
404 /*destination=*/dest,
405 /*color=*/Color::Khaki(), // ignored
406 /*blend_mode=*/BlendMode::kSrcOver, // ignored
407 /*desc=*/sampler,
408 /*use_strict_src_rect=*/src_rect_constraint ==
409 SourceRectConstraint::kStrict);
410
411 auto atlas_contents = std::make_shared<ColorFilterAtlasContents>();
412 atlas_contents->SetGeometry(&geometry);
413 atlas_contents->SetAlpha(paint.color.alpha);
414 impeller::ColorMatrix color_matrix;
415 matrix_filter->get_matrix(color_matrix.array);
416 atlas_contents->SetMatrix(color_matrix);
417
418 Entity entity;
419 entity.SetTransform(GetCurrentTransform());
420 entity.SetBlendMode(paint.blend_mode);
421 entity.SetContents(atlas_contents);
422
423 AddRenderEntityToCurrentPass(entity);
424 }
425 return true;
426 }
427
428 bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
429 Size corner_radii,
430 const Paint& paint) {
431 RRectBlurShape rrect_shape;
432 return AttemptDrawBlurredRRectLike(rect, corner_radii, paint, rrect_shape);
433 }
434
435 bool Canvas::AttemptDrawBlurredRSuperellipse(const Rect& rect,
436 Size corner_radii,
437 const Paint& paint) {
438 RSuperellipseBlurShape rsuperellipse_shape;
439 return AttemptDrawBlurredRRectLike(rect, corner_radii, paint,
440 rsuperellipse_shape);
441 }
442
443 bool Canvas::AttemptDrawBlurredRRectLike(const Rect& rect,
444 Size corner_radii,
445 const Paint& paint,
446 RRectLikeBlurShape& shape) {
447 if (paint.style != Paint::Style::kFill) {
448 return false;
449 }
450
451 if (paint.color_source) {
452 return false;
453 }
454
455 if (!paint.mask_blur_descriptor.has_value()) {
456 return false;
457 }
458
459 // A blur sigma that is not positive enough should not result in a blur.
460 if (paint.mask_blur_descriptor->sigma.sigma <= kEhCloseEnough) {
461 return false;
462 }
463
464 // The current rrect blur math doesn't work on ovals.
465 if (fabsf(corner_radii.width - corner_radii.height) > kEhCloseEnough) {
466 return false;
467 }
468 Scalar corner_radius = corner_radii.width;
469
470 // For symmetrically mask blurred solid RRects, absorb the mask blur and use
471 // a faster SDF approximation.
472 Color rrect_color = paint.color;
473 if (paint.invert_colors) {
474 rrect_color = rrect_color.ApplyColorMatrix(kColorInversion);
475 }
476 if (paint.color_filter) {
477 rrect_color = GetCPUColorFilterProc(paint.color_filter)(rrect_color);
478 }
479
480 Paint rrect_paint = {.mask_blur_descriptor = paint.mask_blur_descriptor};
481
482 // In some cases, we need to render the mask blur to a separate layer.
483 //
484 // 1. If the blur style is normal, we'll be drawing using one draw call and
485 // no clips. And so we can just wrap the RRect contents with the
486 // ImageFilter, which will get applied to the result as per usual.
487 //
488 // 2. If the blur style is solid, we combine the non-blurred RRect with the
489 // blurred RRect via two separate draw calls, and so we need to defer any
490 // fancy blending, translucency, or image filtering until after these two
491 // draws have been combined in a separate layer.
492 //
493 // 3. If the blur style is outer or inner, we apply the blur style via a
494 // clip. The ImageFilter needs to be applied to the mask blurred result.
495 // And so if there's an ImageFilter, we need to defer applying it until
496 // after the clipped RRect blur has been drawn to a separate texture.
497 // However, since there's only one draw call that produces color, we
498 // don't need to worry about the blend mode or translucency (unlike with
499 // BlurStyle::kSolid).
500 //
501 if ((paint.mask_blur_descriptor->style !=
502 FilterContents::BlurStyle::kNormal &&
503 paint.image_filter) ||
504 (paint.mask_blur_descriptor->style == FilterContents::BlurStyle::kSolid &&
505 (!rrect_color.IsOpaque() || paint.blend_mode != BlendMode::kSrcOver))) {
506 Rect render_bounds = rect;
507 if (paint.mask_blur_descriptor->style !=
508 FilterContents::BlurStyle::kInner) {
509 render_bounds =
510 render_bounds.Expand(paint.mask_blur_descriptor->sigma.sigma * 4.0);
511 }
512 // Defer the alpha, blend mode, and image filter to a separate layer.
513 SaveLayer(
514 Paint{
515 .color = Color::White().WithAlpha(rrect_color.alpha),
516 .image_filter = paint.image_filter,
517 .blend_mode = paint.blend_mode,
518 },
519 render_bounds, nullptr, ContentBoundsPromise::kContainsContents, 1u);
520 rrect_paint.color = rrect_color.WithAlpha(1);
521 } else {
522 rrect_paint.color = rrect_color;
523 rrect_paint.blend_mode = paint.blend_mode;
524 rrect_paint.image_filter = paint.image_filter;
525 Save(1u);
526 }
527
528 auto draw_blurred_rrect = [this, &rect, corner_radius, &rrect_paint,
529 &shape]() {
530 auto contents = shape.BuildBlurContent();
531
532 contents->SetColor(rrect_paint.color);
533 contents->SetSigma(rrect_paint.mask_blur_descriptor->sigma);
534 contents->SetShape(rect, corner_radius);
535
536 Entity blurred_rrect_entity;
537 blurred_rrect_entity.SetTransform(GetCurrentTransform());
538 blurred_rrect_entity.SetBlendMode(rrect_paint.blend_mode);
539
540 rrect_paint.mask_blur_descriptor = std::nullopt;
541 blurred_rrect_entity.SetContents(
542 rrect_paint.WithFilters(std::move(contents)));
543 AddRenderEntityToCurrentPass(blurred_rrect_entity);
544 };
545
546 switch (rrect_paint.mask_blur_descriptor->style) {
547 case FilterContents::BlurStyle::kNormal: {
548 draw_blurred_rrect();
549 break;
550 }
551 case FilterContents::BlurStyle::kSolid: {
552 // First, draw the blurred RRect.
553 draw_blurred_rrect();
554 // Then, draw the non-blurred RRect on top.
555 Entity entity;
556 entity.SetTransform(GetCurrentTransform());
557 entity.SetBlendMode(rrect_paint.blend_mode);
558
559 Geometry& geom = shape.BuildGeometry(rect, corner_radius);
560 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, rrect_paint,
561 /*reuse_depth=*/true);
562 break;
563 }
564 case FilterContents::BlurStyle::kOuter: {
565 Geometry& geom = shape.BuildGeometry(rect, corner_radius);
566 ClipGeometry(geom, Entity::ClipOperation::kDifference);
567 draw_blurred_rrect();
568 break;
569 }
570 case FilterContents::BlurStyle::kInner: {
571 Geometry& geom = shape.BuildGeometry(rect, corner_radius);
572 ClipGeometry(geom, Entity::ClipOperation::kIntersect);
573 draw_blurred_rrect();
574 break;
575 }
576 }
577
578 Restore();
579
580 return true;
581 }
582
583 void Canvas::DrawLine(const Point& p0,
584 const Point& p1,
585 const Paint& paint,
586 bool reuse_depth) {
587 Entity entity;
588 entity.SetTransform(GetCurrentTransform());
589 entity.SetBlendMode(paint.blend_mode);
590
591 auto geometry = std::make_unique<LineGeometry>(p0, p1, paint.stroke);
592
593 if (renderer_.GetContext()->GetFlags().antialiased_lines &&
594 !paint.color_filter && !paint.invert_colors && !paint.image_filter &&
595 !paint.mask_blur_descriptor.has_value() && !paint.color_source) {
596 auto contents = LineContents::Make(std::move(geometry), paint.color);
597 entity.SetContents(std::move(contents));
598 AddRenderEntityToCurrentPass(entity, reuse_depth);
599 } else {
600 AddRenderEntityWithFiltersToCurrentPass(entity, geometry.get(), paint,
601 /*reuse_depth=*/reuse_depth);
602 }
603 }
604
605 void Canvas::DrawDashedLine(const Point& p0,
606 const Point& p1,
607 Scalar on_length,
608 Scalar off_length,
609 const Paint& paint) {
610 // Reasons to defer to regular DrawLine:
611 // - performance for degenerate and "regular line" cases
612 // - length is non-positive - DrawLine will draw appropriate "dot"
613 // - off_length is non-positive - no gaps, DrawLine will draw it solid
614 // - on_length is negative - invalid dashing
615 //
616 // Note that a 0 length "on" dash will draw "dot"s every "off" distance
617 // apart so we proceed with the dashing process in that case.
618 Scalar length = p0.GetDistance(p1);
619 if (length > 0.0f && on_length >= 0.0f && off_length > 0.0f) {
620 Entity entity;
621 entity.SetTransform(GetCurrentTransform());
622 entity.SetBlendMode(paint.blend_mode);
623
624 StrokeDashedLineGeometry geom(p0, p1, on_length, off_length, paint.stroke);
625 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
626 } else {
627 DrawLine(p0, p1, paint);
628 }
629 }
630
631 void Canvas::DrawRect(const Rect& rect, const Paint& paint) {
632 if (AttemptDrawBlurredRRect(rect, {}, paint)) {
633 return;
634 }
635
636 Entity entity;
637 entity.SetTransform(GetCurrentTransform());
638 entity.SetBlendMode(paint.blend_mode);
639
640 if (paint.style == Paint::Style::kStroke) {
641 StrokeRectGeometry geom(rect, paint.stroke);
642 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
643 } else {
644 FillRectGeometry geom(rect);
645 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
646 }
647 }
648
649 void Canvas::DrawOval(const Rect& rect, const Paint& paint) {
650 // TODO(jonahwilliams): This additional condition avoids an assert in the
651 // stroke circle geometry generator. I need to verify the condition that this
652 // assert prevents.
653 if (rect.IsSquare() && (paint.style == Paint::Style::kFill ||
654 (paint.style == Paint::Style::kStroke &&
655 paint.stroke.width < rect.GetWidth()))) {
656 // Circles have slightly less overhead and can do stroking
657 DrawCircle(rect.GetCenter(), rect.GetWidth() * 0.5f, paint);
658 return;
659 }
660
661 if (AttemptDrawBlurredRRect(rect, rect.GetSize() * 0.5f, paint)) {
662 return;
663 }
664
665 Entity entity;
666 entity.SetTransform(GetCurrentTransform());
667 entity.SetBlendMode(paint.blend_mode);
668
669 if (paint.style == Paint::Style::kStroke) {
670 StrokeEllipseGeometry geom(rect, paint.stroke);
671 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
672 } else {
673 EllipseGeometry geom(rect);
674 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
675 }
676 }
677
678 void Canvas::DrawArc(const Arc& arc, const Paint& paint) {
679 Entity entity;
680 entity.SetTransform(GetCurrentTransform());
681 entity.SetBlendMode(paint.blend_mode);
682
683 if (paint.style == Paint::Style::kFill) {
684 ArcGeometry geom(arc);
685 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
686 return;
687 }
688
689 const Rect& oval_bounds = arc.GetOvalBounds();
690 if (paint.stroke.width > oval_bounds.GetSize().MaxDimension()) {
691 // This is a special case for rendering arcs whose stroke width is so large
692 // you are effectively drawing a sector of a circle.
693 // https://github.com/flutter/flutter/issues/158567
694 Arc expanded_arc(oval_bounds.Expand(Size(paint.stroke.width * 0.5f)),
695 arc.GetStart(), arc.GetSweep(), true);
696
697 ArcGeometry geom(expanded_arc);
698 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
699 return;
700 }
701
702 // IncludeCenter incurs lots of extra work for stroking an arc, including:
703 // - It introduces segments to/from the center point (not too hard).
704 // - It introduces joins on those segments (a bit more complicated).
705 // - Even if the sweep is >=360 degrees, we still draw the segment to
706 // the center and it basically looks like a pie cut into the complete
707 // boundary circle, as if the slice were cut, but not extracted
708 // (hard to express as a continuous kTriangleStrip).
709 if (!arc.IncludeCenter()) {
710 if (arc.IsFullCircle()) {
711 return DrawOval(oval_bounds, paint);
712 }
713
714 // Our fast stroking code only works for circular bounds as it assumes
715 // that the inner and outer radii can be scaled along each angular step
716 // of the arc - which is not true for elliptical arcs where the inner
717 // and outer samples are perpendicular to the traveling direction of the
718 // elliptical curve which may not line up with the center of the bounds.
719 //
720 // TODO(flar): It also only supports Butt and Square caps for now.
721 // See https://github.com/flutter/flutter/issues/169400
722 if (oval_bounds.IsSquare() && paint.stroke.cap != Cap::kRound) {
723 ArcGeometry geom(arc, paint.stroke);
724 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
725 return;
726 }
727 }
728
729 ArcStrokeGeometry geom(arc, paint.stroke);
730 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
731 }
732
733 void Canvas::DrawRoundRect(const RoundRect& round_rect, const Paint& paint) {
734 auto& rect = round_rect.GetBounds();
735 auto& radii = round_rect.GetRadii();
736 if (radii.AreAllCornersSame()) {
737 if (AttemptDrawBlurredRRect(rect, radii.top_left, paint)) {
738 return;
739 }
740
741 if (paint.style == Paint::Style::kFill) {
742 Entity entity;
743 entity.SetTransform(GetCurrentTransform());
744 entity.SetBlendMode(paint.blend_mode);
745
746 RoundRectGeometry geom(rect, radii.top_left);
747 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
748 return;
749 }
750 }
751
752 Entity entity;
753 entity.SetTransform(GetCurrentTransform());
754 entity.SetBlendMode(paint.blend_mode);
755
756 if (paint.style == Paint::Style::kFill) {
757 FillRoundRectGeometry geom(round_rect);
758 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
759 } else {
760 StrokeRoundRectGeometry geom(round_rect, paint.stroke);
761 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
762 }
763 }
764
765 void Canvas::DrawDiffRoundRect(const RoundRect& outer,
766 const RoundRect& inner,
767 const Paint& paint) {
768 Entity entity;
769 entity.SetTransform(GetCurrentTransform());
770 entity.SetBlendMode(paint.blend_mode);
771
772 if (paint.style == Paint::Style::kFill) {
773 FillDiffRoundRectGeometry geom(outer, inner);
774 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
775 } else {
776 StrokeDiffRoundRectGeometry geom(outer, inner, paint.stroke);
777 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
778 }
779 }
780
781 void Canvas::DrawRoundSuperellipse(const RoundSuperellipse& round_superellipse,
782 const Paint& paint) {
783 auto& rect = round_superellipse.GetBounds();
784 auto& radii = round_superellipse.GetRadii();
785 if (radii.AreAllCornersSame() &&
786 AttemptDrawBlurredRSuperellipse(rect, radii.top_left, paint)) {
787 return;
788 }
789
790 Entity entity;
791 entity.SetTransform(GetCurrentTransform());
792 entity.SetBlendMode(paint.blend_mode);
793
794 if (paint.style == Paint::Style::kFill) {
795 RoundSuperellipseGeometry geom(rect, radii);
796 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
797 } else {
798 StrokeRoundSuperellipseGeometry geom(round_superellipse, paint.stroke);
799 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
800 }
801 }
802
803 void Canvas::DrawCircle(const Point& center,
804 Scalar radius,
805 const Paint& paint) {
806 Size half_size(radius, radius);
807 if (AttemptDrawBlurredRRect(
808 Rect::MakeOriginSize(center - half_size, half_size * 2),
809 {radius, radius}, paint)) {
810 return;
811 }
812
813 Entity entity;
814 entity.SetTransform(GetCurrentTransform());
815 entity.SetBlendMode(paint.blend_mode);
816
817 if (paint.style == Paint::Style::kStroke) {
818 CircleGeometry geom(center, radius, paint.stroke.width);
819 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
820 } else {
821 CircleGeometry geom(center, radius);
822 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
823 }
824 }
825
826 void Canvas::ClipGeometry(const Geometry& geometry,
827 Entity::ClipOperation clip_op,
828 bool is_aa) {
829 if (IsSkipping()) {
830 return;
831 }
832
833 // Ideally the clip depth would be greater than the current rendering
834 // depth because any rendering calls that follow this clip operation will
835 // pre-increment the depth and then be rendering above our clip depth,
836 // but that case will be caught by the CHECK in AddRenderEntity above.
837 // In practice we sometimes have a clip set with no rendering after it
838 // and in such cases the current depth will equal the clip depth.
839 // Eventually the DisplayList should optimize these out, but it is hard
840 // to know if a clip will actually be used in advance of storing it in
841 // the DisplayList buffer.
842 // See https://github.com/flutter/flutter/issues/147021
843 FML_DCHECK(current_depth_ <= transform_stack_.back().clip_depth)
844 << current_depth_ << " <=? " << transform_stack_.back().clip_depth;
845 uint32_t clip_depth = transform_stack_.back().clip_depth;
846
847 const Matrix clip_transform =
848 Matrix::MakeTranslation(Vector3(-GetGlobalPassPosition())) *
849 GetCurrentTransform();
850
851 std::optional<Rect> clip_coverage = geometry.GetCoverage(clip_transform);
852 if (!clip_coverage.has_value()) {
853 return;
854 }
855
856 ClipContents clip_contents(
857 clip_coverage.value(),
858 /*is_axis_aligned_rect=*/geometry.IsAxisAlignedRect() &&
859 GetCurrentTransform().IsTranslationScaleOnly());
860 clip_contents.SetClipOperation(clip_op);
861
862 EntityPassClipStack::ClipStateResult clip_state_result =
863 clip_coverage_stack_.RecordClip(
864 clip_contents, //
865 /*transform=*/clip_transform, //
866 /*global_pass_position=*/GetGlobalPassPosition(), //
867 /*clip_depth=*/clip_depth, //
868 /*clip_height_floor=*/GetClipHeightFloor(), //
869 /*is_aa=*/is_aa);
870
871 if (clip_state_result.clip_did_change) {
872 // We only need to update the pass scissor if the clip state has changed.
873 SetClipScissor(clip_coverage_stack_.CurrentClipCoverage(),
874 *render_passes_.back().inline_pass_context->GetRenderPass(),
875 GetGlobalPassPosition());
876 }
877
878 ++transform_stack_.back().clip_height;
879 ++transform_stack_.back().num_clips;
880
881 if (!clip_state_result.should_render) {
882 return;
883 }
884
885 // Note: this is a bit of a hack. Its not possible to construct a geometry
886 // result without begninning the render pass. We should refactor the geometry
887 // objects so that they only need a reference to the render pass size and/or
888 // orthographic transform.
889 Entity entity;
890 entity.SetTransform(clip_transform);
891 entity.SetClipDepth(clip_depth);
892
893 GeometryResult geometry_result = geometry.GetPositionBuffer(
894 renderer_, //
895 entity, //
896 *render_passes_.back().inline_pass_context->GetRenderPass() //
897 );
898 clip_contents.SetGeometry(geometry_result);
899 clip_coverage_stack_.GetLastReplayResult().clip_contents.SetGeometry(
900 geometry_result);
901
902 clip_contents.Render(
903 renderer_, *render_passes_.back().inline_pass_context->GetRenderPass(),
904 clip_depth);
905 }
906
907 void Canvas::DrawPoints(const Point points[],
908 uint32_t count,
909 Scalar radius,
910 const Paint& paint,
911 PointStyle point_style) {
912 if (radius <= 0) {
913 return;
914 }
915
916 Entity entity;
917 entity.SetTransform(GetCurrentTransform());
918 entity.SetBlendMode(paint.blend_mode);
919
920 PointFieldGeometry geom(points, count, radius,
921 /*round=*/point_style == PointStyle::kRound);
922 AddRenderEntityWithFiltersToCurrentPass(entity, &geom, paint);
923 }
924
925 void Canvas::DrawImage(const std::shared_ptr<Texture>& image,
926 Point offset,
927 const Paint& paint,
928 const SamplerDescriptor& sampler) {
929 if (!image) {
930 return;
931 }
932
933 const Rect source = Rect::MakeSize(image->GetSize());
934 const Rect dest = source.Shift(offset);
935
936 DrawImageRect(image, source, dest, paint, sampler);
937 }
938
939 void Canvas::DrawImageRect(const std::shared_ptr<Texture>& image,
940 Rect source,
941 Rect dest,
942 const Paint& paint,
943 const SamplerDescriptor& sampler,
944 SourceRectConstraint src_rect_constraint) {
945 if (!image || source.IsEmpty() || dest.IsEmpty()) {
946 return;
947 }
948
949 ISize size = image->GetSize();
950 if (size.IsEmpty()) {
951 return;
952 }
953
954 std::optional<Rect> clipped_source =
955 source.Intersection(Rect::MakeSize(size));
956 if (!clipped_source) {
957 return;
958 }
959
960 if (AttemptColorFilterOptimization(image, source, dest, paint, sampler,
961 src_rect_constraint)) {
962 return;
963 }
964
965 if (*clipped_source != source) {
966 Scalar sx = dest.GetWidth() / source.GetWidth();
967 Scalar sy = dest.GetHeight() / source.GetHeight();
968 Scalar tx = dest.GetLeft() - source.GetLeft() * sx;
969 Scalar ty = dest.GetTop() - source.GetTop() * sy;
970 Matrix src_to_dest = Matrix::MakeTranslateScale({sx, sy, 1}, {tx, ty, 0});
971 dest = clipped_source->TransformBounds(src_to_dest);
972 }
973
974 auto texture_contents = TextureContents::MakeRect(dest);
975 texture_contents->SetTexture(image);
976 texture_contents->SetSourceRect(*clipped_source);
977 texture_contents->SetStrictSourceRect(src_rect_constraint ==
978 SourceRectConstraint::kStrict);
979 texture_contents->SetSamplerDescriptor(sampler);
980 texture_contents->SetOpacity(paint.color.alpha);
981 texture_contents->SetDeferApplyingOpacity(paint.HasColorFilter());
982
983 Entity entity;
984 entity.SetBlendMode(paint.blend_mode);
985 entity.SetTransform(GetCurrentTransform());
986
987 if (!paint.mask_blur_descriptor.has_value()) {
988 entity.SetContents(paint.WithFilters(std::move(texture_contents)));
989 AddRenderEntityToCurrentPass(entity);
990 return;
991 }
992
993 FillRectGeometry out_rect(Rect{});
994
995 entity.SetContents(paint.WithFilters(
996 paint.mask_blur_descriptor->CreateMaskBlur(texture_contents, &out_rect)));
997 AddRenderEntityToCurrentPass(entity);
998 }
999
1000 size_t Canvas::GetClipHeight() const {
1001 return transform_stack_.back().clip_height;
1002 }
1003
1004 void Canvas::DrawVertices(const std::shared_ptr<VerticesGeometry>& vertices,
1005 BlendMode blend_mode,
1006 const Paint& paint) {
1007 // Override the blend mode with kDestination in order to match the behavior
1008 // of Skia's SK_LEGACY_IGNORE_DRAW_VERTICES_BLEND_WITH_NO_SHADER flag, which
1009 // is enabled when the Flutter engine builds Skia.
1010 if (!paint.color_source) {
1011 blend_mode = BlendMode::kDst;
1012 }
1013
1014 Entity entity;
1015 entity.SetTransform(GetCurrentTransform());
1016 entity.SetBlendMode(paint.blend_mode);
1017
1018 // If there are no vertex colors.
1019 if (UseColorSourceContents(vertices, paint)) {
1020 AddRenderEntityWithFiltersToCurrentPass(entity, vertices.get(), paint);
1021 return;
1022 }
1023
1024 // If the blend mode is destination don't bother to bind or create a texture.
1025 if (blend_mode == BlendMode::kDst) {
1026 auto contents = std::make_shared<VerticesSimpleBlendContents>();
1027 contents->SetBlendMode(blend_mode);
1028 contents->SetAlpha(paint.color.alpha);
1029 contents->SetGeometry(vertices);
1030 entity.SetContents(paint.WithFilters(std::move(contents)));
1031 AddRenderEntityToCurrentPass(entity);
1032 return;
1033 }
1034
1035 // If there is a texture, use this directly. Otherwise render the color
1036 // source to a texture.
1037 if (paint.color_source &&
1038 paint.color_source->type() == flutter::DlColorSourceType::kImage) {
1039 const flutter::DlImageColorSource* image_color_source =
1040 paint.color_source->asImage();
1041 FML_DCHECK(image_color_source &&
1042 image_color_source->image()->impeller_texture());
1043 auto texture = image_color_source->image()->impeller_texture();
1044 auto x_tile_mode = static_cast<Entity::TileMode>(
1045 image_color_source->horizontal_tile_mode());
1046 auto y_tile_mode =
1047 static_cast<Entity::TileMode>(image_color_source->vertical_tile_mode());
1048 auto sampler_descriptor =
1049 skia_conversions::ToSamplerDescriptor(image_color_source->sampling());
1050 auto effect_transform = image_color_source->matrix();
1051
1052 auto contents = std::make_shared<VerticesSimpleBlendContents>();
1053 contents->SetBlendMode(blend_mode);
1054 contents->SetAlpha(paint.color.alpha);
1055 contents->SetGeometry(vertices);
1056 contents->SetEffectTransform(effect_transform);
1057 contents->SetTexture(texture);
1058 contents->SetTileMode(x_tile_mode, y_tile_mode);
1059 contents->SetSamplerDescriptor(sampler_descriptor);
1060
1061 entity.SetContents(paint.WithFilters(std::move(contents)));
1062 AddRenderEntityToCurrentPass(entity);
1063 return;
1064 }
1065
1066 auto src_paint = paint;
1067 src_paint.color = paint.color.WithAlpha(1.0);
1068
1069 std::shared_ptr<ColorSourceContents> src_contents =
1070 src_paint.CreateContents();
1071 src_contents->SetGeometry(vertices.get());
1072
1073 // If the color source has an intrinsic size, then we use that to
1074 // create the src contents as a simplification. Otherwise we use
1075 // the extent of the texture coordinates to determine how large
1076 // the src contents should be. If neither has a value we fall back
1077 // to using the geometry coverage data.
1078 Rect src_coverage;
1079 auto size = src_contents->GetColorSourceSize();
1080 if (size.has_value()) {
1081 src_coverage = Rect::MakeXYWH(0, 0, size->width, size->height);
1082 } else {
1083 auto cvg = vertices->GetCoverage(Matrix{});
1084 FML_CHECK(cvg.has_value());
1085 auto texture_coverage = vertices->GetTextureCoordinateCoverage();
1086 if (texture_coverage.has_value()) {
1087 src_coverage =
1088 Rect::MakeOriginSize(texture_coverage->GetOrigin(),
1089 texture_coverage->GetSize().Max({1, 1}));
1090 } else {
1091 src_coverage = cvg.value();
1092 }
1093 }
1094 src_contents = src_paint.CreateContents();
1095
1096 clip_geometry_.push_back(Geometry::MakeRect(Rect::Round(src_coverage)));
1097 src_contents->SetGeometry(clip_geometry_.back().get());
1098
1099 auto contents = std::make_shared<VerticesSimpleBlendContents>();
1100 contents->SetBlendMode(blend_mode);
1101 contents->SetAlpha(paint.color.alpha);
1102 contents->SetGeometry(vertices);
1103 contents->SetLazyTextureCoverage(src_coverage);
1104 contents->SetLazyTexture([src_contents,
1105 src_coverage](const ContentContext& renderer) {
1106 // Applying the src coverage as the coverage limit prevents the 1px
1107 // coverage pad from adding a border that is picked up by developer
1108 // specified UVs.
1109 auto snapshot =
1110 src_contents->RenderToSnapshot(renderer, {}, Rect::Round(src_coverage));
1111 return snapshot.has_value() ? snapshot->texture : nullptr;
1112 });
1113 entity.SetContents(paint.WithFilters(std::move(contents)));
1114 AddRenderEntityToCurrentPass(entity);
1115 }
1116
1117 void Canvas::DrawAtlas(const std::shared_ptr<AtlasContents>& atlas_contents,
1118 const Paint& paint) {
1119 atlas_contents->SetAlpha(paint.color.alpha);
1120
1121 Entity entity;
1122 entity.SetTransform(GetCurrentTransform());
1123 entity.SetBlendMode(paint.blend_mode);
1124 entity.SetContents(paint.WithFilters(atlas_contents));
1125
1126 AddRenderEntityToCurrentPass(entity);
1127 }
1128
1129 /// Compositor Functionality
1130 /////////////////////////////////////////
1131
1132 void Canvas::SetupRenderPass() {
1133 renderer_.GetRenderTargetCache()->Start();
1134 ColorAttachment color0 = render_target_.GetColorAttachment(0);
1135
1136 auto& stencil_attachment = render_target_.GetStencilAttachment();
1137 auto& depth_attachment = render_target_.GetDepthAttachment();
1138 if (!stencil_attachment.has_value() || !depth_attachment.has_value()) {
1139 // Setup a new root stencil with an optimal configuration if one wasn't
1140 // provided by the caller.
1141 render_target_.SetupDepthStencilAttachments(
1142 *renderer_.GetContext(),
1143 *renderer_.GetContext()->GetResourceAllocator(),
1144 color0.texture->GetSize(),
1145 renderer_.GetContext()->GetCapabilities()->SupportsOffscreenMSAA(),
1146 "ImpellerOnscreen", kDefaultStencilConfig);
1147 }
1148
1149 // Set up the clear color of the root pass.
1150 color0.clear_color = Color::BlackTransparent();
1151 render_target_.SetColorAttachment(color0, 0);
1152
1153 // If requires_readback is true, then there is a backdrop filter or emulated
1154 // advanced blend in the first save layer. This requires a readback, which
1155 // isn't supported by onscreen textures. To support this, we immediately begin
1156 // a second save layer with the same dimensions as the onscreen. When
1157 // rendering is completed, we must blit this saveLayer to the onscreen.
1158 if (requires_readback_) {
1159 auto entity_pass_target =
1160 CreateRenderTarget(renderer_, //
1161 color0.texture->GetSize(), //
1162 /*clear_color=*/Color::BlackTransparent());
1163 render_passes_.push_back(
1164 LazyRenderingConfig(renderer_, std::move(entity_pass_target)));
1165 } else {
1166 auto entity_pass_target = std::make_unique<EntityPassTarget>(
1167 render_target_, //
1168 renderer_.GetDeviceCapabilities().SupportsReadFromResolve(), //
1169 renderer_.GetDeviceCapabilities().SupportsImplicitResolvingMSAA() //
1170 );
1171 render_passes_.push_back(
1172 LazyRenderingConfig(renderer_, std::move(entity_pass_target)));
1173 }
1174 }
1175
1176 void Canvas::SkipUntilMatchingRestore(size_t total_content_depth) {
1177 auto entry = CanvasStackEntry{};
1178 entry.skipping = true;
1179 entry.clip_depth = current_depth_ + total_content_depth;
1180 transform_stack_.push_back(entry);
1181 }
1182
1183 void Canvas::Save(uint32_t total_content_depth) {
1184 if (IsSkipping()) {
1185 return SkipUntilMatchingRestore(total_content_depth);
1186 }
1187
1188 auto entry = CanvasStackEntry{};
1189 entry.transform = transform_stack_.back().transform;
1190 entry.clip_depth = current_depth_ + total_content_depth;
1191 entry.distributed_opacity = transform_stack_.back().distributed_opacity;
1192 FML_DCHECK(entry.clip_depth <= transform_stack_.back().clip_depth)
1193 << entry.clip_depth << " <=? " << transform_stack_.back().clip_depth
1194 << " after allocating " << total_content_depth;
1195 entry.clip_height = transform_stack_.back().clip_height;
1196 entry.rendering_mode = Entity::RenderingMode::kDirect;
1197 transform_stack_.push_back(entry);
1198 }
1199
1200 std::optional<Rect> Canvas::GetLocalCoverageLimit() const {
1201 if (!clip_coverage_stack_.HasCoverage()) {
1202 // The current clip is empty. This means the pass texture won't be
1203 // visible, so skip it.
1204 return std::nullopt;
1205 }
1206
1207 auto maybe_current_clip_coverage = clip_coverage_stack_.CurrentClipCoverage();
1208 if (!maybe_current_clip_coverage.has_value()) {
1209 return std::nullopt;
1210 }
1211
1212 auto current_clip_coverage = maybe_current_clip_coverage.value();
1213
1214 // The maximum coverage of the subpass. Subpasses textures should never
1215 // extend outside the parent pass texture or the current clip coverage.
1216 std::optional<Rect> maybe_coverage_limit =
1217 Rect::MakeOriginSize(GetGlobalPassPosition(),
1218 Size(render_passes_.back()
1219 .inline_pass_context->GetTexture()
1220 ->GetSize()))
1221 .Intersection(current_clip_coverage);
1222
1223 if (!maybe_coverage_limit.has_value() || maybe_coverage_limit->IsEmpty()) {
1224 return std::nullopt;
1225 }
1226
1227 return maybe_coverage_limit->Intersection(
1228 Rect::MakeSize(render_target_.GetRenderTargetSize()));
1229 }
1230
1231 void Canvas::SaveLayer(const Paint& paint,
1232 std::optional<Rect> bounds,
1233 const flutter::DlImageFilter* backdrop_filter,
1234 ContentBoundsPromise bounds_promise,
1235 uint32_t total_content_depth,
1236 bool can_distribute_opacity,
1237 std::optional<int64_t> backdrop_id) {
1238 TRACE_EVENT0("flutter", "Canvas::saveLayer");
1239 if (IsSkipping()) {
1240 return SkipUntilMatchingRestore(total_content_depth);
1241 }
1242
1243 auto maybe_coverage_limit = GetLocalCoverageLimit();
1244 if (!maybe_coverage_limit.has_value()) {
1245 return SkipUntilMatchingRestore(total_content_depth);
1246 }
1247 auto coverage_limit = maybe_coverage_limit.value();
1248
1249 if (can_distribute_opacity && !backdrop_filter &&
1250 Paint::CanApplyOpacityPeephole(paint) &&
1251 bounds_promise != ContentBoundsPromise::kMayClipContents) {
1252 Save(total_content_depth);
1253 transform_stack_.back().distributed_opacity *= paint.color.alpha;
1254 return;
1255 }
1256
1257 std::shared_ptr<FilterContents> filter_contents = paint.WithImageFilter(
1258 Rect(), transform_stack_.back().transform,
1259 Entity::RenderingMode::kSubpassPrependSnapshotTransform);
1260
1261 std::optional<Rect> maybe_subpass_coverage = ComputeSaveLayerCoverage(
1262 bounds.value_or(Rect::MakeMaximum()),
1263 transform_stack_.back().transform, //
1264 coverage_limit, //
1265 filter_contents, //
1266 /*flood_output_coverage=*/
1267 Entity::IsBlendModeDestructive(paint.blend_mode), //
1268 /*flood_input_coverage=*/!!backdrop_filter ||
1269 (paint.color_filter &&
1270 paint.color_filter->modifies_transparent_black()) //
1271 );
1272
1273 if (!maybe_subpass_coverage.has_value()) {
1274 return SkipUntilMatchingRestore(total_content_depth);
1275 }
1276
1277 auto subpass_coverage = maybe_subpass_coverage.value();
1278
1279 // When an image filter is present, clamp to avoid flicking due to nearest
1280 // sampled image. For other cases, round out to ensure than any geometry is
1281 // not cut off.
1282 //
1283 // See also this bug: https://github.com/flutter/flutter/issues/144213
1284 //
1285 // TODO(jonahwilliams): this could still round out for filters that use decal
1286 // sampling mode.
1287 ISize subpass_size;
1288 bool did_round_out = false;
1289 Point coverage_origin_adjustment = Point{0, 0};
1290 if (paint.image_filter) {
1291 subpass_size = ISize(subpass_coverage.GetSize());
1292 } else {
1293 did_round_out = true;
1294 subpass_size =
1295 static_cast<ISize>(IRect::RoundOut(subpass_coverage).GetSize());
1296 // If rounding out, adjust the coverage to account for the subpixel shift.
1297 coverage_origin_adjustment =
1298 Point(subpass_coverage.GetLeftTop().x -
1299 std::floor(subpass_coverage.GetLeftTop().x),
1300 subpass_coverage.GetLeftTop().y -
1301 std::floor(subpass_coverage.GetLeftTop().y));
1302 }
1303 if (subpass_size.IsEmpty()) {
1304 return SkipUntilMatchingRestore(total_content_depth);
1305 }
1306
1307 // When there are scaling filters present, these contents may exceed the
1308 // maximum texture size. Perform a clamp here, which may cause rendering
1309 // artifacts.
1310 subpass_size = subpass_size.Min(renderer_.GetContext()
1311 ->GetCapabilities()
1312 ->GetMaximumRenderPassAttachmentSize());
1313
1314 // Backdrop filter state, ignored if there is no BDF.
1315 std::shared_ptr<FilterContents> backdrop_filter_contents;
1316 Point local_position = Point(0, 0);
1317 if (backdrop_filter) {
1318 local_position = subpass_coverage.GetOrigin() - GetGlobalPassPosition();
1319 Canvas::BackdropFilterProc backdrop_filter_proc =
1320 [backdrop_filter = backdrop_filter](
1321 const FilterInput::Ref& input, const Matrix& effect_transform,
1322 Entity::RenderingMode rendering_mode) {
1323 auto filter = WrapInput(backdrop_filter, input);
1324 filter->SetEffectTransform(effect_transform);
1325 filter->SetRenderingMode(rendering_mode);
1326 return filter;
1327 };
1328
1329 std::shared_ptr<Texture> input_texture;
1330
1331 // If the backdrop ID is not nullopt and there is more than one usage
1332 // of it in the current scene, cache the backdrop texture and remove it from
1333 // the current entity pass flip.
1334 bool will_cache_backdrop_texture = false;
1335 BackdropData* backdrop_data = nullptr;
1336 // If we've reached this point, there is at least one backdrop filter. But
1337 // potentially more if there is a backdrop id. We may conditionally set this
1338 // to a higher value in the if block below.
1339 size_t backdrop_count = 1;
1340 if (backdrop_id.has_value()) {
1341 std::unordered_map<int64_t, BackdropData>::iterator backdrop_data_it =
1342 backdrop_data_.find(backdrop_id.value());
1343 if (backdrop_data_it != backdrop_data_.end()) {
1344 backdrop_data = &backdrop_data_it->second;
1345 will_cache_backdrop_texture =
1346 backdrop_data_it->second.backdrop_count > 1;
1347 backdrop_count = backdrop_data_it->second.backdrop_count;
1348 }
1349 }
1350
1351 if (!will_cache_backdrop_texture || !backdrop_data->texture_slot) {
1352 backdrop_count_ -= backdrop_count;
1353
1354 // The onscreen texture can be flipped to if:
1355 // 1. The device supports framebuffer fetch
1356 // 2. There are no more backdrop filters
1357 // 3. The current render pass is for the onscreen pass.
1358 const bool should_use_onscreen =
1359 renderer_.GetDeviceCapabilities().SupportsFramebufferFetch() &&
1360 backdrop_count_ == 0 && render_passes_.size() == 1u;
1361 input_texture = FlipBackdrop(
1362 GetGlobalPassPosition(), //
1363 /*should_remove_texture=*/will_cache_backdrop_texture, //
1364 /*should_use_onscreen=*/should_use_onscreen //
1365 );
1366 if (!input_texture) {
1367 // Validation failures are logged in FlipBackdrop.
1368 return;
1369 }
1370
1371 if (will_cache_backdrop_texture) {
1372 backdrop_data->texture_slot = input_texture;
1373 }
1374 } else {
1375 input_texture = backdrop_data->texture_slot;
1376 }
1377
1378 backdrop_filter_contents = backdrop_filter_proc(
1379 FilterInput::Make(std::move(input_texture)),
1380 transform_stack_.back().transform.Basis(),
1381 // When the subpass has a translation that means the math with
1382 // the snapshot has to be different.
1383 transform_stack_.back().transform.HasTranslation()
1384 ? Entity::RenderingMode::kSubpassPrependSnapshotTransform
1385 : Entity::RenderingMode::kSubpassAppendSnapshotTransform);
1386
1387 if (will_cache_backdrop_texture) {
1388 FML_DCHECK(backdrop_data);
1389 // If all filters on the shared backdrop layer are equal, process the
1390 // layer once.
1391 if (backdrop_data->all_filters_equal &&
1392 !backdrop_data->shared_filter_snapshot.has_value()) {
1393 // TODO(157110): compute minimum input hint.
1394 backdrop_data->shared_filter_snapshot =
1395 backdrop_filter_contents->RenderToSnapshot(renderer_, {});
1396 }
1397
1398 std::optional<Snapshot> maybe_snapshot =
1399 backdrop_data->shared_filter_snapshot;
1400 if (maybe_snapshot.has_value()) {
1401 Snapshot snapshot = maybe_snapshot.value();
1402 std::shared_ptr<TextureContents> contents = TextureContents::MakeRect(
1403 subpass_coverage.Shift(-GetGlobalPassPosition()));
1404 auto scaled =
1405 subpass_coverage.TransformBounds(snapshot.transform.Invert());
1406 contents->SetTexture(snapshot.texture);
1407 contents->SetSourceRect(scaled);
1408 contents->SetSamplerDescriptor(snapshot.sampler_descriptor);
1409
1410 // This backdrop entity sets a depth value as it is written to the newly
1411 // flipped backdrop and not into a new saveLayer.
1412 Entity backdrop_entity;
1413 backdrop_entity.SetContents(std::move(contents));
1414 backdrop_entity.SetClipDepth(++current_depth_);
1415 backdrop_entity.SetBlendMode(paint.blend_mode);
1416
1417 backdrop_entity.Render(renderer_, GetCurrentRenderPass());
1418 Save(0);
1419 return;
1420 }
1421 }
1422 }
1423
1424 // When applying a save layer, absorb any pending distributed opacity.
1425 Paint paint_copy = paint;
1426 paint_copy.color.alpha *= transform_stack_.back().distributed_opacity;
1427 transform_stack_.back().distributed_opacity = 1.0;
1428
1429 render_passes_.push_back(
1430 LazyRenderingConfig(renderer_, //
1431 CreateRenderTarget(renderer_, //
1432 subpass_size, //
1433 Color::BlackTransparent() //
1434 )));
1435 save_layer_state_.push_back(SaveLayerState{
1436 paint_copy, subpass_coverage.Shift(-coverage_origin_adjustment)});
1437
1438 CanvasStackEntry entry;
1439 entry.transform = transform_stack_.back().transform;
1440 entry.clip_depth = current_depth_ + total_content_depth;
1441 FML_DCHECK(entry.clip_depth <= transform_stack_.back().clip_depth)
1442 << entry.clip_depth << " <=? " << transform_stack_.back().clip_depth
1443 << " after allocating " << total_content_depth;
1444 entry.clip_height = transform_stack_.back().clip_height;
1445 entry.rendering_mode = Entity::RenderingMode::kSubpassAppendSnapshotTransform;
1446 entry.did_round_out = did_round_out;
1447 transform_stack_.emplace_back(entry);
1448
1449 // Start non-collapsed subpasses with a fresh clip coverage stack limited by
1450 // the subpass coverage. This is important because image filters applied to
1451 // save layers may transform the subpass texture after it's rendered,
1452 // causing parent clip coverage to get misaligned with the actual area that
1453 // the subpass will affect in the parent pass.
1454 clip_coverage_stack_.PushSubpass(subpass_coverage, GetClipHeight());
1455
1456 if (!backdrop_filter_contents) {
1457 return;
1458 }
1459
1460 // Render the backdrop entity.
1461 Entity backdrop_entity;
1462 backdrop_entity.SetContents(std::move(backdrop_filter_contents));
1463 backdrop_entity.SetTransform(
1464 Matrix::MakeTranslation(Vector3(-local_position)));
1465 backdrop_entity.SetClipDepth(std::numeric_limits<uint32_t>::max());
1466 backdrop_entity.Render(renderer_, GetCurrentRenderPass());
1467 }
1468
1469 bool Canvas::Restore() {
1470 FML_DCHECK(transform_stack_.size() > 0);
1471 if (transform_stack_.size() == 1) {
1472 return false;
1473 }
1474
1475 // This check is important to make sure we didn't exceed the depth
1476 // that the clips were rendered at while rendering any of the
1477 // rendering ops. It is OK for the current depth to equal the
1478 // outgoing clip depth because that means the clipping would have
1479 // been successful up through the last rendering op, but it cannot
1480 // be greater.
1481 // Also, we bump the current rendering depth to the outgoing clip
1482 // depth so that future rendering operations are not clipped by
1483 // any of the pixels set by the expiring clips. It is OK for the
1484 // estimates used to determine the clip depth in save/saveLayer
1485 // to be overly conservative, but we need to jump the depth to
1486 // the clip depth so that the next rendering op will get a
1487 // larger depth (it will pre-increment the current_depth_ value).
1488 FML_DCHECK(current_depth_ <= transform_stack_.back().clip_depth)
1489 << current_depth_ << " <=? " << transform_stack_.back().clip_depth;
1490 current_depth_ = transform_stack_.back().clip_depth;
1491
1492 if (IsSkipping()) {
1493 transform_stack_.pop_back();
1494 return true;
1495 }
1496
1497 if (transform_stack_.back().rendering_mode ==
1498 Entity::RenderingMode::kSubpassAppendSnapshotTransform ||
1499 transform_stack_.back().rendering_mode ==
1500 Entity::RenderingMode::kSubpassPrependSnapshotTransform) {
1501 auto lazy_render_pass = std::move(render_passes_.back());
1502 render_passes_.pop_back();
1503 // Force the render pass to be constructed if it never was.
1504 lazy_render_pass.inline_pass_context->GetRenderPass();
1505
1506 SaveLayerState save_layer_state = save_layer_state_.back();
1507 save_layer_state_.pop_back();
1508 auto global_pass_position = GetGlobalPassPosition();
1509
1510 std::shared_ptr<Contents> contents = CreateContentsForSubpassTarget(
1511 save_layer_state.paint, //
1512 lazy_render_pass.inline_pass_context->GetTexture(), //
1513 Matrix::MakeTranslation(Vector3{-global_pass_position}) * //
1514 transform_stack_.back().transform //
1515 );
1516
1517 lazy_render_pass.inline_pass_context->EndPass();
1518
1519 // Round the subpass texture position for pixel alignment with the parent
1520 // pass render target. By default, we draw subpass textures with nearest
1521 // sampling, so aligning here is important for avoiding visual nearest
1522 // sampling errors caused by limited floating point precision when
1523 // straddling a half pixel boundary.
1524 Point subpass_texture_position;
1525 if (transform_stack_.back().did_round_out) {
1526 // Subpass coverage was rounded out, origin potentially moved "down" by
1527 // as much as a pixel.
1528 subpass_texture_position =
1529 (save_layer_state.coverage.GetOrigin() - global_pass_position)
1530 .Floor();
1531 } else {
1532 // Subpass coverage was truncated. Pick the closest phyiscal pixel.
1533 subpass_texture_position =
1534 (save_layer_state.coverage.GetOrigin() - global_pass_position)
1535 .Round();
1536 }
1537
1538 Entity element_entity;
1539 element_entity.SetClipDepth(++current_depth_);
1540 element_entity.SetContents(std::move(contents));
1541 element_entity.SetBlendMode(save_layer_state.paint.blend_mode);
1542 element_entity.SetTransform(
1543 Matrix::MakeTranslation(Vector3(subpass_texture_position)));
1544
1545 if (element_entity.GetBlendMode() > Entity::kLastPipelineBlendMode) {
1546 if (renderer_.GetDeviceCapabilities().SupportsFramebufferFetch()) {
1547 ApplyFramebufferBlend(element_entity);
1548 } else {
1549 // End the active pass and flush the buffer before rendering "advanced"
1550 // blends. Advanced blends work by binding the current render target
1551 // texture as an input ("destination"), blending with a second texture
1552 // input ("source"), writing the result to an intermediate texture, and
1553 // finally copying the data from the intermediate texture back to the
1554 // render target texture. And so all of the commands that have written
1555 // to the render target texture so far need to execute before it's bound
1556 // for blending (otherwise the blend pass will end up executing before
1557 // all the previous commands in the active pass).
1558 auto input_texture = FlipBackdrop(GetGlobalPassPosition());
1559 if (!input_texture) {
1560 return false;
1561 }
1562
1563 FilterInput::Vector inputs = {
1564 FilterInput::Make(input_texture,
1565 element_entity.GetTransform().Invert()),
1566 FilterInput::Make(element_entity.GetContents())};
1567 auto contents = ColorFilterContents::MakeBlend(
1568 element_entity.GetBlendMode(), inputs);
1569 contents->SetCoverageHint(element_entity.GetCoverage());
1570 element_entity.SetContents(std::move(contents));
1571 element_entity.SetBlendMode(BlendMode::kSrc);
1572 }
1573 }
1574
1575 element_entity.Render(
1576 renderer_, //
1577 *render_passes_.back().inline_pass_context->GetRenderPass() //
1578 );
1579 clip_coverage_stack_.PopSubpass();
1580 transform_stack_.pop_back();
1581
1582 // We don't need to restore clips if a saveLayer was performed, as the clip
1583 // state is per render target, and no more rendering operations will be
1584 // performed as the render target workloaded is completed in the restore.
1585 return true;
1586 }
1587
1588 size_t num_clips = transform_stack_.back().num_clips;
1589 transform_stack_.pop_back();
1590
1591 if (num_clips > 0) {
1592 EntityPassClipStack::ClipStateResult clip_state_result =
1593 clip_coverage_stack_.RecordRestore(GetGlobalPassPosition(),
1594 GetClipHeight());
1595
1596 // Clip restores are never required with depth based clipping.
1597 FML_DCHECK(!clip_state_result.should_render);
1598 if (clip_state_result.clip_did_change) {
1599 // We only need to update the pass scissor if the clip state has changed.
1600 SetClipScissor(
1601 clip_coverage_stack_.CurrentClipCoverage(), //
1602 *render_passes_.back().inline_pass_context->GetRenderPass(), //
1603 GetGlobalPassPosition() //
1604 );
1605 }
1606 }
1607
1608 return true;
1609 }
1610
1611 bool Canvas::AttemptBlurredTextOptimization(
1612 const std::shared_ptr<TextFrame>& text_frame,
1613 const std::shared_ptr<TextContents>& text_contents,
1614 Entity& entity,
1615 const Paint& paint) {
1616 if (!paint.mask_blur_descriptor.has_value() || //
1617 paint.image_filter != nullptr || //
1618 paint.color_filter != nullptr || //
1619 paint.invert_colors) {
1620 return false;
1621 }
1622
1623 // TODO(bdero): This mask blur application is a hack. It will always wind up
1624 // doing a gaussian blur that affects the color source itself
1625 // instead of just the mask. The color filter text support
1626 // needs to be reworked in order to interact correctly with
1627 // mask filters.
1628 // https://github.com/flutter/flutter/issues/133297
1629 std::shared_ptr<FilterContents> filter =
1630 paint.mask_blur_descriptor->CreateMaskBlur(
1631 FilterInput::Make(text_contents),
1632 /*is_solid_color=*/true, GetCurrentTransform());
1633
1634 std::optional<Glyph> maybe_glyph = text_frame->AsSingleGlyph();
1635 int64_t identifier = maybe_glyph.has_value()
1636 ? maybe_glyph.value().index
1637 : reinterpret_cast<int64_t>(text_frame.get());
1638 TextShadowCache::TextShadowCacheKey cache_key(
1639 /*p_max_basis=*/entity.GetTransform().GetMaxBasisLengthXY(),
1640 /*p_identifier=*/identifier,
1641 /*p_is_single_glyph=*/maybe_glyph.has_value(),
1642 /*p_font=*/text_frame->GetFont(),
1643 /*p_sigma=*/paint.mask_blur_descriptor->sigma);
1644
1645 std::optional<Entity> result = renderer_.GetTextShadowCache().Lookup(
1646 renderer_, entity, filter, cache_key);
1647 if (result.has_value()) {
1648 AddRenderEntityToCurrentPass(result.value(), /*reuse_depth=*/false);
1649 return true;
1650 } else {
1651 return false;
1652 }
1653 }
1654
1655 // If the text point size * max basis XY is larger than this value,
1656 // render the text as paths (if available) for faster and higher
1657 // fidelity rendering. This is a somewhat arbitrary cutoff
1658 static constexpr Scalar kMaxTextScale = 250;
1659
1660 void Canvas::DrawTextFrame(const std::shared_ptr<TextFrame>& text_frame,
1661 Point position,
1662 const Paint& paint) {
1663 Scalar max_scale = GetCurrentTransform().GetMaxBasisLengthXY();
1664 if (max_scale * text_frame->GetFont().GetMetrics().point_size >
1665 kMaxTextScale) {
1666 fml::StatusOr<flutter::DlPath> path = text_frame->GetPath();
1667 if (path.ok()) {
1668 Save(1);
1669 Concat(Matrix::MakeTranslation(position));
1670 DrawPath(path.value(), paint);
1671 Restore();
1672 return;
1673 }
1674 }
1675
1676 Entity entity;
1677 entity.SetClipDepth(GetClipHeight());
1678 entity.SetBlendMode(paint.blend_mode);
1679
1680 auto text_contents = std::make_shared<TextContents>();
1681 text_contents->SetTextFrame(text_frame);
1682 text_contents->SetForceTextColor(paint.mask_blur_descriptor.has_value());
1683 text_contents->SetScale(max_scale);
1684 text_contents->SetColor(paint.color);
1685 text_contents->SetOffset(position);
1686 text_contents->SetTextProperties(paint.color,
1687 paint.style == Paint::Style::kStroke
1688 ? std::optional(paint.stroke)
1689 : std::nullopt);
1690
1691 entity.SetTransform(GetCurrentTransform() *
1692 Matrix::MakeTranslation(position));
1693
1694 if (AttemptBlurredTextOptimization(text_frame, text_contents, entity,
1695 paint)) {
1696 return;
1697 }
1698
1699 entity.SetContents(paint.WithFilters(std::move(text_contents)));
1700 AddRenderEntityToCurrentPass(entity, false);
1701 }
1702
1703 void Canvas::AddRenderEntityWithFiltersToCurrentPass(Entity& entity,
1704 const Geometry* geometry,
1705 const Paint& paint,
1706 bool reuse_depth) {
1707 std::shared_ptr<ColorSourceContents> contents = paint.CreateContents();
1708 if (!paint.color_filter && !paint.invert_colors && !paint.image_filter &&
1709 !paint.mask_blur_descriptor.has_value()) {
1710 contents->SetGeometry(geometry);
1711 entity.SetContents(std::move(contents));
1712 AddRenderEntityToCurrentPass(entity, reuse_depth);
1713 return;
1714 }
1715
1716 // Attempt to apply the color filter on the CPU first.
1717 // Note: This is not just an optimization; some color sources rely on
1718 // CPU-applied color filters to behave properly.
1719 bool needs_color_filter = paint.color_filter || paint.invert_colors;
1720 if (needs_color_filter &&
1721 contents->ApplyColorFilter([&](Color color) -> Color {
1722 if (paint.color_filter) {
1723 color = GetCPUColorFilterProc(paint.color_filter)(color);
1724 }
1725 if (paint.invert_colors) {
1726 color = color.ApplyColorMatrix(kColorInversion);
1727 }
1728 return color;
1729 })) {
1730 needs_color_filter = false;
1731 }
1732
1733 bool can_apply_mask_filter = geometry->CanApplyMaskFilter();
1734 contents->SetGeometry(geometry);
1735
1736 if (can_apply_mask_filter && paint.mask_blur_descriptor.has_value()) {
1737 // If there's a mask blur and we need to apply the color filter on the GPU,
1738 // we need to be careful to only apply the color filter to the source
1739 // colors. CreateMaskBlur is able to handle this case.
1740 FillRectGeometry out_rect(Rect{});
1741 auto filter_contents = paint.mask_blur_descriptor->CreateMaskBlur(
1742 contents, needs_color_filter ? paint.color_filter : nullptr,
1743 needs_color_filter ? paint.invert_colors : false, &out_rect);
1744 entity.SetContents(std::move(filter_contents));
1745 AddRenderEntityToCurrentPass(entity, reuse_depth);
1746 return;
1747 }
1748
1749 std::shared_ptr<Contents> contents_copy = std::move(contents);
1750
1751 // Image input types will directly set their color filter,
1752 // if any. See `TiledTextureContents.SetColorFilter`.
1753 if (needs_color_filter &&
1754 (!paint.color_source ||
1755 paint.color_source->type() != flutter::DlColorSourceType::kImage)) {
1756 if (paint.color_filter) {
1757 contents_copy = WrapWithGPUColorFilter(
1758 paint.color_filter, FilterInput::Make(std::move(contents_copy)),
1759 ColorFilterContents::AbsorbOpacity::kYes);
1760 }
1761 if (paint.invert_colors) {
1762 contents_copy =
1763 WrapWithInvertColors(FilterInput::Make(std::move(contents_copy)),
1764 ColorFilterContents::AbsorbOpacity::kYes);
1765 }
1766 }
1767
1768 if (paint.image_filter) {
1769 std::shared_ptr<FilterContents> filter = WrapInput(
1770 paint.image_filter, FilterInput::Make(std::move(contents_copy)));
1771 filter->SetRenderingMode(Entity::RenderingMode::kDirect);
1772 entity.SetContents(filter);
1773 AddRenderEntityToCurrentPass(entity, reuse_depth);
1774 return;
1775 }
1776
1777 entity.SetContents(std::move(contents_copy));
1778 AddRenderEntityToCurrentPass(entity, reuse_depth);
1779 }
1780
1781 void Canvas::AddRenderEntityToCurrentPass(Entity& entity, bool reuse_depth) {
1782 if (IsSkipping()) {
1783 return;
1784 }
1785
1786 entity.SetTransform(
1787 Matrix::MakeTranslation(Vector3(-GetGlobalPassPosition())) *
1788 entity.GetTransform());
1789 entity.SetInheritedOpacity(transform_stack_.back().distributed_opacity);
1790 if (entity.GetBlendMode() == BlendMode::kSrcOver &&
1791 entity.GetContents()->IsOpaque(entity.GetTransform())) {
1792 entity.SetBlendMode(BlendMode::kSrc);
1793 }
1794
1795 // If the entity covers the current render target and is a solid color, then
1796 // conditionally update the backdrop color to its solid color value blended
1797 // with the current backdrop.
1798 if (render_passes_.back().IsApplyingClearColor()) {
1799 std::optional<Color> maybe_color = entity.AsBackgroundColor(
1800 render_passes_.back().inline_pass_context->GetTexture()->GetSize());
1801 if (maybe_color.has_value()) {
1802 Color color = maybe_color.value();
1803 RenderTarget& render_target = render_passes_.back()
1804 .inline_pass_context->GetPassTarget()
1805 .GetRenderTarget();
1806 ColorAttachment attachment = render_target.GetColorAttachment(0);
1807 // Attachment.clear color needs to be premultiplied at all times, but the
1808 // Color::Blend function requires unpremultiplied colors.
1809 attachment.clear_color = attachment.clear_color.Unpremultiply()
1810 .Blend(color, entity.GetBlendMode())
1811 .Premultiply();
1812 render_target.SetColorAttachment(attachment, 0u);
1813 return;
1814 }
1815 }
1816 if (!reuse_depth) {
1817 ++current_depth_;
1818 }
1819
1820 // We can render at a depth up to and including the depth of the currently
1821 // active clips and we will still be clipped out, but we cannot render at
1822 // a depth that is greater than the current clips or we will not be clipped.
1823 FML_DCHECK(current_depth_ <= transform_stack_.back().clip_depth)
1824 << current_depth_ << " <=? " << transform_stack_.back().clip_depth;
1825 entity.SetClipDepth(current_depth_);
1826
1827 if (entity.GetBlendMode() > Entity::kLastPipelineBlendMode) {
1828 if (renderer_.GetDeviceCapabilities().SupportsFramebufferFetch()) {
1829 ApplyFramebufferBlend(entity);
1830 } else {
1831 // End the active pass and flush the buffer before rendering "advanced"
1832 // blends. Advanced blends work by binding the current render target
1833 // texture as an input ("destination"), blending with a second texture
1834 // input ("source"), writing the result to an intermediate texture, and
1835 // finally copying the data from the intermediate texture back to the
1836 // render target texture. And so all of the commands that have written
1837 // to the render target texture so far need to execute before it's bound
1838 // for blending (otherwise the blend pass will end up executing before
1839 // all the previous commands in the active pass).
1840 auto input_texture = FlipBackdrop(GetGlobalPassPosition(), //
1841 /*should_remove_texture=*/false,
1842 /*should_use_onscreen=*/false,
1843 /*post_depth_increment=*/true);
1844 if (!input_texture) {
1845 return;
1846 }
1847
1848 // The coverage hint tells the rendered Contents which portion of the
1849 // rendered output will actually be used, and so we set this to the
1850 // current clip coverage (which is the max clip bounds). The contents may
1851 // optionally use this hint to avoid unnecessary rendering work.
1852 auto element_coverage_hint = entity.GetContents()->GetCoverageHint();
1853 entity.GetContents()->SetCoverageHint(Rect::Intersection(
1854 element_coverage_hint, clip_coverage_stack_.CurrentClipCoverage()));
1855
1856 FilterInput::Vector inputs = {
1857 FilterInput::Make(input_texture, entity.GetTransform().Invert()),
1858 FilterInput::Make(entity.GetContents())};
1859 auto contents =
1860 ColorFilterContents::MakeBlend(entity.GetBlendMode(), inputs);
1861 entity.SetContents(std::move(contents));
1862 entity.SetBlendMode(BlendMode::kSrc);
1863 }
1864 }
1865
1866 const std::shared_ptr<RenderPass>& result =
1867 render_passes_.back().inline_pass_context->GetRenderPass();
1868 if (!result) {
1869 // Failure to produce a render pass should be explained by specific errors
1870 // in `InlinePassContext::GetRenderPass()`, so avoid log spam and don't
1871 // append a validation log here.
1872 return;
1873 }
1874
1875 entity.Render(renderer_, *result);
1876 }
1877
1878 RenderPass& Canvas::GetCurrentRenderPass() const {
1879 return *render_passes_.back().inline_pass_context->GetRenderPass();
1880 }
1881
1882 void Canvas::SetBackdropData(
1883 std::unordered_map<int64_t, BackdropData> backdrop_data,
1884 size_t backdrop_count) {
1885 backdrop_data_ = std::move(backdrop_data);
1886 backdrop_count_ = backdrop_count;
1887 }
1888
1889 std::shared_ptr<Texture> Canvas::FlipBackdrop(Point global_pass_position,
1890 bool should_remove_texture,
1891 bool should_use_onscreen,
1892 bool post_depth_increment) {
1893 LazyRenderingConfig rendering_config = std::move(render_passes_.back());
1894 render_passes_.pop_back();
1895
1896 // If the very first thing we render in this EntityPass is a subpass that
1897 // happens to have a backdrop filter or advanced blend, than that backdrop
1898 // filter/blend will sample from an uninitialized texture.
1899 //
1900 // By calling `pass_context.GetRenderPass` here, we force the texture to pass
1901 // through at least one RenderPass with the correct clear configuration before
1902 // any sampling occurs.
1903 //
1904 // In cases where there are no contents, we
1905 // could instead check the clear color and initialize a 1x2 CPU texture
1906 // instead of ending the pass.
1907 rendering_config.inline_pass_context->GetRenderPass();
1908 if (!rendering_config.inline_pass_context->EndPass()) {
1909 VALIDATION_LOG
1910 << "Failed to end the current render pass in order to read from "
1911 "the backdrop texture and apply an advanced blend or backdrop "
1912 "filter.";
1913 // Note: adding this render pass ensures there are no later crashes from
1914 // unbalanced save layers. Ideally, this method would return false and the
1915 // renderer could handle that by terminating dispatch.
1916 render_passes_.push_back(LazyRenderingConfig(
1917 renderer_, std::move(rendering_config.entity_pass_target),
1918 std::move(rendering_config.inline_pass_context)));
1919 return nullptr;
1920 }
1921
1922 const std::shared_ptr<Texture>& input_texture =
1923 rendering_config.inline_pass_context->GetTexture();
1924
1925 if (!input_texture) {
1926 VALIDATION_LOG << "Failed to fetch the color texture in order to "
1927 "apply an advanced blend or backdrop filter.";
1928
1929 // Note: see above.
1930 render_passes_.push_back(LazyRenderingConfig(
1931 renderer_, std::move(rendering_config.entity_pass_target),
1932 std::move(rendering_config.inline_pass_context)));
1933 return nullptr;
1934 }
1935
1936 if (should_use_onscreen) {
1937 ColorAttachment color0 = render_target_.GetColorAttachment(0);
1938 // When MSAA is being used, we end up overriding the entire backdrop by
1939 // drawing the previous pass texture, and so we don't have to clear it and
1940 // can use kDontCare.
1941 color0.load_action = color0.resolve_texture != nullptr
1942 ? LoadAction::kDontCare
1943 : LoadAction::kLoad;
1944 render_target_.SetColorAttachment(color0, 0);
1945
1946 auto entity_pass_target = std::make_unique<EntityPassTarget>(
1947 render_target_, //
1948 renderer_.GetDeviceCapabilities().SupportsReadFromResolve(), //
1949 renderer_.GetDeviceCapabilities().SupportsImplicitResolvingMSAA() //
1950 );
1951 render_passes_.push_back(
1952 LazyRenderingConfig(renderer_, std::move(entity_pass_target)));
1953 requires_readback_ = false;
1954 } else {
1955 render_passes_.push_back(LazyRenderingConfig(
1956 renderer_, std::move(rendering_config.entity_pass_target),
1957 std::move(rendering_config.inline_pass_context)));
1958 // If the current texture is being cached for a BDF we need to ensure we
1959 // don't recycle it during recording; remove it from the entity pass target.
1960 if (should_remove_texture) {
1961 render_passes_.back().entity_pass_target->RemoveSecondary();
1962 }
1963 }
1964 RenderPass& current_render_pass =
1965 *render_passes_.back().inline_pass_context->GetRenderPass();
1966
1967 // Eagerly restore the BDF contents.
1968
1969 // If the pass context returns a backdrop texture, we need to draw it to the
1970 // current pass. We do this because it's faster and takes significantly less
1971 // memory than storing/loading large MSAA textures. Also, it's not possible
1972 // to blit the non-MSAA resolve texture of the previous pass to MSAA
1973 // textures (let alone a transient one).
1974 Rect size_rect = Rect::MakeSize(input_texture->GetSize());
1975 auto msaa_backdrop_contents = TextureContents::MakeRect(size_rect);
1976 msaa_backdrop_contents->SetStencilEnabled(false);
1977 msaa_backdrop_contents->SetLabel("MSAA backdrop");
1978 msaa_backdrop_contents->SetSourceRect(size_rect);
1979 msaa_backdrop_contents->SetTexture(input_texture);
1980
1981 Entity msaa_backdrop_entity;
1982 msaa_backdrop_entity.SetContents(std::move(msaa_backdrop_contents));
1983 msaa_backdrop_entity.SetBlendMode(BlendMode::kSrc);
1984 msaa_backdrop_entity.SetClipDepth(std::numeric_limits<uint32_t>::max());
1985 if (!msaa_backdrop_entity.Render(renderer_, current_render_pass)) {
1986 VALIDATION_LOG << "Failed to render MSAA backdrop entity.";
1987 return nullptr;
1988 }
1989
1990 // Restore any clips that were recorded before the backdrop filter was
1991 // applied.
1992 auto& replay_entities = clip_coverage_stack_.GetReplayEntities();
1993 uint64_t current_depth =
1994 post_depth_increment ? current_depth_ - 1 : current_depth_;
1995 for (const auto& replay : replay_entities) {
1996 if (replay.clip_depth <= current_depth) {
1997 continue;
1998 }
1999
2000 SetClipScissor(replay.clip_coverage, current_render_pass,
2001 global_pass_position);
2002 if (!replay.clip_contents.Render(renderer_, current_render_pass,
2003 replay.clip_depth)) {
2004 VALIDATION_LOG << "Failed to render entity for clip restore.";
2005 }
2006 }
2007
2008 return input_texture;
2009 }
2010
2011 bool Canvas::SupportsBlitToOnscreen() const {
2012 return renderer_.GetContext()
2013 ->GetCapabilities()
2014 ->SupportsTextureToTextureBlits() &&
2015 renderer_.GetContext()->GetBackendType() ==
2016 Context::BackendType::kMetal;
2017 }
2018
2019 bool Canvas::BlitToOnscreen(bool is_onscreen) {
2020 auto command_buffer = renderer_.GetContext()->CreateCommandBuffer();
2021 command_buffer->SetLabel("EntityPass Root Command Buffer");
2022 auto offscreen_target = render_passes_.back()
2023 .inline_pass_context->GetPassTarget()
2024 .GetRenderTarget();
2025 if (SupportsBlitToOnscreen()) {
2026 auto blit_pass = command_buffer->CreateBlitPass();
2027 blit_pass->AddCopy(offscreen_target.GetRenderTargetTexture(),
2028 render_target_.GetRenderTargetTexture());
2029 if (!blit_pass->EncodeCommands()) {
2030 VALIDATION_LOG << "Failed to encode root pass blit command.";
2031 return false;
2032 }
2033 } else {
2034 auto render_pass = command_buffer->CreateRenderPass(render_target_);
2035 render_pass->SetLabel("EntityPass Root Render Pass");
2036
2037 {
2038 auto size_rect = Rect::MakeSize(offscreen_target.GetRenderTargetSize());
2039 auto contents = TextureContents::MakeRect(size_rect);
2040 contents->SetTexture(offscreen_target.GetRenderTargetTexture());
2041 contents->SetSourceRect(size_rect);
2042 contents->SetLabel("Root pass blit");
2043
2044 Entity entity;
2045 entity.SetContents(contents);
2046 entity.SetBlendMode(BlendMode::kSrc);
2047
2048 if (!entity.Render(renderer_, *render_pass)) {
2049 VALIDATION_LOG << "Failed to render EntityPass root blit.";
2050 return false;
2051 }
2052 }
2053
2054 if (!render_pass->EncodeCommands()) {
2055 VALIDATION_LOG << "Failed to encode root pass command buffer.";
2056 return false;
2057 }
2058 }
2059
2060 if (is_onscreen) {
2061 return renderer_.GetContext()->SubmitOnscreen(std::move(command_buffer));
2062 } else {
2063 return renderer_.GetContext()->EnqueueCommandBuffer(
2064 std::move(command_buffer));
2065 }
2066 }
2067
2068 bool Canvas::EnsureFinalMipmapGeneration() const {
2069 if (!render_target_.GetRenderTargetTexture()->NeedsMipmapGeneration()) {
2070 return true;
2071 }
2072 std::shared_ptr<CommandBuffer> cmd_buffer =
2073 renderer_.GetContext()->CreateCommandBuffer();
2074 if (!cmd_buffer) {
2075 return false;
2076 }
2077 std::shared_ptr<BlitPass> blit_pass = cmd_buffer->CreateBlitPass();
2078 if (!blit_pass) {
2079 return false;
2080 }
2081 blit_pass->GenerateMipmap(render_target_.GetRenderTargetTexture());
2082 blit_pass->EncodeCommands();
2083 return renderer_.GetContext()->EnqueueCommandBuffer(std::move(cmd_buffer));
2084 }
2085
2086 void Canvas::EndReplay() {
2087 FML_DCHECK(render_passes_.size() == 1u);
2088 render_passes_.back().inline_pass_context->GetRenderPass();
2089 render_passes_.back().inline_pass_context->EndPass(
2090 /*is_onscreen=*/!requires_readback_ && is_onscreen_);
2091 backdrop_data_.clear();
2092
2093 // If requires_readback_ was true, then we rendered to an offscreen texture
2094 // instead of to the onscreen provided in the render target. Now we need to
2095 // draw or blit the offscreen back to the onscreen.
2096 if (requires_readback_) {
2097 BlitToOnscreen(/*is_onscreen_=*/is_onscreen_);
2098 }
2099 if (!EnsureFinalMipmapGeneration()) {
2100 VALIDATION_LOG << "Failed to generate onscreen mipmaps.";
2101 }
2102 if (!renderer_.GetContext()->FlushCommandBuffers()) {
2103 // Not much we can do.
2104 VALIDATION_LOG << "Failed to submit command buffers";
2105 }
2106 render_passes_.clear();
2107 renderer_.GetRenderTargetCache()->End();
2108 clip_geometry_.clear();
2109
2110 Reset();
2111 Initialize(initial_cull_rect_);
2112 }
2113
2114 } // namespace impeller
arc_geometry.h
atlas_contents.h
canvas.h
circle_geometry.h
impeller::ArcGeometry
Definition: arc_geometry.h:17
impeller::ArcStrokeGeometry
A Geometry that produces fillable vertices representing the stroked outline of an |Arc| object using ...
Definition: stroke_path_geometry.h:132
impeller::Canvas::ClipGeometry
void ClipGeometry(const Geometry &geometry, Entity::ClipOperation clip_op, bool is_aa=true)
Definition: canvas.cc:826
impeller::Canvas::kMaxDepth
static constexpr uint32_t kMaxDepth
Definition: canvas.h:122
impeller::Canvas::Canvas
Canvas(ContentContext &renderer, const RenderTarget &render_target, bool is_onscreen, bool requires_readback)
Definition: canvas.cc:197
impeller::Canvas::DrawRoundSuperellipse
void DrawRoundSuperellipse(const RoundSuperellipse &rse, const Paint &paint)
Definition: canvas.cc:781
impeller::Canvas::GetLocalCoverageLimit
std::optional< Rect > GetLocalCoverageLimit() const
Return the culling bounds of the current render target, or nullopt if there is no coverage.
Definition: canvas.cc:1200
impeller::Canvas::SaveLayer
void SaveLayer(const Paint &paint, std::optional< Rect > bounds=std::nullopt, const flutter::DlImageFilter *backdrop_filter=nullptr, ContentBoundsPromise bounds_promise=ContentBoundsPromise::kUnknown, uint32_t total_content_depth=kMaxDepth, bool can_distribute_opacity=false, std::optional< int64_t > backdrop_id=std::nullopt)
Definition: canvas.cc:1231
impeller::Canvas::GetCurrentTransform
const Matrix & GetCurrentTransform() const
Definition: canvas.cc:271
impeller::Canvas::DrawVertices
void DrawVertices(const std::shared_ptr< VerticesGeometry > &vertices, BlendMode blend_mode, const Paint &paint)
Definition: canvas.cc:1004
impeller::Canvas::DrawOval
void DrawOval(const Rect &rect, const Paint &paint)
Definition: canvas.cc:649
impeller::Canvas::DrawImageRect
void DrawImageRect(const std::shared_ptr< Texture > &image, Rect source, Rect dest, const Paint &paint, const SamplerDescriptor &sampler={}, SourceRectConstraint src_rect_constraint=SourceRectConstraint::kFast)
Definition: canvas.cc:939
impeller::Canvas::RestoreToCount
void RestoreToCount(size_t count)
Definition: canvas.cc:318
impeller::Canvas::Restore
bool Restore()
Definition: canvas.cc:1469
impeller::Canvas::GetSaveCount
size_t GetSaveCount() const
Definition: canvas.cc:310
impeller::Canvas::Concat
void Concat(const Matrix &transform)
Definition: canvas.cc:255
impeller::Canvas::Transform
void Transform(const Matrix &transform)
Definition: canvas.cc:267
impeller::Canvas::DrawDashedLine
void DrawDashedLine(const Point &p0, const Point &p1, Scalar on_length, Scalar off_length, const Paint &paint)
Definition: canvas.cc:605
impeller::Canvas::DrawDiffRoundRect
void DrawDiffRoundRect(const RoundRect &outer, const RoundRect &inner, const Paint &paint)
Definition: canvas.cc:765
impeller::Canvas::DrawPath
void DrawPath(const flutter::DlPath &path, const Paint &paint)
Definition: canvas.cc:326
impeller::Canvas::BackdropFilterProc
std::function< std::shared_ptr< FilterContents >(FilterInput::Ref, const Matrix &effect_transform, Entity::RenderingMode rendering_mode)> BackdropFilterProc
Definition: canvas.h:127
impeller::Canvas::PreConcat
void PreConcat(const Matrix &transform)
Definition: canvas.cc:259
impeller::Canvas::Rotate
void Rotate(Radians radians)
Definition: canvas.cc:291
impeller::Canvas::DrawPoints
void DrawPoints(const Point points[], uint32_t count, Scalar radius, const Paint &paint, PointStyle point_style)
Definition: canvas.cc:907
impeller::Canvas::ResetTransform
void ResetTransform()
Definition: canvas.cc:263
impeller::Canvas::DrawTextFrame
void DrawTextFrame(const std::shared_ptr< TextFrame > &text_frame, Point position, const Paint &paint)
Definition: canvas.cc:1660
impeller::Canvas::DrawImage
void DrawImage(const std::shared_ptr< Texture > &image, Point offset, const Paint &paint, const SamplerDescriptor &sampler={})
Definition: canvas.cc:925
impeller::Canvas::DrawPaint
void DrawPaint(const Paint &paint)
Definition: canvas.cc:340
impeller::Canvas::DrawRoundRect
void DrawRoundRect(const RoundRect &rect, const Paint &paint)
Definition: canvas.cc:733
impeller::Canvas::Skew
void Skew(Scalar sx, Scalar sy)
Definition: canvas.cc:287
impeller::Canvas::Scale
void Scale(const Vector2 &scale)
Definition: canvas.cc:279
impeller::Canvas::Save
void Save(uint32_t total_content_depth=kMaxDepth)
Definition: canvas.cc:1183
impeller::Canvas::DrawRect
void DrawRect(const Rect &rect, const Paint &paint)
Definition: canvas.cc:631
impeller::Canvas::DrawAtlas
void DrawAtlas(const std::shared_ptr< AtlasContents > &atlas_contents, const Paint &paint)
Definition: canvas.cc:1117
impeller::Canvas::DrawLine
void DrawLine(const Point &p0, const Point &p1, const Paint &paint, bool reuse_depth=false)
Definition: canvas.cc:583
impeller::Canvas::Translate
void Translate(const Vector3 &offset)
Definition: canvas.cc:275
impeller::Canvas::DrawCircle
void DrawCircle(const Point &center, Scalar radius, const Paint &paint)
Definition: canvas.cc:803
impeller::Canvas::DrawArc
void DrawArc(const Arc &arc, const Paint &paint)
Definition: canvas.cc:678
impeller::Capabilities::SupportsImplicitResolvingMSAA
virtual bool SupportsImplicitResolvingMSAA() const =0
Whether the context backend supports multisampled rendering to the on-screen surface without requirin...
impeller::Capabilities::SupportsFramebufferFetch
virtual bool SupportsFramebufferFetch() const =0
Whether the context backend is able to support pipelines with shaders that read from the framebuffer ...
impeller::Capabilities::SupportsReadFromResolve
virtual bool SupportsReadFromResolve() const =0
Whether the context backend supports binding the current RenderPass attachments. This is supported if...
impeller::CircleGeometry
Definition: circle_geometry.h:14
impeller::ClipContents
Definition: clip_contents.h:29
impeller::ClipContents::SetGeometry
void SetGeometry(GeometryResult geometry)
Set the pre-tessellated clip geometry.
Definition: clip_contents.cc:37
impeller::ClipContents::SetClipOperation
void SetClipOperation(Entity::ClipOperation clip_op)
Definition: clip_contents.cc:41
impeller::ClipContents::Render
bool Render(const ContentContext &renderer, RenderPass &pass, uint32_t clip_depth) const
Definition: clip_contents.cc:70
impeller::ColorFilterContents::AbsorbOpacity::kYes
@ kYes
impeller::ColorFilterContents::MakeBlend
static std::shared_ptr< ColorFilterContents > MakeBlend(BlendMode blend_mode, FilterInput::Vector inputs, std::optional< Color > foreground_color=std::nullopt)
the [inputs] are expected to be in the order of dst, src.
Definition: color_filter_contents.cc:17
impeller::ContentContext
Definition: content_context.h:138
impeller::ContentContext::GetDeviceCapabilities
const Capabilities & GetDeviceCapabilities() const
Definition: content_context.cc:943
impeller::ContentContext::GetRenderTargetCache
const std::shared_ptr< RenderTargetAllocator > & GetRenderTargetCache() const
Definition: content_context.h:269
impeller::ContentContext::GetTextShadowCache
TextShadowCache & GetTextShadowCache() const
Definition: content_context.h:299
impeller::ContentContext::GetContext
std::shared_ptr< Context > GetContext() const
Definition: content_context.cc:939
impeller::CoverGeometry
A geometry that implements "drawPaint" like behavior by covering the entire render pass area.
Definition: cover_geometry.h:14
impeller::EllipseGeometry
A Geometry class that can directly generate vertices (with or without texture coordinates) for filled...
Definition: ellipse_geometry.h:21
impeller::Entity
Definition: entity.h:26
impeller::Entity::SetTransform
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
Definition: entity.cc:60
impeller::Entity::TileMode
TileMode
Definition: entity.h:48
impeller::Entity::GetCoverage
std::optional< Rect > GetCoverage() const
Definition: entity.cc:64
impeller::Entity::RenderingMode
RenderingMode
Definition: entity.h:33
impeller::Entity::RenderingMode::kDirect
@ kDirect
impeller::Entity::RenderingMode::kSubpassPrependSnapshotTransform
@ kSubpassPrependSnapshotTransform
impeller::Entity::RenderingMode::kSubpassAppendSnapshotTransform
@ kSubpassAppendSnapshotTransform
impeller::Entity::GetContents
const std::shared_ptr< Contents > & GetContents() const
Definition: entity.cc:76
impeller::Entity::SetClipDepth
void SetClipDepth(uint32_t clip_depth)
Definition: entity.cc:80
impeller::Entity::GetBlendMode
BlendMode GetBlendMode() const
Definition: entity.cc:101
impeller::Entity::SetContents
void SetContents(std::shared_ptr< Contents > contents)
Definition: entity.cc:72
impeller::Entity::SetBlendMode
void SetBlendMode(BlendMode blend_mode)
Definition: entity.cc:97
impeller::Entity::Render
bool Render(const ContentContext &renderer, RenderPass &parent_pass) const
Definition: entity.cc:144
impeller::Entity::GetTransform
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition: entity.cc:44
impeller::Entity::kLastPipelineBlendMode
static constexpr BlendMode kLastPipelineBlendMode
Definition: entity.h:28
impeller::Entity::IsBlendModeDestructive
static bool IsBlendModeDestructive(BlendMode blend_mode)
Returns true if the blend mode is "destructive", meaning that even fully transparent source colors wo...
Definition: entity.cc:127
impeller::Entity::ClipOperation
ClipOperation
Definition: entity.h:67
impeller::Entity::ClipOperation::kIntersect
@ kIntersect
impeller::Entity::ClipOperation::kDifference
@ kDifference
impeller::EntityPassClipStack
A class that tracks all clips that have been recorded in the current entity pass stencil.
Definition: entity_pass_clip_stack.h:23
impeller::EntityPassClipStack::CurrentClipCoverage
std::optional< Rect > CurrentClipCoverage() const
Definition: entity_pass_clip_stack.cc:24
impeller::EntityPassClipStack::PushSubpass
void PushSubpass(std::optional< Rect > subpass_coverage, size_t clip_height)
Definition: entity_pass_clip_stack.cc:32
impeller::EntityPassClipStack::GetLastReplayResult
ReplayResult & GetLastReplayResult()
Definition: entity_pass_clip_stack.h:61
impeller::EntityPassClipStack::RecordClip
ClipStateResult RecordClip(const ClipContents &clip_contents, Matrix transform, Point global_pass_position, uint32_t clip_depth, size_t clip_height_floor, bool is_aa)
Definition: entity_pass_clip_stack.cc:100
impeller::EntityPassClipStack::RecordRestore
ClipStateResult RecordRestore(Point global_pass_position, size_t restore_height)
Definition: entity_pass_clip_stack.cc:54
impeller::EntityPassClipStack::PopSubpass
void PopSubpass()
Definition: entity_pass_clip_stack.cc:44
impeller::EntityPassClipStack::HasCoverage
bool HasCoverage() const
Definition: entity_pass_clip_stack.cc:28
impeller::FillDiffRoundRectGeometry
A Geometry that produces fillable vertices for the gap between a pair of |RoundRect| objects using th...
Definition: fill_path_geometry.h:70
impeller::FillPathGeometry
A Geometry that produces fillable vertices from a |DlPath| object using the |FillPathSourceGeometry| ...
Definition: fill_path_geometry.h:55
impeller::FillRectGeometry
Definition: rect_geometry.h:13
impeller::FillRoundRectGeometry
A Geometry class that produces fillable vertices from any |RoundRect| object regardless of radii unif...
Definition: round_rect_geometry.h:59
impeller::FilterContents::BlurStyle::kNormal
@ kNormal
Blurred inside and outside.
impeller::FilterContents::BlurStyle::kOuter
@ kOuter
Nothing inside, blurred outside.
impeller::FilterContents::BlurStyle::kInner
@ kInner
Blurred inside, nothing outside.
impeller::FilterContents::BlurStyle::kSolid
@ kSolid
Solid inside, blurred outside.
impeller::FilterInput::Ref
std::shared_ptr< FilterInput > Ref
Definition: filter_input.h:32
impeller::FilterInput::Make
static FilterInput::Ref Make(Variant input, bool msaa_enabled=true)
Definition: filter_input.cc:19
impeller::FilterInput::Vector
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
impeller::Geometry
Definition: geometry.h:50
impeller::Geometry::MakeRect
static std::unique_ptr< Geometry > MakeRect(const Rect &rect)
Definition: geometry.cc:83
impeller::Geometry::GetPositionBuffer
virtual GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const =0
impeller::Geometry::CanApplyMaskFilter
virtual bool CanApplyMaskFilter() const
Definition: geometry.cc:144
impeller::Geometry::GetCoverage
virtual std::optional< Rect > GetCoverage(const Matrix &transform) const =0
impeller::Geometry::IsAxisAlignedRect
virtual bool IsAxisAlignedRect() const
Definition: geometry.cc:140
impeller::LineContents::Make
static std::unique_ptr< LineContents > Make(std::unique_ptr< LineGeometry > geometry, Color color)
Definition: line_contents.cc:137
impeller::PointFieldGeometry
A geometry class specialized for Canvas::DrawPoints.
Definition: point_field_geometry.h:16
impeller::RenderTarget
Definition: render_target.h:38
impeller::RenderTarget::GetColorAttachment
ColorAttachment GetColorAttachment(size_t index) const
Get the color attachment at [index].
Definition: render_target.cc:233
impeller::RenderTarget::SetColorAttachment
RenderTarget & SetColorAttachment(const ColorAttachment &attachment, size_t index)
Definition: render_target.cc:199
impeller::RenderTarget::GetRenderTargetSize
ISize GetRenderTargetSize() const
Definition: render_target.cc:171
impeller::RenderTarget::GetDepthAttachment
const std::optional< DepthAttachment > & GetDepthAttachment() const
Definition: render_target.cc:247
impeller::RenderTarget::GetStencilAttachment
const std::optional< StencilAttachment > & GetStencilAttachment() const
Definition: render_target.cc:251
impeller::RenderTarget::SetupDepthStencilAttachments
void SetupDepthStencilAttachments(const Context &context, Allocator &allocator, ISize size, bool msaa, std::string_view label="Offscreen", RenderTarget::AttachmentConfig stencil_attachment_config=RenderTarget::kDefaultStencilAttachmentConfig, const std::shared_ptr< Texture > &depth_stencil_texture=nullptr)
Definition: render_target.cc:475
impeller::RoundRectGeometry
A Geometry class that generates fillable vertices (with or without texture coordinates) directly from...
Definition: round_rect_geometry.h:25
impeller::RoundSuperellipseGeometry
A Geometry class that generates fillable vertices (with or without texture coordinates) directly from...
Definition: round_superellipse_geometry.h:30
impeller::StrokeDashedLineGeometry
A Geometry that produces fillable vertices representing the stroked outline of a |DlPath| object usin...
Definition: stroke_path_geometry.h:170
impeller::StrokeDiffRoundRectGeometry
A Geometry that produces fillable vertices representing the stroked outline of a pair of nested |Roun...
Definition: stroke_path_geometry.h:152
impeller::StrokeEllipseGeometry
A Geometry class that produces fillable vertices representing the stroked outline of an ellipse with ...
Definition: ellipse_geometry.h:54
impeller::StrokePathGeometry
A Geometry that produces fillable vertices representing the stroked outline of a |DlPath| object usin...
Definition: stroke_path_geometry.h:115
impeller::StrokeRectGeometry
Definition: rect_geometry.h:37
impeller::StrokeRoundRectGeometry
A Geometry class that produces fillable vertices representing the stroked outline of any |Roundrect| ...
Definition: round_rect_geometry.h:80
impeller::StrokeRoundSuperellipseGeometry
A Geometry class that produces fillable vertices representing the stroked outline of any |RoundSupere...
Definition: round_superellipse_geometry.h:69
impeller::TextShadowCache::Lookup
std::optional< Entity > Lookup(const ContentContext &renderer, const Entity &entity, const std::shared_ptr< FilterContents > &contents, const TextShadowCacheKey &)
Lookup the entity in the cache with the given filter/text contents, returning the new entity to rende...
Definition: text_shadow_cache.cc:41
impeller::TextureContents::MakeRect
static std::shared_ptr< TextureContents > MakeRect(Rect destination)
Definition: texture_contents.cc:28
clip_contents.h
color.h
color_source_contents.h
command_buffer.h
content_context.h
formats.h
cover_geometry.h
color_filter.h
image_filter.h
ellipse_geometry.h
fill_path_geometry.h
filter_contents.h
framebuffer_blend_contents.h
subpass_size
ISize subpass_size
The output size of the down-sampling pass.
Definition: gaussian_blur_filter_contents.cc:202
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:214
constants.h
geometry.h
line_contents.h
line_geometry.h
impeller::skia_conversions::ToSamplerDescriptor
impeller::SamplerDescriptor ToSamplerDescriptor(const flutter::DlImageSampling options)
Definition: skia_conversions.cc:24
impeller::skia_conversions::ToColor
Color ToColor(const flutter::DlColor &color)
Definition: skia_conversions.cc:13
impeller
Definition: allocation.cc:12
impeller::kMaxTextScale
static constexpr Scalar kMaxTextScale
Definition: canvas.cc:1658
impeller::WrapWithGPUColorFilter
std::shared_ptr< ColorFilterContents > WrapWithGPUColorFilter(const flutter::DlColorFilter *filter, const std::shared_ptr< FilterInput > &input, ColorFilterContents::AbsorbOpacity absorb_opacity)
Definition: color_filter.cc:24
impeller::Scalar
float Scalar
Definition: scalar.h:19
impeller::SourceRectConstraint
SourceRectConstraint
Controls the behavior of the source rectangle given to DrawImageRect.
Definition: canvas.h:74
impeller::SourceRectConstraint::kStrict
@ kStrict
Sample only within the source rectangle. May be slower.
impeller::WrapInput
std::shared_ptr< FilterContents > WrapInput(const flutter::DlImageFilter *filter, const FilterInput::Ref &input)
Generate a new FilterContents using this filter's configuration.
Definition: image_filter.cc:18
impeller::kEhCloseEnough
constexpr float kEhCloseEnough
Definition: constants.h:57
impeller::WrapWithInvertColors
std::shared_ptr< ColorFilterContents > WrapWithInvertColors(const std::shared_ptr< FilterInput > &input, ColorFilterContents::AbsorbOpacity absorb_opacity)
Definition: color_filter.cc:16
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:792
impeller::PointStyle
PointStyle
Definition: canvas.h:65
impeller::PointStyle::kRound
@ kRound
Points are drawn as squares.
impeller::Point
TPoint< Scalar > Point
Definition: point.h:327
impeller::StorageMode::kDevicePrivate
@ kDevicePrivate
impeller::StorageMode::kDeviceTransient
@ kDeviceTransient
impeller::Cap::kRound
@ kRound
impeller::GetCPUColorFilterProc
ColorFilterProc GetCPUColorFilterProc(const flutter::DlColorFilter *filter)
Definition: color_filter.cc:66
impeller::IRect
IRect64 IRect
Definition: rect.h:795
impeller::DlPath
flutter::DlPath DlPath
Definition: dl_dispatcher.h:29
impeller::BlendMode
BlendMode
Definition: color.h:58
impeller::BlendMode::kDst
@ kDst
impeller::BlendMode::kSrcOver
@ kSrcOver
impeller::BlendMode::kSrc
@ kSrc
impeller::ContentBoundsPromise
ContentBoundsPromise
Definition: canvas.h:84
impeller::ContentBoundsPromise::kMayClipContents
@ kMayClipContents
The caller claims the bounds are a subset of an estimate of the reasonably tight bounds but likely cl...
impeller::ContentBoundsPromise::kContainsContents
@ kContainsContents
The caller claims the bounds are a reasonably tight estimate of the coverage of the contents and shou...
impeller::LoadAction::kDontCare
@ kDontCare
impeller::StoreAction::kDontCare
@ kDontCare
impeller::StoreAction::kMultisampleResolve
@ kMultisampleResolve
impeller::Size
TSize< Scalar > Size
Definition: size.h:159
impeller::kColorInversion
static constexpr const ColorMatrix kColorInversion
A color matrix which inverts colors.
Definition: color_filter.h:16
impeller::ComputeSaveLayerCoverage
std::optional< Rect > ComputeSaveLayerCoverage(const Rect &content_coverage, const Matrix &effect_transform, const Rect &coverage_limit, const std::shared_ptr< FilterContents > &image_filter, bool flood_output_coverage, bool flood_input_coverage)
Compute the coverage of a subpass in the global coordinate space.
Definition: save_layer_utils.cc:19
impeller::ISize
ISize64 ISize
Definition: size.h:162
point_field_geometry.h
rect_geometry.h
rstransform.h
save_layer_utils.h
skia_conversions.h
solid_rrect_blur_contents.h
solid_rsuperellipse_blur_contents.h
stroke_path_geometry.h
impeller::Arc
Definition: arc.h:13
impeller::Arc::IncludeCenter
constexpr bool IncludeCenter() const
Definition: arc.h:110
impeller::Arc::IsFullCircle
constexpr bool IsFullCircle() const
Definition: arc.h:114
impeller::Arc::GetOvalBounds
const Rect & GetOvalBounds() const
Return the bounds of the oval in which this arc is inscribed.
Definition: arc.h:94
impeller::Arc::GetSweep
constexpr Degrees GetSweep() const
Definition: arc.h:108
impeller::Arc::GetStart
constexpr Degrees GetStart() const
Definition: arc.h:106
impeller::Attachment::load_action
LoadAction load_action
Definition: formats.h:659
impeller::Attachment::texture
std::shared_ptr< Texture > texture
Definition: formats.h:657
impeller::BackdropData
Definition: canvas.h:40
impeller::BackdropData::all_filters_equal
bool all_filters_equal
Definition: canvas.h:42
impeller::BackdropData::texture_slot
std::shared_ptr< Texture > texture_slot
Definition: canvas.h:43
impeller::BackdropData::backdrop_count
size_t backdrop_count
Definition: canvas.h:41
impeller::BackdropData::shared_filter_snapshot
std::optional< Snapshot > shared_filter_snapshot
Definition: canvas.h:46
impeller::Canvas::SaveLayerState
Definition: canvas.h:265
impeller::Canvas::SaveLayerState::coverage
Rect coverage
Definition: canvas.h:267
impeller::Canvas::SaveLayerState::paint
Paint paint
Definition: canvas.h:266
impeller::CanvasStackEntry
Definition: canvas.h:50
impeller::CanvasStackEntry::clip_height
size_t clip_height
Definition: canvas.h:53
impeller::CanvasStackEntry::did_round_out
bool did_round_out
Definition: canvas.h:62
impeller::CanvasStackEntry::rendering_mode
Entity::RenderingMode rendering_mode
Definition: canvas.h:57
impeller::CanvasStackEntry::transform
Matrix transform
Definition: canvas.h:51
impeller::CanvasStackEntry::clip_depth
uint32_t clip_depth
Definition: canvas.h:52
impeller::ColorAttachment
Definition: formats.h:665
impeller::ColorAttachment::clear_color
Color clear_color
Definition: formats.h:666
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:270
impeller::Color::Khaki
static constexpr Color Khaki()
Definition: color.h:518
impeller::Color::alpha
Scalar alpha
Definition: color.h:143
impeller::Color::White
static constexpr Color White()
Definition: color.h:264
impeller::Color::WithAlpha
constexpr Color WithAlpha(Scalar new_alpha) const
Definition: color.h:278
impeller::ColorMatrix
Definition: color.h:117
impeller::ColorMatrix::array
Scalar array[20]
Definition: color.h:118
impeller::EntityPassClipStack::ClipStateResult
Definition: entity_pass_clip_stack.h:32
impeller::EntityPassClipStack::ClipStateResult::clip_did_change
bool clip_did_change
Definition: entity_pass_clip_stack.h:38
impeller::EntityPassClipStack::ClipStateResult::should_render
bool should_render
Definition: entity_pass_clip_stack.h:35
impeller::EntityPassClipStack::ReplayResult::clip_contents
ClipContents clip_contents
Definition: entity_pass_clip_stack.h:26
impeller::GeometryResult
Definition: geometry.h:21
impeller::LazyRenderingConfig
Definition: canvas.h:99
impeller::LazyRenderingConfig::inline_pass_context
std::unique_ptr< InlinePassContext > inline_pass_context
Definition: canvas.h:101
impeller::LazyRenderingConfig::entity_pass_target
std::unique_ptr< EntityPassTarget > entity_pass_target
Definition: canvas.h:100
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::Matrix::MakeTranslation
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition: matrix.h:95
impeller::Matrix::Invert
Matrix Invert() const
Definition: matrix.cc:97
impeller::Matrix::MakeSkew
static constexpr Matrix MakeSkew(Scalar sx, Scalar sy)
Definition: matrix.h:127
impeller::Matrix::MakeTranslateScale
static constexpr Matrix MakeTranslateScale(const Vector3 &s, const Vector3 &t)
Definition: matrix.h:113
impeller::Matrix::MakeRotationZ
static Matrix MakeRotationZ(Radians r)
Definition: matrix.h:223
impeller::Matrix::MakeScale
static constexpr Matrix MakeScale(const Vector3 &s)
Definition: matrix.h:104
impeller::Matrix::GetMaxBasisLengthXY
Scalar GetMaxBasisLengthXY() const
Definition: matrix.h:323
impeller::Paint
Definition: paint.h:27
impeller::Paint::WithFilters
std::shared_ptr< Contents > WithFilters(std::shared_ptr< Contents > input) const
Wrap this paint's configured filters to the given contents.
Definition: paint.cc:278
impeller::Paint::color_filter
const flutter::DlColorFilter * color_filter
Definition: paint.h:77
impeller::Paint::color_source
const flutter::DlColorSource * color_source
Definition: paint.h:76
impeller::Paint::Style::kStroke
@ kStroke
impeller::Paint::Style::kFill
@ kFill
impeller::Paint::image_filter
const flutter::DlImageFilter * image_filter
Definition: paint.h:78
impeller::Paint::style
Style style
Definition: paint.h:81
impeller::Paint::invert_colors
bool invert_colors
Definition: paint.h:83
impeller::Paint::CanApplyOpacityPeephole
static bool CanApplyOpacityPeephole(const Paint &paint)
Whether or not a save layer with the provided paint can perform the opacity peephole optimization.
Definition: paint.h:40
impeller::Paint::mask_blur_descriptor
std::optional< MaskBlurDescriptor > mask_blur_descriptor
Definition: paint.h:85
impeller::Paint::color
Color color
Definition: paint.h:75
impeller::Paint::blend_mode
BlendMode blend_mode
Definition: paint.h:82
impeller::Paint::WithImageFilter
std::shared_ptr< FilterContents > WithImageFilter(const FilterInput::Variant &input, const Matrix &effect_transform, Entity::RenderingMode rendering_mode) const
Definition: paint.cc:312
impeller::Paint::stroke
StrokeParameters stroke
Definition: paint.h:80
impeller::Paint::CreateContents
std::shared_ptr< ColorSourceContents > CreateContents() const
Definition: paint.cc:62
impeller::Paint::HasColorFilter
bool HasColorFilter() const
Whether this paint has a color filter that can apply opacity.
Definition: paint.cc:469
impeller::Radians
Definition: scalar.h:44
impeller::RoundRect
Definition: round_rect.h:16
impeller::RoundRect::GetRadii
constexpr const RoundingRadii & GetRadii() const
Definition: round_rect.h:55
impeller::RoundRect::GetBounds
constexpr const Rect & GetBounds() const
Definition: round_rect.h:53
impeller::RoundSuperellipse
Definition: round_superellipse.h:18
impeller::RoundSuperellipse::GetRadii
constexpr const RoundingRadii & GetRadii() const
Definition: round_superellipse.h:50
impeller::RoundSuperellipse::GetBounds
constexpr const Rect & GetBounds() const
Definition: round_superellipse.h:49
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:14
impeller::Snapshot
Represents a texture and its intended draw transform/sampler configuration.
Definition: snapshot.h:24
impeller::Snapshot::transform
Matrix transform
The transform that should be applied to this texture for rendering.
Definition: snapshot.h:27
impeller::Snapshot::texture
std::shared_ptr< Texture > texture
Definition: snapshot.h:25
impeller::Snapshot::sampler_descriptor
SamplerDescriptor sampler_descriptor
Definition: snapshot.h:29
impeller::StrokeParameters::cap
Cap cap
Definition: stroke_parameters.h:30
impeller::StrokeParameters::width
Scalar width
Definition: stroke_parameters.h:29
impeller::TPoint< Scalar >
impeller::TPoint::GetDistance
constexpr Type GetDistance(const TPoint &p) const
Definition: point.h:200
impeller::TRect< Scalar >
impeller::TRect::Expand
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
Definition: rect.h:622
impeller::TRect::GetBottom
constexpr auto GetBottom() const
Definition: rect.h:361
impeller::TRect::TransformBounds
constexpr TRect TransformBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle.
Definition: rect.h:476
impeller::TRect::GetTop
constexpr auto GetTop() const
Definition: rect.h:357
impeller::TRect::GetHeight
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition: rect.h:351
impeller::TRect::GetOrigin
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...
Definition: rect.h:324
impeller::TRect::Intersection
constexpr std::optional< TRect > Intersection(const TRect &o) const
Definition: rect.h:532
impeller::TRect::IsEmpty
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition: rect.h:301
impeller::TRect< Scalar >::MakeOriginSize
constexpr static TRect MakeOriginSize(const TPoint< Type > &origin, const TSize< Type > &size)
Definition: rect.h:144
impeller::TRect::GetLeft
constexpr auto GetLeft() const
Definition: rect.h:355
impeller::TRect::GetSize
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...
Definition: rect.h:331
impeller::TRect< Scalar >::Round
Round(const TRect< U > &r)
Definition: rect.h:699
impeller::TRect::RoundOut
RoundOut(const TRect< U > &r)
Definition: rect.h:683
impeller::TRect::GetRight
constexpr auto GetRight() const
Definition: rect.h:359
impeller::TRect::IsSquare
constexpr bool IsSquare() const
Returns true if width and height are equal and neither is NaN.
Definition: rect.h:308
impeller::TRect< Scalar >::MakeXYWH
constexpr static TRect MakeXYWH(Type x, Type y, Type width, Type height)
Definition: rect.h:136
impeller::TRect::Shift
constexpr TRect< T > Shift(T dx, T dy) const
Returns a new rectangle translated by the given offset.
Definition: rect.h:606
impeller::TRect::MakeSize
constexpr static TRect MakeSize(const TSize< U > &size)
Definition: rect.h:150
impeller::TRect::GetWidth
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition: rect.h:345
impeller::TRect::GetCenter
constexpr Point GetCenter() const
Get the center point as a |Point|.
Definition: rect.h:386
impeller::TRect< Scalar >::MakeLTRB
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129
impeller::TRect< Scalar >::MakeMaximum
constexpr static TRect MakeMaximum()
Definition: rect.h:188
impeller::TSize< Scalar >
impeller::TSize::IsEmpty
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition: size.h:123
impeller::Vector3
Definition: vector.h:20
points
std::vector< Point > points
Definition: tessellator_libtess.cc:76
text_contents.h
text_shadow_cache.h
texture_contents.h
validation.h
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
vertices_contents.h