Commit 19dd3bcd authored by Mason Freed's avatar Mason Freed Committed by Commit Bot

Backdrop filter cleanup

This CL is just a cleanup. Renaming "BackgroundFilter" to
"BackdropFilter" in several places, removing unused arguments, etc.
I also made the backdrop-filter-clip-rect test a little more sensitive
to orientation - the four rounded corners are different.

No behavior should change with this CL.

Bug: 618913
Change-Id: Idf23358cc81ed93bb0c8e744133fcbe4e6d46f46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1542366
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarenne <enne@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646548}
parent 12e8fba8
......@@ -504,13 +504,13 @@ const cc::FilterOperations* DirectRenderer::FiltersForPass(
return it == render_pass_filters_.end() ? nullptr : it->second;
}
const cc::FilterOperations* DirectRenderer::BackgroundFiltersForPass(
const cc::FilterOperations* DirectRenderer::BackdropFiltersForPass(
RenderPassId render_pass_id) const {
auto it = render_pass_backdrop_filters_.find(render_pass_id);
return it == render_pass_backdrop_filters_.end() ? nullptr : it->second;
}
const gfx::RRectF* DirectRenderer::BackgroundFilterBoundsForPass(
const gfx::RRectF* DirectRenderer::BackdropFilterBoundsForPass(
RenderPassId render_pass_id) const {
auto it = render_pass_backdrop_filter_bounds_.find(render_pass_id);
return it == render_pass_backdrop_filter_bounds_.end() ? nullptr : it->second;
......
......@@ -157,9 +157,9 @@ class VIZ_SERVICE_EXPORT DirectRenderer {
bool use_render_pass_scissor);
const cc::FilterOperations* FiltersForPass(RenderPassId render_pass_id) const;
const cc::FilterOperations* BackgroundFiltersForPass(
const cc::FilterOperations* BackdropFiltersForPass(
RenderPassId render_pass_id) const;
const gfx::RRectF* BackgroundFilterBoundsForPass(
const gfx::RRectF* BackdropFilterBoundsForPass(
RenderPassId render_pass_id) const;
// Private interface implemented by subclasses for use by DirectRenderer.
......
......@@ -195,6 +195,14 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
void ApplyBlendModeUsingBlendFunc(SkBlendMode blend_mode);
void RestoreBlendFuncToDefault(SkBlendMode blend_mode);
// Returns the rect that should be sampled from the backdrop texture to be
// backdrop filtered. This rect lives in window pixel space. The |clip_region|
// input lives in the local quad rect pixel space. The
// |backdrop_filter_bounds_input| input lives in the local quad rect pixel
// space. The |backdrop_filter_bounds| output lives in the space of the output
// rect returned by this function. It will be used to clip the sampled
// backdrop texture. The |unclipped_rect| output is the unclipped (full) rect
// that the backdrop_filter should be applied to, in window pixel space.
gfx::Rect GetBackdropBoundingBoxForRenderPassQuad(
const RenderPassDrawQuad* quad,
const gfx::Transform& contents_device_transform,
......@@ -209,8 +217,7 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
// of the current RenderPass being drawn.
uint32_t GetBackdropTexture(const gfx::Rect& window_rect);
static bool ShouldApplyBackgroundFilters(
const RenderPassDrawQuad* quad,
static bool ShouldApplyBackdropFilters(
const cc::FilterOperations* backdrop_filters);
// Applies the backdrop filters to the backdrop that has been painted to this
// point, and returns it as an SkImage. Any opacity and/or "regular"
......@@ -220,12 +227,12 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
// stacking context, which would then be painted into its parent with opacity
// and filters applied. This is an approximation, but it should be close
// enough.
sk_sp<SkImage> ApplyBackgroundFilters(
sk_sp<SkImage> ApplyBackdropFilters(
const RenderPassDrawQuad* quad,
const cc::FilterOperations* backdrop_filters,
const cc::FilterOperations* regular_filters,
uint32_t background_texture,
const gfx::Rect& rect,
const gfx::Rect& background_rect,
const gfx::Rect& unclipped_rect,
const float backdrop_filter_quality,
const gfx::RRectF& backdrop_filter_bounds);
......
......@@ -1621,9 +1621,9 @@ void SkiaRenderer::DrawRenderPassQuadInternal(const RenderPassDrawQuad* quad,
}
const cc::FilterOperations* backdrop_filters =
BackgroundFiltersForPass(quad->render_pass_id);
BackdropFiltersForPass(quad->render_pass_id);
// Without backdrop effect.
if (!ShouldApplyBackgroundFilters(quad, backdrop_filters)) {
if (!ShouldApplyBackdropFilters(backdrop_filters)) {
if (mask_filter)
paint->setMaskFilter(mask_filter);
......@@ -1749,8 +1749,7 @@ void SkiaRenderer::GenerateMipmap() {
// RenderPassDrawQuad is what actually generates generate_mipmap.
}
bool SkiaRenderer::ShouldApplyBackgroundFilters(
const RenderPassDrawQuad* quad,
bool SkiaRenderer::ShouldApplyBackdropFilters(
const cc::FilterOperations* backdrop_filters) const {
if (!backdrop_filters)
return false;
......
......@@ -164,8 +164,7 @@ class VIZ_SERVICE_EXPORT SkiaRenderer : public DirectRenderer {
bool CalculateRPDQParams(sk_sp<SkImage> src_image,
const RenderPassDrawQuad* quad,
DrawRenderPassDrawQuadParams* params);
bool ShouldApplyBackgroundFilters(
const RenderPassDrawQuad* quad,
bool ShouldApplyBackdropFilters(
const cc::FilterOperations* backdrop_filters) const;
const TileDrawQuad* CanPassBeDrawnDirectly(const RenderPass* pass) override;
......
......@@ -520,12 +520,12 @@ void SoftwareRenderer::DrawRenderPassQuad(const RenderPassDrawQuad* quad) {
SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, &mask_mat)));
}
// If we have a background filter shader, render its results first.
sk_sp<SkShader> background_filter_shader =
GetBackgroundFilterShader(quad, SkShader::kClamp_TileMode);
if (background_filter_shader) {
// If we have a backdrop filter shader, render its results first.
sk_sp<SkShader> backdrop_filter_shader =
GetBackdropFilterShader(quad, SkShader::kClamp_TileMode);
if (backdrop_filter_shader) {
SkPaint paint;
paint.setShader(std::move(background_filter_shader));
paint.setShader(std::move(backdrop_filter_shader));
paint.setMaskFilter(current_paint_.refMaskFilter());
current_canvas_->drawRect(dest_visible_rect, paint);
}
......@@ -627,8 +627,7 @@ void SoftwareRenderer::GenerateMipmap() {
NOTIMPLEMENTED();
}
bool SoftwareRenderer::ShouldApplyBackgroundFilters(
const RenderPassDrawQuad* quad,
bool SoftwareRenderer::ShouldApplyBackdropFilters(
const cc::FilterOperations* backdrop_filters) const {
if (!backdrop_filters)
return false;
......@@ -697,7 +696,7 @@ gfx::Rect SoftwareRenderer::GetBackdropBoundingBoxForRenderPassQuad(
gfx::Rect* unclipped_rect) const {
// TODO(916318): This function needs to compute the backdrop
// filter clip rect and return it.
DCHECK(ShouldApplyBackgroundFilters(quad, backdrop_filters));
DCHECK(ShouldApplyBackdropFilters(backdrop_filters));
gfx::Rect backdrop_rect = gfx::ToEnclosingRect(cc::MathUtil::MapClippedRect(
contents_device_transform, QuadVertexRect()));
......@@ -712,15 +711,15 @@ gfx::Rect SoftwareRenderer::GetBackdropBoundingBoxForRenderPassQuad(
return backdrop_rect;
}
sk_sp<SkShader> SoftwareRenderer::GetBackgroundFilterShader(
sk_sp<SkShader> SoftwareRenderer::GetBackdropFilterShader(
const RenderPassDrawQuad* quad,
SkShader::TileMode content_tile_mode) const {
const cc::FilterOperations* backdrop_filters =
BackgroundFiltersForPass(quad->render_pass_id);
BackdropFiltersForPass(quad->render_pass_id);
if (!ShouldApplyBackdropFilters(backdrop_filters))
return nullptr;
const cc::FilterOperations* regular_filters =
FiltersForPass(quad->render_pass_id);
if (!ShouldApplyBackgroundFilters(quad, backdrop_filters))
return nullptr;
gfx::Transform quad_rect_matrix;
QuadRectTransform(&quad_rect_matrix,
......
......@@ -78,8 +78,7 @@ class VIZ_SERVICE_EXPORT SoftwareRenderer : public DirectRenderer {
void DrawTextureQuad(const TextureDrawQuad* quad);
void DrawTileQuad(const TileDrawQuad* quad);
void DrawUnsupportedQuad(const DrawQuad* quad);
bool ShouldApplyBackgroundFilters(
const RenderPassDrawQuad* quad,
bool ShouldApplyBackdropFilters(
const cc::FilterOperations* backdrop_filters) const;
sk_sp<SkImage> ApplyImageFilter(SkImageFilter* filter,
const RenderPassDrawQuad* quad,
......@@ -91,7 +90,7 @@ class VIZ_SERVICE_EXPORT SoftwareRenderer : public DirectRenderer {
const cc::FilterOperations* backdrop_filters,
gfx::Rect* unclipped_rect) const;
SkBitmap GetBackdropBitmap(const gfx::Rect& bounding_rect) const;
sk_sp<SkShader> GetBackgroundFilterShader(
sk_sp<SkShader> GetBackdropFilterShader(
const RenderPassDrawQuad* quad,
SkShader::TileMode content_tile_mode) const;
......
......@@ -7,8 +7,9 @@
<div>
<p>Expected: A green box, color-inverted inside the short, wide box with a<br>
blue border, and not color-inverted anywhere else. In particular, there should be<br>
no color inversion inside the tall, narrow box, or anywhere outside that.</p>
blue border and rounded corners, and not color-inverted anywhere else. In<br>
particular, there should be no color inversion inside the tall, narrow box,<br>
or anywhere outside that.</p>
</div>
<div class="box"></div>
<div class="navbar"></div>
......@@ -31,21 +32,22 @@ div {
height: 50px;
top: 150px;
left: 50px;
border: 1px solid blue;
border: 2px solid blue;
backdrop-filter: invert(1);
border-radius: 10px 20px 30px 40px;
}
.menu {
width: 100px;
height: 150px;
top: 201px;
left: 146px;
border: 1px solid blue;
top: 202px;
left: 147px;
border: 2px solid red;
}
.menu2 {
width: 100px;
height: 30px;
top: 119px;
left: 146px;
border: 1px solid blue;
top: 118px;
left: 147px;
border: 2px solid red;
}
</style>
......@@ -7,8 +7,9 @@
<div>
<p>Expected: A green box, color-inverted inside the short, wide box with a<br>
blue border, and not color-inverted anywhere else. In particular, there should be<br>
no color inversion inside the tall, narrow box, or anywhere outside that.</p>
blue border and rounded corners, and not color-inverted anywhere else. In<br>
particular, there should be no color inversion inside the tall, narrow box,<br>
or anywhere outside that.</p>
</div>
<div class="box"></div>
<div class="navbar">
......@@ -31,21 +32,22 @@ div {
height: 50px;
top: 150px;
left: 50px;
border: 1px solid blue;
border: 2px solid blue;
backdrop-filter: invert(1);
border-radius: 10px 20px 30px 40px;
}
.menu {
width: 100px;
height: 150px;
top: 50px;
left: 95px;
border: 1px solid blue;
border: 2px solid red;
}
.menu2 {
width: 100px;
height: 30px;
top: -32px;
top: -34px;
left: 95px;
border: 1px solid blue;
border: 2px solid red;
}
</style>
......@@ -7,8 +7,9 @@
<div>
<p>Expected: A green box, color-inverted inside the short, wide box with a<br>
blue border, and not color-inverted anywhere else. In particular, there should be<br>
no color inversion inside the tall, narrow box, or anywhere outside that.</p>
blue border and rounded corners, and not color-inverted anywhere else. In<br>
particular, there should be no color inversion inside the tall, narrow box,<br>
or anywhere outside that.</p>
</div>
<div class="box"></div>
<div class="navbar">
......@@ -43,21 +44,22 @@ div {
height: 50px;
top: 150px;
left: 50px;
border: 1px solid blue;
border: 2px solid blue;
backdrop-filter: url(#svgInvert);
border-radius: 10px 20px 30px 40px;
}
.menu {
width: 100px;
height: 150px;
top: 50px;
left: 95px;
border: 1px solid blue;
border: 2px solid red;
}
.menu2 {
width: 100px;
height: 30px;
top: -32px;
top: -34px;
left: 95px;
border: 1px solid blue;
border: 2px solid red;
}
</style>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment