Commit 43a763e6 authored by Daniele Castagna's avatar Daniele Castagna Committed by Commit Bot

viz: Pass device_scale_factor as a float to CanSplitQuad

|device_scale_factor_| is a float and was incorrectly passed as an int
to CanSplitQuad.
This would cause rounding down the device scale factor and incorrectly
computing the number of fragments we are saving.

Bug: 1022544
Test: viz_unittests --gtest_filter="*DrawOcclusionSplitDeviceScaleFactor*"

Change-Id: I084cb9ce52116b0d37e18ff74dd06233978cb9a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2072625
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarAndres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: default avatarGil Dekel <gildekel@chromium.org>
Reviewed-by: default avatarSasha McIntosh <sashamcintosh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745520}
parent ed553abf
......@@ -170,7 +170,7 @@ bool CanSplitQuad(const DrawQuad::Material m,
const cc::Region& visible_region,
const int quad_split_limit,
const int minimum_fragments_reduced,
const int device_scale_factor,
const float device_scale_factor,
const bool enable_quad_splitting) {
return enable_quad_splitting && !base::Contains(kNonSplittableMaterials, m) &&
visible_region.GetRegionComplexity() < quad_split_limit &&
......
......@@ -12,7 +12,6 @@
#include "base/test/metrics/histogram_tester.h"
#include "base/test/null_task_runner.h"
#include "cc/base/math_util.h"
#include "cc/base/region.h"
#include "cc/test/scheduler_test_common.h"
#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
......@@ -4210,6 +4209,61 @@ TEST_F(DisplayTest, DrawOcclusionSplit) {
TearDownDisplay();
}
// Test that the threshold we use to determine if it's worth splitting a quad or
// not takes into account the device scale factor. In particular, this test
// would not pass if we had a display scale factor equal to 1.f instead of 1.5f
// since the number of saved fragments would only be 100x100 which is lower than
// our threshold 128x128.
TEST_F(DisplayTest, DrawOcclusionSplitDeviceScaleFactorFractional) {
SetUpGpuDisplay(RendererSettings());
StubDisplayClient client;
display_->Initialize(&client, manager_.surface_manager());
display_->SetLocalSurfaceId(
id_allocator_.GetCurrentLocalSurfaceIdAllocation().local_surface_id(),
1.5f);
display_->Resize(gfx::Size(1000, 1000));
CompositorFrame frame = MakeDefaultCompositorFrame();
const bool is_clipped = false;
const bool are_contents_opaque = true;
const float opacity = 1.f;
// Occluder quad.
const gfx::Rect occluding_rect(10, 10, 100, 100);
SharedQuadState* shared_quad_state_occluding =
frame.render_pass_list.front()->CreateAndAppendSharedQuadState();
SolidColorDrawQuad* occluding_quad =
frame.render_pass_list.front()
->quad_list.AllocateAndConstruct<SolidColorDrawQuad>();
shared_quad_state_occluding->SetAll(
gfx::Transform(), occluding_rect, occluding_rect, gfx::RRectF(),
occluding_rect, is_clipped, are_contents_opaque, opacity,
SkBlendMode::kSrcOver, 0);
occluding_quad->SetNew(shared_quad_state_occluding, occluding_rect,
occluding_rect, SK_ColorRED, false);
// Occluded quad.
const gfx::Rect occluded_rect = gfx::Rect(0, 0, 1000, 1000);
SharedQuadState* shared_quad_state_occluded =
frame.render_pass_list.front()->CreateAndAppendSharedQuadState();
SolidColorDrawQuad* occluded_quad =
frame.render_pass_list.front()
->quad_list.AllocateAndConstruct<SolidColorDrawQuad>();
shared_quad_state_occluded->SetAll(
gfx::Transform(), occluded_rect, occluded_rect, gfx::RRectF(),
occluded_rect, is_clipped, are_contents_opaque, opacity,
SkBlendMode::kSrcOver, 0);
occluded_quad->SetNew(shared_quad_state_occluded, occluded_rect,
occluded_rect, SK_ColorRED, false);
EXPECT_EQ(2u, frame.render_pass_list.front()->quad_list.size());
display_->RemoveOverdrawQuads(&frame);
EXPECT_EQ(5u, frame.render_pass_list.front()->quad_list.size());
TearDownDisplay();
}
TEST_F(DisplayTest, DrawOcclusionWithRoundedCornerPartialOcclude) {
SetUpGpuDisplay(RendererSettings());
......
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