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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/viz/service/display/overlay_processor_mac.h"
#include <utility>
#include <vector>
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/viz/common/quads/solid_color_draw_quad.h"
#include "components/viz/service/display/display_resource_provider.h"
#include "components/viz/service/display/output_surface.h"
#include "ui/gfx/geometry/rect_conversions.h"
namespace viz {
OverlayProcessorMac::OverlayProcessorMac()
: ca_layer_overlay_processor_(std::make_unique<CALayerOverlayProcessor>()) {
}
OverlayProcessorMac::OverlayProcessorMac(
std::unique_ptr<CALayerOverlayProcessor> ca_layer_overlay_processor)
: ca_layer_overlay_processor_(std::move(ca_layer_overlay_processor)) {}
OverlayProcessorMac::~OverlayProcessorMac() = default;
bool OverlayProcessorMac::DisableSplittingQuads() const {
return true;
}
bool OverlayProcessorMac::IsOverlaySupported() const {
return true;
}
gfx::Rect OverlayProcessorMac::GetAndResetOverlayDamage() {
gfx::Rect result = ca_overlay_damage_rect_;
ca_overlay_damage_rect_ = gfx::Rect();
return result;
}
void OverlayProcessorMac::ProcessForOverlays(
DisplayResourceProvider* resource_provider,
AggregatedRenderPassList* render_passes,
const SkM44& output_color_matrix,
const OverlayProcessorInterface::FilterOperationsMap& render_pass_filters,
const OverlayProcessorInterface::FilterOperationsMap&
render_pass_backdrop_filters,
SurfaceDamageRectList surface_damage_rect_list,
OutputSurfaceOverlayPlane* output_surface_plane,
CandidateList* candidates,
gfx::Rect* damage_rect,
std::vector<gfx::Rect>* content_bounds) {
TRACE_EVENT0("viz", "OverlayProcessorMac::ProcessForOverlays");
auto* render_pass = render_passes->back().get();
// Clear to get ready to handle output surface as overlay.
output_surface_already_handled_ = false;
// We could have surfaceless overlay but not ca overlay system on. In this
// case we would still have the OutputSurfaceOverlayPlane.
// First, try to use ProcessForCALayerOverlays to replace all DrawQuads in
// |render_pass->quad_list| with CALayerOverlays in |candidates|.
bool success = ca_layer_overlay_processor_->ProcessForCALayerOverlays(
render_pass, resource_provider, gfx::RectF(render_pass->output_rect),
render_pass_filters, render_pass_backdrop_filters, candidates);
if (success) {
// Mark the output surface as already handled (there is no output surface
// anymore).
output_surface_already_handled_ = true;
// Set |ca_overlay_damage_rect_| to be everything, so that the next
// composite that we draw to the output surface will do a full re-draw.
ca_overlay_damage_rect_ = render_pass->output_rect;
// Everything in |render_pass->quad_list| has been moved over to
// |candidates|. Ideally we would clear |render_pass->quad_list|, but some
// RenderPass overlays still point into that list. So instead, to avoid
// drawing the root RenderPass, we set |damage_rect| to be empty.
*damage_rect = gfx::Rect();
} else {
ca_layer_overlay_processor_->PutForcedOverlayContentIntoUnderlays(
resource_provider, render_pass, gfx::RectF(render_pass->output_rect),
&render_pass->quad_list, render_pass_filters,
render_pass_backdrop_filters, candidates);
}
}
void OverlayProcessorMac::AdjustOutputSurfaceOverlay(
std::optional<OutputSurfaceOverlayPlane>* output_surface_plane) {
if (!output_surface_plane->has_value())
return;
if (output_surface_already_handled_)
output_surface_plane->reset();
}
bool OverlayProcessorMac::NeedsSurfaceDamageRectList() const {
return false;
}
gfx::CALayerResult OverlayProcessorMac::GetCALayerErrorCode() const {
return ca_layer_overlay_processor_->ca_layer_result();
}
} // namespace viz
|