Clear webapp storage when site data is cleared
[chromium-blink-merge.git] / cc / output / overlay_strategy_single_on_top.cc
blob6b63045c0154c0218baa9bd5704ff52d4db0ddca
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/output/overlay_strategy_single_on_top.h"
7 #include <limits>
9 #include "cc/base/math_util.h"
10 #include "cc/output/overlay_candidate_validator.h"
11 #include "cc/quads/draw_quad.h"
13 namespace cc {
15 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {}
17 OverlayResult OverlayStrategySingleOnTop::TryOverlay(
18 OverlayCandidateValidator* capability_checker,
19 RenderPassList* render_passes_in_draw_order,
20 OverlayCandidateList* candidate_list,
21 const OverlayCandidate& candidate,
22 QuadList::Iterator* candidate_iterator,
23 float device_scale_factor) {
24 RenderPass* root_render_pass = render_passes_in_draw_order->back();
25 QuadList& quad_list = root_render_pass->quad_list;
26 // Check that no prior quads overlap it.
27 for (auto overlap_iter = quad_list.cbegin();
28 overlap_iter != *candidate_iterator; ++overlap_iter) {
29 gfx::RectF overlap_rect = MathUtil::MapClippedRect(
30 overlap_iter->shared_quad_state->quad_to_target_transform,
31 gfx::RectF(overlap_iter->rect));
32 if (candidate.display_rect.Intersects(overlap_rect) &&
33 !OverlayStrategyCommon::IsInvisibleQuad(*overlap_iter))
34 return DID_NOT_CREATE_OVERLAY;
37 // Add the overlay.
38 OverlayCandidateList new_candidate_list = *candidate_list;
39 new_candidate_list.push_back(candidate);
40 new_candidate_list.back().plane_z_order = 1;
42 // Check for support.
43 capability_checker->CheckOverlaySupport(&new_candidate_list);
45 // If the candidate can be handled by an overlay, create a pass for it.
46 if (new_candidate_list.back().overlay_handled) {
47 quad_list.EraseAndInvalidateAllPointers(*candidate_iterator);
48 candidate_list->swap(new_candidate_list);
49 return CREATED_OVERLAY_STOP_LOOKING;
52 return DID_NOT_CREATE_OVERLAY;
55 } // namespace cc