CommandExecutorCPU.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. /*
  2. * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGfx/Filters/StackBlurFilter.h>
  7. #include <LibWeb/CSS/ComputedValues.h>
  8. #include <LibWeb/Painting/BorderRadiusCornerClipper.h>
  9. #include <LibWeb/Painting/CommandExecutorCPU.h>
  10. #include <LibWeb/Painting/FilterPainting.h>
  11. #include <LibWeb/Painting/RecordingPainter.h>
  12. #include <LibWeb/Painting/ShadowPainting.h>
  13. namespace Web::Painting {
  14. CommandExecutorCPU::CommandExecutorCPU(Gfx::Bitmap& bitmap, bool enable_affine_command_executor)
  15. : m_target_bitmap(bitmap)
  16. , m_enable_affine_command_executor(enable_affine_command_executor)
  17. {
  18. stacking_contexts.append({ .painter = AK::make<Gfx::Painter>(bitmap),
  19. .opacity = 1.0f,
  20. .destination = {},
  21. .scaling_mode = {} });
  22. }
  23. CommandResult CommandExecutorCPU::draw_glyph_run(DrawGlyphRun const& command)
  24. {
  25. auto& painter = this->painter();
  26. auto const& glyphs = command.glyph_run->glyphs();
  27. for (auto& glyph_or_emoji : glyphs) {
  28. auto transformed_glyph = glyph_or_emoji;
  29. transformed_glyph.visit([&](auto& glyph) {
  30. glyph.position = glyph.position.scaled(command.scale).translated(command.translation);
  31. glyph.font = glyph.font->with_size(glyph.font->point_size() * static_cast<float>(command.scale));
  32. });
  33. if (glyph_or_emoji.has<Gfx::DrawGlyph>()) {
  34. auto& glyph = transformed_glyph.get<Gfx::DrawGlyph>();
  35. painter.draw_glyph(glyph.position, glyph.code_point, *glyph.font, command.color);
  36. } else {
  37. auto& emoji = transformed_glyph.get<Gfx::DrawEmoji>();
  38. painter.draw_emoji(emoji.position.to_type<int>(), *emoji.emoji, *emoji.font);
  39. }
  40. }
  41. return CommandResult::Continue;
  42. }
  43. CommandResult CommandExecutorCPU::draw_text(DrawText const& command)
  44. {
  45. auto& painter = this->painter();
  46. painter.draw_text(command.rect, command.raw_text, command.font, command.alignment, command.color, command.elision, command.wrapping);
  47. return CommandResult::Continue;
  48. }
  49. template<typename Callback>
  50. void apply_clip_paths_to_painter(Gfx::IntRect const& rect, Callback callback, Vector<Gfx::Path> const& clip_paths, Gfx::Painter& target_painter)
  51. {
  52. // Setup a painter for a background canvas that we will paint to first.
  53. auto background_canvas = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, rect.size()).release_value_but_fixme_should_propagate_errors();
  54. Gfx::Painter painter(*background_canvas);
  55. // Offset the painter to paint in the correct location.
  56. painter.translate(-rect.location());
  57. // Paint the background canvas.
  58. callback(painter);
  59. // Apply the clip path to the target painter.
  60. Gfx::AntiAliasingPainter aa_painter(target_painter);
  61. for (auto const& clip_path : clip_paths) {
  62. auto fill_offset = clip_path.bounding_box().location().to_type<int>() - rect.location();
  63. auto paint_style = Gfx::BitmapPaintStyle::create(*background_canvas, fill_offset).release_value_but_fixme_should_propagate_errors();
  64. aa_painter.fill_path(clip_path, paint_style);
  65. }
  66. }
  67. CommandResult CommandExecutorCPU::fill_rect(FillRect const& command)
  68. {
  69. auto paint_op = [&](Gfx::Painter& painter) {
  70. painter.fill_rect(command.rect, command.color);
  71. };
  72. if (command.clip_paths.is_empty()) {
  73. paint_op(painter());
  74. } else {
  75. apply_clip_paths_to_painter(command.rect, paint_op, command.clip_paths, painter());
  76. }
  77. return CommandResult::Continue;
  78. }
  79. CommandResult CommandExecutorCPU::draw_scaled_bitmap(DrawScaledBitmap const& command)
  80. {
  81. auto& painter = this->painter();
  82. painter.draw_scaled_bitmap(command.dst_rect, command.bitmap, command.src_rect, 1, command.scaling_mode);
  83. return CommandResult::Continue;
  84. }
  85. CommandResult CommandExecutorCPU::draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const& command)
  86. {
  87. auto paint_op = [&](Gfx::Painter& painter) {
  88. painter.draw_scaled_bitmap(command.dst_rect, command.bitmap->bitmap(), command.src_rect, 1, command.scaling_mode);
  89. };
  90. if (command.clip_paths.is_empty()) {
  91. paint_op(painter());
  92. } else {
  93. apply_clip_paths_to_painter(command.dst_rect, paint_op, command.clip_paths, painter());
  94. }
  95. return CommandResult::Continue;
  96. }
  97. CommandResult CommandExecutorCPU::set_clip_rect(SetClipRect const& command)
  98. {
  99. auto& painter = this->painter();
  100. painter.clear_clip_rect();
  101. painter.add_clip_rect(command.rect);
  102. return CommandResult::Continue;
  103. }
  104. CommandResult CommandExecutorCPU::clear_clip_rect(ClearClipRect const&)
  105. {
  106. painter().clear_clip_rect();
  107. return CommandResult::Continue;
  108. }
  109. CommandResult CommandExecutorCPU::push_stacking_context(PushStackingContext const& command)
  110. {
  111. // FIXME: This extracts the affine 2D part of the full transformation matrix.
  112. // Use the whole matrix when we get better transformation support in LibGfx or use LibGL for drawing the bitmap
  113. auto affine_transform = Gfx::extract_2d_affine_transform(command.transform.matrix);
  114. if (m_enable_affine_command_executor && command.opacity == 1.0f && !affine_transform.is_identity_or_translation()) {
  115. auto offset = command.is_fixed_position ? Gfx::IntPoint {} : painter().translation();
  116. auto full_transform = Gfx::AffineTransform {}
  117. .set_translation((command.post_transform_translation + offset).to_type<float>())
  118. .translate(command.transform.origin)
  119. .multiply(affine_transform)
  120. .translate(-command.transform.origin);
  121. m_affine_command_executor = AffineCommandExecutorCPU(m_target_bitmap, full_transform, painter().clip_rect());
  122. return CommandResult::ContinueWithNestedExecutor;
  123. }
  124. painter().save();
  125. if (command.is_fixed_position)
  126. painter().translate(-painter().translation());
  127. if (command.mask.has_value()) {
  128. // TODO: Support masks and other stacking context features at the same time.
  129. // Note: Currently only SVG masking is implemented (which does not use CSS transforms anyway).
  130. auto bitmap_or_error = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, command.mask->mask_bitmap->size());
  131. if (bitmap_or_error.is_error())
  132. return CommandResult::Continue;
  133. auto bitmap = bitmap_or_error.release_value();
  134. stacking_contexts.append(StackingContext {
  135. .painter = AK::make<Gfx::Painter>(bitmap),
  136. .opacity = 1,
  137. .destination = command.source_paintable_rect.translated(command.post_transform_translation),
  138. .scaling_mode = Gfx::ScalingMode::None,
  139. .mask = command.mask });
  140. painter().translate(-command.source_paintable_rect.location());
  141. return CommandResult::Continue;
  142. }
  143. if (command.opacity == 1.0f && affine_transform.is_identity_or_translation()) {
  144. // OPTIMIZATION: This is a simple translation use previous stacking context's painter.
  145. painter().translate(affine_transform.translation().to_rounded<int>() + command.post_transform_translation);
  146. stacking_contexts.append(StackingContext {
  147. .painter = MaybeOwned(painter()),
  148. .opacity = 1,
  149. .destination = {},
  150. .scaling_mode = {} });
  151. return CommandResult::Continue;
  152. }
  153. auto& current_painter = this->painter();
  154. auto source_rect = command.source_paintable_rect.to_type<float>().translated(-command.transform.origin);
  155. auto transformed_destination_rect = affine_transform.map(source_rect).translated(command.transform.origin);
  156. auto destination_rect = transformed_destination_rect.to_rounded<int>();
  157. // FIXME: We should find a way to scale the paintable, rather than paint into a separate bitmap,
  158. // then scale it. This snippet now copies the background at the destination, then scales it down/up
  159. // to the size of the source (which could add some artefacts, though just scaling the bitmap already does that).
  160. // We need to copy the background at the destination because a bunch of our rendering effects now rely on
  161. // being able to sample the painter (see border radii, shadows, filters, etc).
  162. Gfx::FloatPoint destination_clipped_fixup {};
  163. auto try_get_scaled_destination_bitmap = [&]() -> ErrorOr<NonnullRefPtr<Gfx::Bitmap>> {
  164. Gfx::IntRect actual_destination_rect;
  165. auto bitmap = TRY(current_painter.get_region_bitmap(destination_rect, Gfx::BitmapFormat::BGRA8888, actual_destination_rect));
  166. // get_region_bitmap() may clip to a smaller region if the requested rect goes outside the painter, so we need to account for that.
  167. destination_clipped_fixup = Gfx::FloatPoint { destination_rect.location() - actual_destination_rect.location() };
  168. destination_rect = actual_destination_rect;
  169. if (source_rect.size() != transformed_destination_rect.size()) {
  170. auto sx = static_cast<float>(source_rect.width()) / transformed_destination_rect.width();
  171. auto sy = static_cast<float>(source_rect.height()) / transformed_destination_rect.height();
  172. bitmap = TRY(bitmap->scaled(sx, sy));
  173. destination_clipped_fixup.scale_by(sx, sy);
  174. }
  175. return bitmap;
  176. };
  177. auto bitmap_or_error = try_get_scaled_destination_bitmap();
  178. if (bitmap_or_error.is_error()) {
  179. // NOTE: If the creation of the bitmap fails, we need to skip all painting commands that belong to this stacking context.
  180. // We don't interrupt the execution of painting commands because get_region_bitmap() returns an error if the requested
  181. // region is outside of the viewport (mmap fails to allocate a zero-size region), which means we can safely proceed
  182. // with execution of commands outside of this stacking context.
  183. // FIXME: Change the get_region_bitmap() API to return ErrorOr<Optional<Bitmap>> and exit the execution of commands here
  184. // if we run out of memory.
  185. painter().restore();
  186. return CommandResult::SkipStackingContext;
  187. }
  188. auto bitmap = bitmap_or_error.release_value();
  189. stacking_contexts.append(StackingContext {
  190. .painter = AK::make<Gfx::Painter>(bitmap),
  191. .opacity = command.opacity,
  192. .destination = destination_rect.translated(command.post_transform_translation),
  193. .scaling_mode = CSS::to_gfx_scaling_mode(command.image_rendering, destination_rect, destination_rect) });
  194. painter().translate(-command.source_paintable_rect.location() + destination_clipped_fixup.to_type<int>());
  195. return CommandResult::Continue;
  196. }
  197. CommandResult CommandExecutorCPU::pop_stacking_context(PopStackingContext const&)
  198. {
  199. ScopeGuard restore_painter = [&] {
  200. painter().restore();
  201. };
  202. auto stacking_context = stacking_contexts.take_last();
  203. // Stacking contexts that don't own their painter are simple translations, and don't need to blit anything back.
  204. if (stacking_context.painter.is_owned()) {
  205. auto bitmap = stacking_context.painter->target();
  206. if (stacking_context.mask.has_value())
  207. bitmap->apply_mask(*stacking_context.mask->mask_bitmap, stacking_context.mask->mask_kind);
  208. auto destination_rect = stacking_context.destination;
  209. if (destination_rect.size() == bitmap->size()) {
  210. painter().blit(destination_rect.location(), *bitmap, bitmap->rect(), stacking_context.opacity);
  211. } else {
  212. painter().draw_scaled_bitmap(destination_rect, *bitmap, bitmap->rect(), stacking_context.opacity, stacking_context.scaling_mode);
  213. }
  214. }
  215. return CommandResult::Continue;
  216. }
  217. CommandResult CommandExecutorCPU::paint_linear_gradient(PaintLinearGradient const& command)
  218. {
  219. auto const& linear_gradient_data = command.linear_gradient_data;
  220. auto paint_op = [&](Gfx::Painter& painter) {
  221. painter.fill_rect_with_linear_gradient(
  222. command.gradient_rect, linear_gradient_data.color_stops.list,
  223. linear_gradient_data.gradient_angle, linear_gradient_data.color_stops.repeat_length);
  224. };
  225. if (command.clip_paths.is_empty()) {
  226. paint_op(painter());
  227. } else {
  228. apply_clip_paths_to_painter(command.gradient_rect, paint_op, command.clip_paths, painter());
  229. }
  230. return CommandResult::Continue;
  231. }
  232. CommandResult CommandExecutorCPU::paint_outer_box_shadow(PaintOuterBoxShadow const& command)
  233. {
  234. auto& painter = this->painter();
  235. Web::Painting::paint_outer_box_shadow(painter, command.outer_box_shadow_params);
  236. return CommandResult::Continue;
  237. }
  238. CommandResult CommandExecutorCPU::paint_inner_box_shadow(PaintInnerBoxShadow const& command)
  239. {
  240. auto& painter = this->painter();
  241. Web::Painting::paint_inner_box_shadow(painter, command.outer_box_shadow_params);
  242. return CommandResult::Continue;
  243. }
  244. CommandResult CommandExecutorCPU::paint_text_shadow(PaintTextShadow const& command)
  245. {
  246. // FIXME: Figure out the maximum bitmap size for all shadows and then allocate it once and reuse it?
  247. auto maybe_shadow_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, command.shadow_bounding_rect.size());
  248. if (maybe_shadow_bitmap.is_error()) {
  249. dbgln("Unable to allocate temporary bitmap {} for text-shadow rendering: {}", command.shadow_bounding_rect.size(), maybe_shadow_bitmap.error());
  250. return CommandResult::Continue;
  251. }
  252. auto shadow_bitmap = maybe_shadow_bitmap.release_value();
  253. Gfx::Painter shadow_painter { *shadow_bitmap };
  254. // FIXME: "Spread" the shadow somehow.
  255. Gfx::IntPoint const baseline_start(command.text_rect.x(), command.text_rect.y() + command.fragment_baseline);
  256. shadow_painter.translate(baseline_start);
  257. for (auto const& glyph_or_emoji : command.glyph_run) {
  258. if (glyph_or_emoji.has<Gfx::DrawGlyph>()) {
  259. auto const& glyph = glyph_or_emoji.get<Gfx::DrawGlyph>();
  260. shadow_painter.draw_glyph(glyph.position, glyph.code_point, *glyph.font, command.color);
  261. } else {
  262. auto const& emoji = glyph_or_emoji.get<Gfx::DrawEmoji>();
  263. shadow_painter.draw_emoji(emoji.position.to_type<int>(), *emoji.emoji, *emoji.font);
  264. }
  265. }
  266. // Blur
  267. Gfx::StackBlurFilter filter(*shadow_bitmap);
  268. filter.process_rgba(command.blur_radius, command.color);
  269. painter().blit(command.draw_location, *shadow_bitmap, command.shadow_bounding_rect);
  270. return CommandResult::Continue;
  271. }
  272. CommandResult CommandExecutorCPU::fill_rect_with_rounded_corners(FillRectWithRoundedCorners const& command)
  273. {
  274. auto paint_op = [&](Gfx::Painter& painter) {
  275. Gfx::AntiAliasingPainter aa_painter(painter);
  276. aa_painter.fill_rect_with_rounded_corners(
  277. command.rect,
  278. command.color,
  279. command.top_left_radius,
  280. command.top_right_radius,
  281. command.bottom_right_radius,
  282. command.bottom_left_radius);
  283. };
  284. if (command.clip_paths.is_empty()) {
  285. paint_op(painter());
  286. } else {
  287. apply_clip_paths_to_painter(command.rect, paint_op, command.clip_paths, painter());
  288. }
  289. return CommandResult::Continue;
  290. }
  291. CommandResult CommandExecutorCPU::fill_path_using_color(FillPathUsingColor const& command)
  292. {
  293. Gfx::AntiAliasingPainter aa_painter(painter());
  294. aa_painter.translate(command.aa_translation);
  295. aa_painter.fill_path(command.path, command.color, command.winding_rule);
  296. return CommandResult::Continue;
  297. }
  298. CommandResult CommandExecutorCPU::fill_path_using_paint_style(FillPathUsingPaintStyle const& command)
  299. {
  300. Gfx::AntiAliasingPainter aa_painter(painter());
  301. aa_painter.translate(command.aa_translation);
  302. aa_painter.fill_path(command.path, command.paint_style, command.opacity, command.winding_rule);
  303. return CommandResult::Continue;
  304. }
  305. CommandResult CommandExecutorCPU::stroke_path_using_color(StrokePathUsingColor const& command)
  306. {
  307. Gfx::AntiAliasingPainter aa_painter(painter());
  308. aa_painter.translate(command.aa_translation);
  309. aa_painter.stroke_path(command.path, command.color, command.thickness);
  310. return CommandResult::Continue;
  311. }
  312. CommandResult CommandExecutorCPU::stroke_path_using_paint_style(StrokePathUsingPaintStyle const& command)
  313. {
  314. Gfx::AntiAliasingPainter aa_painter(painter());
  315. aa_painter.translate(command.aa_translation);
  316. aa_painter.stroke_path(command.path, command.paint_style, command.thickness, command.opacity);
  317. return CommandResult::Continue;
  318. }
  319. CommandResult CommandExecutorCPU::draw_ellipse(DrawEllipse const& command)
  320. {
  321. Gfx::AntiAliasingPainter aa_painter(painter());
  322. aa_painter.draw_ellipse(command.rect, command.color, command.thickness);
  323. return CommandResult::Continue;
  324. }
  325. CommandResult CommandExecutorCPU::fill_ellipse(FillEllipse const& command)
  326. {
  327. Gfx::AntiAliasingPainter aa_painter(painter());
  328. aa_painter.fill_ellipse(command.rect, command.color);
  329. return CommandResult::Continue;
  330. }
  331. CommandResult CommandExecutorCPU::draw_line(DrawLine const& command)
  332. {
  333. if (command.style == Gfx::LineStyle::Dotted) {
  334. Gfx::AntiAliasingPainter aa_painter(painter());
  335. aa_painter.draw_line(command.from, command.to, command.color, command.thickness, command.style, command.alternate_color);
  336. } else {
  337. painter().draw_line(command.from, command.to, command.color, command.thickness, command.style, command.alternate_color);
  338. }
  339. return CommandResult::Continue;
  340. }
  341. CommandResult CommandExecutorCPU::draw_signed_distance_field(DrawSignedDistanceField const& command)
  342. {
  343. painter().draw_signed_distance_field(command.rect, command.color, command.sdf, command.smoothing);
  344. return CommandResult::Continue;
  345. }
  346. CommandResult CommandExecutorCPU::apply_backdrop_filter(ApplyBackdropFilter const& command)
  347. {
  348. auto& painter = this->painter();
  349. // This performs the backdrop filter operation: https://drafts.fxtf.org/filter-effects-2/#backdrop-filter-operation
  350. // Note: The region bitmap can be smaller than the backdrop_region if it's at the edge of canvas.
  351. // Note: This is in DevicePixels, but we use an IntRect because `get_region_bitmap()` below writes to it.
  352. // FIXME: Go through the steps to find the "Backdrop Root Image"
  353. // https://drafts.fxtf.org/filter-effects-2/#BackdropRoot
  354. // 1. Copy the Backdrop Root Image into a temporary buffer, such as a raster image. Call this buffer T’.
  355. Gfx::IntRect actual_region {};
  356. auto maybe_backdrop_bitmap = painter.get_region_bitmap(command.backdrop_region, Gfx::BitmapFormat::BGRA8888, actual_region);
  357. if (actual_region.is_empty())
  358. return CommandResult::Continue;
  359. if (maybe_backdrop_bitmap.is_error()) {
  360. dbgln("Failed get region bitmap for backdrop-filter");
  361. return CommandResult::Continue;
  362. }
  363. auto backdrop_bitmap = maybe_backdrop_bitmap.release_value();
  364. // 2. Apply the backdrop-filter’s filter operations to the entire contents of T'.
  365. apply_filter_list(*backdrop_bitmap, command.backdrop_filter.filters);
  366. // FIXME: 3. If element B has any transforms (between B and the Backdrop Root), apply the inverse of those transforms to the contents of T’.
  367. // 4. Apply a clip to the contents of T’, using the border box of element B, including border-radius if specified. Note that the children of B are not considered for the sizing or location of this clip.
  368. // FIXME: 5. Draw all of element B, including its background, border, and any children elements, into T’.
  369. // FXIME: 6. If element B has any transforms, effects, or clips, apply those to T’.
  370. // 7. Composite the contents of T’ into element B’s parent, using source-over compositing.
  371. painter.blit(actual_region.location(), *backdrop_bitmap, backdrop_bitmap->rect());
  372. return CommandResult::Continue;
  373. }
  374. CommandResult CommandExecutorCPU::draw_rect(DrawRect const& command)
  375. {
  376. painter().draw_rect(command.rect, command.color, command.rough);
  377. return CommandResult::Continue;
  378. }
  379. CommandResult CommandExecutorCPU::paint_radial_gradient(PaintRadialGradient const& command)
  380. {
  381. auto paint_op = [&](Gfx::Painter& painter) {
  382. painter.fill_rect_with_radial_gradient(command.rect, command.radial_gradient_data.color_stops.list, command.center, command.size, command.radial_gradient_data.color_stops.repeat_length);
  383. };
  384. if (command.clip_paths.is_empty()) {
  385. paint_op(painter());
  386. } else {
  387. apply_clip_paths_to_painter(command.rect, paint_op, command.clip_paths, painter());
  388. }
  389. return CommandResult::Continue;
  390. }
  391. CommandResult CommandExecutorCPU::paint_conic_gradient(PaintConicGradient const& command)
  392. {
  393. auto paint_op = [&](Gfx::Painter& painter) {
  394. painter.fill_rect_with_conic_gradient(command.rect, command.conic_gradient_data.color_stops.list, command.position, command.conic_gradient_data.start_angle, command.conic_gradient_data.color_stops.repeat_length);
  395. };
  396. if (command.clip_paths.is_empty()) {
  397. paint_op(painter());
  398. } else {
  399. apply_clip_paths_to_painter(command.rect, paint_op, command.clip_paths, painter());
  400. }
  401. return CommandResult::Continue;
  402. }
  403. CommandResult CommandExecutorCPU::draw_triangle_wave(DrawTriangleWave const& command)
  404. {
  405. painter().draw_triangle_wave(command.p1, command.p2, command.color, command.amplitude, command.thickness);
  406. return CommandResult::Continue;
  407. }
  408. void CommandExecutorCPU::prepare_to_execute(size_t corner_clip_max_depth)
  409. {
  410. m_corner_clippers_stack.ensure_capacity(corner_clip_max_depth);
  411. }
  412. CommandResult CommandExecutorCPU::sample_under_corners(SampleUnderCorners const& command)
  413. {
  414. auto clipper = BorderRadiusCornerClipper::create(command.corner_radii, command.border_rect.to_type<DevicePixels>(), command.corner_clip).release_value();
  415. clipper->sample_under_corners(painter());
  416. m_corner_clippers_stack.append(clipper);
  417. return CommandResult::Continue;
  418. }
  419. CommandResult CommandExecutorCPU::blit_corner_clipping(BlitCornerClipping const&)
  420. {
  421. auto clipper = m_corner_clippers_stack.take_last();
  422. clipper->blit_corner_clipping(painter());
  423. return CommandResult::Continue;
  424. }
  425. bool CommandExecutorCPU::would_be_fully_clipped_by_painter(Gfx::IntRect rect) const
  426. {
  427. return !painter().clip_rect().intersects(rect.translated(painter().translation()));
  428. }
  429. }