Commit a8fd74b8 authored by Maggie Chen's avatar Maggie Chen Committed by Commit Bot

Use the render_pass_filters map directly in DCLayerOverlayProcessor

Pass the foreground and backdrop filters
flat_map<RenderPassId, cc::FilterOperations*> to Process() function and
use it directly. No need to build the filter operation map again.

Bug: 1064390
Change-Id: I1e688324aed0d7f75b27ad361f40c7fbdfb2ce49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2489480
Commit-Queue: Maggie Chen <magchen@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819497}
parent 35197dba
......@@ -36,8 +36,6 @@ namespace {
constexpr int kDCLayerDebugBorderWidth = 4;
constexpr gfx::Insets kDCLayerDebugBorderInsets = gfx::Insets(-2);
using RenderPassListWithFilters = base::flat_map<AggregatedRenderPassId, float>;
// This is used for a histogram to determine why overlays are or aren't used,
// so don't remove entries and make sure to update enums.xml if it changes.
enum DCLayerResult {
......@@ -255,7 +253,7 @@ bool HasOccludingQuads(
const gfx::RectF& target_quad,
QuadList::ConstIterator quad_list_begin,
QuadList::ConstIterator quad_list_end,
RenderPassListWithFilters& render_pass_has_pixel_moving_filters) {
const DCLayerOverlayProcessor::FilterOperationsMap& render_pass_filters) {
for (auto overlap_iter = quad_list_begin; overlap_iter != quad_list_end;
++overlap_iter) {
float opacity = overlap_iter->shared_quad_state->opacity;
......@@ -267,13 +265,13 @@ bool HasOccludingQuads(
// Expand the overlap_rect for the render pass draw quad with pixel moving
// foreground filters.
bool has_pixel_moving_filter = false;
if (!render_pass_has_pixel_moving_filters.empty() &&
if (!render_pass_filters.empty() &&
quad->material == DrawQuad::Material::kAggregatedRenderPass) {
const auto* rpdq = AggregatedRenderPassDrawQuad::MaterialCast(quad);
auto render_pass_it =
render_pass_has_pixel_moving_filters.find(rpdq->render_pass_id);
if (render_pass_it != render_pass_has_pixel_moving_filters.end()) {
float max_pixel_movement = render_pass_it->second;
auto render_pass_it = render_pass_filters.find(rpdq->render_pass_id);
if (render_pass_it != render_pass_filters.end()) {
auto* filters = render_pass_it->second;
float max_pixel_movement = filters->MaximumPixelMovement();
overlap_rect =
GetExpandedRectWithPixelMovingFilter(rpdq, max_pixel_movement);
has_pixel_moving_filter = true;
......@@ -581,6 +579,8 @@ bool DCLayerOverlayProcessor::IsPreviousFrameUnderlayRect(
void DCLayerOverlayProcessor::Process(
DisplayResourceProvider* resource_provider,
const gfx::RectF& display_rect,
const FilterOperationsMap& render_pass_filters,
const FilterOperationsMap& render_pass_backdrop_filters,
AggregatedRenderPassList* render_pass_list,
gfx::Rect* damage_rect,
SurfaceDamageRectList* surface_damage_rect_list,
......@@ -590,21 +590,6 @@ void DCLayerOverlayProcessor::Process(
processed_yuv_overlay_count_ = 0;
surface_damage_rect_list_ = surface_damage_rect_list;
// Which render passes have backdrop filters or pixel moving foreground
// filters.
base::flat_set<AggregatedRenderPassId> render_pass_has_backdrop_filters;
RenderPassListWithFilters render_pass_has_pixel_moving_filters;
for (const auto& render_pass : *render_pass_list) {
if (!render_pass->backdrop_filters.IsEmpty())
render_pass_has_backdrop_filters.insert(render_pass->id);
if (render_pass->filters.HasFilterThatMovesPixels()) {
render_pass_has_pixel_moving_filters.insert(
{render_pass->id, render_pass->filters.MaximumPixelMovement()});
}
}
// Output rects of child render passes that have backdrop filters in target
// space. These rects are used to determine if the overlay rect could be read
// by backdrop filters.
......@@ -632,7 +617,9 @@ void DCLayerOverlayProcessor::Process(
for (auto it = quad_list->begin(); it != quad_list->end(); ++it, ++index) {
if (it->material == DrawQuad::Material::kAggregatedRenderPass) {
const auto* rpdq = AggregatedRenderPassDrawQuad::MaterialCast(*it);
if (render_pass_has_backdrop_filters.count(rpdq->render_pass_id)) {
auto render_pass_it =
render_pass_backdrop_filters.find(rpdq->render_pass_id);
if (render_pass_it != render_pass_backdrop_filters.end()) {
backdrop_filter_rects.push_back(
gfx::ToEnclosingRect(ClippedQuadRectangle(rpdq)));
}
......@@ -704,9 +691,9 @@ void DCLayerOverlayProcessor::Process(
gfx::ToEnclosingRect(ClippedQuadRectangle(*it));
// Quad is considered an "overlay" if it has no occluders.
bool is_overlay = !HasOccludingQuads(
gfx::RectF(quad_rectangle_in_target_space), quad_list->begin(), it,
render_pass_has_pixel_moving_filters);
bool is_overlay =
!HasOccludingQuads(gfx::RectF(quad_rectangle_in_target_space),
quad_list->begin(), it, render_pass_filters);
// Protected video is always put in an overlay, but texture quads can be
// skipped if they're not underlay compatible.
......
......@@ -78,6 +78,8 @@ typedef std::vector<DCLayerOverlay> DCLayerOverlayList;
class VIZ_SERVICE_EXPORT DCLayerOverlayProcessor
: public ui::GpuSwitchingObserver {
public:
using FilterOperationsMap =
base::flat_map<AggregatedRenderPassId, cc::FilterOperations*>;
// When |skip_initialization_for_testing| is true, object will be isolated
// for unit tests.
// allowed_yuv_overlay_count will be limited to 1 if
......@@ -94,6 +96,8 @@ class VIZ_SERVICE_EXPORT DCLayerOverlayProcessor
// Virtual for testing.
virtual void Process(DisplayResourceProvider* resource_provider,
const gfx::RectF& display_rect,
const FilterOperationsMap& render_pass_filters,
const FilterOperationsMap& render_pass_backdrop_filters,
AggregatedRenderPassList* render_passes,
gfx::Rect* damage_rect,
SurfaceDamageRectList* surface_damage_rect_list,
......
......@@ -2529,9 +2529,11 @@ class MockDCLayerOverlayProcessor : public DCLayerOverlayProcessor {
/*allowed_yuv_overlay_count=*/1,
true) {}
~MockDCLayerOverlayProcessor() override = default;
MOCK_METHOD6(Process,
MOCK_METHOD8(Process,
void(DisplayResourceProvider* resource_provider,
const gfx::RectF& display_rect,
const FilterOperationsMap& render_pass_filters,
const FilterOperationsMap& render_pass_backdrop_filters,
AggregatedRenderPassList* render_passes,
gfx::Rect* damage_rect,
SurfaceDamageRectList* surface_damage_rect_list,
......@@ -2738,7 +2740,7 @@ TEST_F(GLRendererTest, DontOverlayWithCopyRequests) {
EXPECT_CALL(*mock_ca_processor, ProcessForCALayerOverlays(_, _, _, _, _, _))
.Times(0);
#elif defined(OS_WIN)
EXPECT_CALL(*dc_processor, Process(_, _, _, _, _, _)).Times(0);
EXPECT_CALL(*dc_processor, Process(_, _, _, _, _, _, _, _)).Times(0);
#endif
DrawFrame(&renderer, viewport_size);
#if defined(USE_OZONE) || defined(OS_ANDROID)
......@@ -2770,7 +2772,7 @@ TEST_F(GLRendererTest, DontOverlayWithCopyRequests) {
EXPECT_CALL(*mock_ca_processor, ProcessForCALayerOverlays(_, _, _, _, _, _))
.Times(1);
#elif defined(OS_WIN)
EXPECT_CALL(*dc_processor, Process(_, _, _, _, _, _)).Times(1);
EXPECT_CALL(*dc_processor, Process(_, _, _, _, _, _, _, _)).Times(1);
#endif
DrawFrame(&renderer, viewport_size);
......
......@@ -88,7 +88,8 @@ void OverlayProcessorWin::ProcessForOverlays(
dc_layer_overlay_processor_->Process(
resource_provider, gfx::RectF(root_render_pass->output_rect),
render_passes, damage_rect, surface_damage_rect_list, candidates);
render_pass_filters, render_pass_backdrop_filters, render_passes,
damage_rect, surface_damage_rect_list, candidates);
bool was_using_dc_layers = using_dc_layers_;
if (!candidates->empty()) {
......
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