blob: 59434b01fae3036237131b99b6245440b99b8797 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/output/overlay_processor.h"
#include "cc/output/output_surface.h"
#include "cc/output/overlay_strategy_single_on_top.h"
#include "cc/output/overlay_strategy_underlay.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/transform.h"
namespace cc {
namespace {
bool SortByZOrder(const OverlayCandidate& a, const OverlayCandidate& b) {
return (a.plane_z_order < b.plane_z_order);
}
} // namespace
OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) {
}
void OverlayProcessor::Initialize() {
DCHECK(surface_);
OverlayCandidateValidator* validator =
surface_->GetOverlayCandidateValidator();
if (validator)
validator->GetStrategies(&strategies_);
}
OverlayProcessor::~OverlayProcessor() {}
void OverlayProcessor::ProcessForOverlays(ResourceProvider* resource_provider,
RenderPassList* render_passes,
OverlayCandidateList* candidates,
gfx::Rect* damage_rect) {
for (auto strategy : strategies_) {
if (strategy->Attempt(resource_provider, render_passes, candidates)) {
std::sort(candidates->begin(), candidates->end(), SortByZOrder);
for (const OverlayCandidate& overlay : *candidates) {
if (overlay.plane_z_order <= 0 || overlay.needs_blending)
continue;
damage_rect->Subtract(ToEnclosedRect(overlay.display_rect));
}
return;
}
}
}
} // namespace cc
|