Commit 9b174c64 authored by Michael Ludwig's avatar Michael Ludwig Committed by Commit Bot

Preserve scissor for RPDQs with filters

If the RPDQ has a filter, it's touched pixels are not actually restricted
to the visible rect of the quad. In that case it is incorrect to explicitly
clip the visible rect to the scissor and not set the scissor as a clipRect.
This CL makes it so the scissor is remembered and is applied post-filtering,
so effects like drop shadows are properly clipped to the window content.

Bug: 1035271
Change-Id: I138b1412c55489aa0068cc0ea1744a3248738716
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2019804Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Cr-Commit-Position: refs/heads/master@{#735025}
parent 0633289e
......@@ -99,29 +99,6 @@ bool IsTextureResource(DisplayResourceProvider* resource_provider,
return !resource_provider->IsResourceSoftwareBacked(resource_id);
}
bool CanExplicitlyScissor(const DrawQuad* quad,
const gfx::QuadF* draw_region,
const gfx::Transform& contents_device_transform) {
// PICTURE_CONTENT is not like the others, since it is executing a list of
// draw calls into the canvas.
if (quad->material == DrawQuad::Material::kPictureContent)
return false;
// Intersection with scissor and a quadrilateral is not necessarily a quad,
// so don't complicate things
if (draw_region)
return false;
// This is slightly different than
// gfx::Transform::IsPositiveScaleAndTranslation in that it also allows zero
// scales. This is because in the common orthographic case the z scale is 0.
if (!contents_device_transform.IsScaleOrTranslation())
return false;
return contents_device_transform.matrix().get(0, 0) >= 0.0 &&
contents_device_transform.matrix().get(1, 1) >= 0.0 &&
contents_device_transform.matrix().get(2, 2) >= 0.0;
}
void ApplyExplicitScissor(const DrawQuad* quad,
const gfx::Rect& scissor_rect,
const gfx::Transform& device_transform,
......@@ -1359,6 +1336,38 @@ SkiaRenderer::DrawQuadParams SkiaRenderer::CalculateDrawQuadParams(
return params;
}
bool SkiaRenderer::CanExplicitlyScissor(
const DrawQuad* quad,
const gfx::QuadF* draw_region,
const gfx::Transform& contents_device_transform) const {
// PICTURE_CONTENT is not like the others, since it is executing a list of
// draw calls into the canvas.
if (quad->material == DrawQuad::Material::kPictureContent)
return false;
// Intersection with scissor and a quadrilateral is not necessarily a quad,
// so don't complicate things
if (draw_region)
return false;
// This is slightly different than
// gfx::Transform::IsPositiveScaleAndTranslation in that it also allows zero
// scales. This is because in the common orthographic case the z scale is 0.
if (!contents_device_transform.IsScaleOrTranslation())
return false;
if (quad->material == DrawQuad::Material::kRenderPass) {
// If the renderpass has filters, the filters may modify the effective
// geometry beyond the quad's visible_rect, so it's not safe to pre-clip.
auto pass_id = RenderPassDrawQuad::MaterialCast(quad)->render_pass_id;
if (FiltersForPass(pass_id) || BackdropFiltersForPass(pass_id))
return false;
}
return contents_device_transform.matrix().get(0, 0) >= 0.0 &&
contents_device_transform.matrix().get(1, 1) >= 0.0 &&
contents_device_transform.matrix().get(2, 2) >= 0.0;
}
const DrawQuad* SkiaRenderer::CanPassBeDrawnDirectly(const RenderPass* pass) {
// TODO(michaelludwig) - For now, this only supports opaque, src-over quads
// with invertible transforms and simple content (image or color only).
......
......@@ -151,6 +151,12 @@ class VIZ_SERVICE_EXPORT SkiaRenderer : public DirectRenderer {
const SkImage* image,
const gfx::RectF& valid_texel_bounds,
DrawQuadParams* params) const;
// True or false if the DrawQuad can have the scissor rect applied by
// modifying the quad's visible_rect instead of as a separate clip operation.
bool CanExplicitlyScissor(
const DrawQuad* quad,
const gfx::QuadF* draw_region,
const gfx::Transform& contents_device_transform) const;
bool MustFlushBatchedQuads(const DrawQuad* new_quad,
const DrawRPDQParams* rpdq_params,
......
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