Index: cc/output/overlay_strategy_underlay_cast.cc |
diff --git a/cc/output/overlay_strategy_underlay_cast.cc b/cc/output/overlay_strategy_underlay_cast.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..614df2ec038474d3eaa0fa4588b934766ce47a92 |
--- /dev/null |
+++ b/cc/output/overlay_strategy_underlay_cast.cc |
@@ -0,0 +1,67 @@ |
+// Copyright 2017 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_underlay_cast.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 { |
+ |
+OverlayStrategyUnderlayCast::OverlayStrategyUnderlayCast( |
+ OverlayCandidateValidator* capability_checker) |
+ : OverlayStrategyUnderlay(capability_checker) {} |
+ |
+OverlayStrategyUnderlayCast::~OverlayStrategyUnderlayCast() {} |
+ |
+bool OverlayStrategyUnderlayCast::Attempt( |
+ ResourceProvider* resource_provider, |
+ RenderPass* render_pass, |
+ OverlayCandidateList* candidate_list, |
+ std::vector<gfx::Rect>* content_bounds) { |
+ const QuadList& const_quad_list = render_pass->quad_list; |
+ bool found_underlay = false; |
+ gfx::Rect content_rect; |
+ 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); |
danakj
2017/02/16 18:54:19
How robust is it that you're redoing a subset of t
halliwell
2017/02/23 18:01:46
Strictly speaking, it is ok (we always return true
danakj
2017/02/24 22:05:18
If you reproduce the tests for it then that seems
halliwell
2017/02/27 22:57:13
Yep, good point. I added a basic DCHECK that the
|
+ found_underlay |= is_underlay; |
danakj
2017/02/16 18:54:19
you can just use = here if you want. you know foun
halliwell
2017/02/23 18:01:46
Done.
|
+ } |
+ |
+ if (!found_underlay && quad->material == DrawQuad::SOLID_COLOR) { |
+ const SolidColorDrawQuad* solid = SolidColorDrawQuad::MaterialCast(quad); |
+ if (solid->color == SK_ColorBLACK) |
+ continue; |
+ } |
+ |
+ if (is_underlay) { |
+ content_rect.Subtract(ToEnclosedRect(quad_rect)); |
danakj
2017/02/16 18:54:19
Do you have a test verifying the use of Enclosed/E
halliwell
2017/02/23 18:01:46
Test added.
|
+ } else { |
+ content_rect.Union(ToEnclosingRect(quad_rect)); |
+ } |
+ } |
+ |
+ const bool result = OverlayStrategyUnderlay::Attempt( |
+ resource_provider, render_pass, candidate_list, content_bounds); |
+ DCHECK(content_bounds); |
+ content_bounds->clear(); |
danakj
2017/02/16 18:54:19
I suggest DCHECK its empty instead, if you want. I
halliwell
2017/02/23 18:01:46
Done.
|
+ if (found_underlay) { |
+ content_bounds->push_back(content_rect); |
+ } |
+ return result; |
+} |
+ |
+} // namespace cc |