Skip to content

Commit

Permalink
Optional mask filter in shared quad state mojo
Browse files Browse the repository at this point in the history
The |MaskFilterInfo| member is rarely used and is moderately large
given that it contains a |RRect| object. Avoid serialization in mojo
empty. This only saves a few 10s of us per frame but there may be
other optimizations to follow.

Bug: 1396122
Change-Id: Ia86c50d48bab35860be66d8d5678514218293fd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4347778
Commit-Queue: Peter McNeeley <petermcneeley@chromium.org>
Reviewed-by: Joe Mason <joenotcharles@google.com>
Cr-Commit-Position: refs/heads/main@{#1119761}
  • Loading branch information
petermcneeleychromium authored and Chromium LUCI CQ committed Mar 21, 2023
1 parent 69304a2 commit d9d91ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "components/viz/common/quads/shared_quad_state.h"
#include "services/viz/public/mojom/compositing/shared_quad_state.mojom-shared.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/geometry/mask_filter_info.h"
#include "ui/gfx/mojom/mask_filter_info_mojom_traits.h"
#include "ui/gfx/mojom/rrect_f_mojom_traits.h"

Expand Down Expand Up @@ -38,9 +39,12 @@ struct StructTraits<viz::mojom::SharedQuadStateDataView, OptSharedQuadState> {
return input.sqs->visible_quad_layer_rect;
}

static const gfx::MaskFilterInfo& mask_filter_info(
static const absl::optional<gfx::MaskFilterInfo> mask_filter_info(
const OptSharedQuadState& input) {
return input.sqs->mask_filter_info;
return input.sqs->mask_filter_info.IsEmpty()
? absl::nullopt
: absl::optional<gfx::MaskFilterInfo>(
input.sqs->mask_filter_info);
}

static const absl::optional<gfx::Rect>& clip_rect(
Expand Down Expand Up @@ -118,11 +122,17 @@ struct StructTraits<viz::mojom::SharedQuadStateDataView, viz::SharedQuadState> {
if (!data.ReadQuadToTargetTransform(&out->quad_to_target_transform) ||
!data.ReadQuadLayerRect(&out->quad_layer_rect) ||
!data.ReadVisibleQuadLayerRect(&out->visible_quad_layer_rect) ||
!data.ReadMaskFilterInfo(&out->mask_filter_info) ||
!data.ReadClipRect(&out->clip_rect)) {
return false;
}

absl::optional<gfx::MaskFilterInfo> mask_filter;
if (!data.ReadMaskFilterInfo(&mask_filter)) {
return false;
}

out->mask_filter_info = mask_filter.value_or(gfx::MaskFilterInfo());

out->are_contents_opaque = data.are_contents_opaque();
out->opacity = data.opacity();
if (data.blend_mode() > static_cast<int>(SkBlendMode::kLastMode))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct SharedQuadState {
// This rect lives in the target content space. It defines the mask filter
// info applied to the quad, and also defines rounded corner rects to clip the
// quads with.
gfx.mojom.MaskFilterInfo mask_filter_info;
gfx.mojom.MaskFilterInfo? mask_filter_info;

// This rect lives in the target content space.
gfx.mojom.Rect? clip_rect;
Expand Down

0 comments on commit d9d91ab

Please sign in to comment.