| Index: cc/output/overlay_strategy_cast_underlay.cc
|
| diff --git a/cc/output/overlay_strategy_cast_underlay.cc b/cc/output/overlay_strategy_cast_underlay.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c42511a11e258448c4b600b07138b5e299aab861
|
| --- /dev/null
|
| +++ b/cc/output/overlay_strategy_cast_underlay.cc
|
| @@ -0,0 +1,72 @@
|
| +// Copyright 2016 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_strategy_cast_underlay.h"
|
| +
|
| +#include "base/containers/adapters.h"
|
| +#include "cc/quads/draw_quad.h"
|
| +#include "cc/quads/solid_color_draw_quad.h"
|
| +#include "ui/gfx/geometry/rect_conversions.h"
|
| +
|
| +namespace cc {
|
| +
|
| +OverlayStrategyCastUnderlay::OverlayStrategyCastUnderlay(
|
| + OverlayCandidateValidator* capability_checker)
|
| + : OverlayStrategyUnderlay(capability_checker),
|
| + have_swap_with_damage_rect_(false) {}
|
| +
|
| +OverlayStrategyCastUnderlay::~OverlayStrategyCastUnderlay() {}
|
| +
|
| +bool OverlayStrategyCastUnderlay::GetSwapWithDamageRect(gfx::Rect* rect) {
|
| + DCHECK(rect);
|
| + *rect = swap_with_damage_rect_;
|
| + return have_swap_with_damage_rect_;
|
| +}
|
| +
|
| +bool OverlayStrategyCastUnderlay::Attempt(
|
| + ResourceProvider* resource_provider,
|
| + RenderPass* render_pass,
|
| + OverlayCandidateList* candidate_list) {
|
| + const QuadList& const_quad_list = render_pass->quad_list;
|
| + bool found_underlay = false;
|
| + gfx::Rect damage;
|
| + for (const auto* quad : base::Reversed(const_quad_list)) {
|
| + if (OverlayCandidate::IsInvisibleQuad(quad))
|
| + continue;
|
| +
|
| + const auto& transform = quad->shared_quad_state->quad_to_target_transform;
|
| + gfx::RectF quad_rect = gfx::RectF(quad->rect);
|
| + transform.TransformRect(&quad_rect);
|
| +
|
| + bool is_underlay = false;
|
| + if (!found_underlay) {
|
| + OverlayCandidate candidate;
|
| + is_underlay =
|
| + OverlayCandidate::FromDrawQuad(resource_provider, quad, &candidate);
|
| + found_underlay |= is_underlay;
|
| + }
|
| +
|
| + if (!found_underlay && quad->material == DrawQuad::SOLID_COLOR) {
|
| + const SolidColorDrawQuad* solid = SolidColorDrawQuad::MaterialCast(quad);
|
| + if (solid->color == SK_ColorBLACK)
|
| + continue;
|
| + }
|
| +
|
| + if (is_underlay) {
|
| + damage.Subtract(ToEnclosedRect(quad_rect));
|
| + } else {
|
| + damage.Union(ToEnclosingRect(quad_rect));
|
| + }
|
| + }
|
| +
|
| + have_swap_with_damage_rect_ = found_underlay;
|
| + if (found_underlay) {
|
| + swap_with_damage_rect_ = damage;
|
| + }
|
| +
|
| + return OverlayStrategyUnderlay::Attempt(resource_provider, render_pass,
|
| + candidate_list);
|
| +}
|
| +
|
| +} // namespace cc
|
|
|