Index: cc/output/overlay_strategy_underlay.cc |
diff --git a/cc/output/overlay_strategy_underlay.cc b/cc/output/overlay_strategy_underlay.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c3242c20ca5df6d0a52b514db28d7e3578bcb351 |
--- /dev/null |
+++ b/cc/output/overlay_strategy_underlay.cc |
@@ -0,0 +1,86 @@ |
+// 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_strategy_underlay.h" |
+ |
+#include "cc/quads/draw_quad.h" |
+#include "cc/quads/solid_color_draw_quad.h" |
+#include "cc/quads/stream_video_draw_quad.h" |
+#include "ui/gfx/geometry/rect_conversions.h" |
+#include "ui/gfx/transform.h" |
+ |
+namespace cc { |
+ |
+OverlayStrategyUnderlay::OverlayStrategyUnderlay( |
+ OverlayCandidateValidator* capability_checker, |
+ ResourceProvider* resource_provider) |
+ : OverlayStrategyCommon(resource_provider), |
+ capability_checker_(capability_checker) { |
+} |
+ |
+bool OverlayStrategyUnderlay::IsOverlayQuad(const DrawQuad* draw_quad) { |
+ switch (draw_quad->material) { |
+ case DrawQuad::STREAM_VIDEO_CONTENT: |
alexst (slow to review)
2015/03/05 14:12:00
We can allow WebGL here as well, I think.
achaulk
2015/03/18 16:31:26
Done.
|
+ return resource_provider_->AllowOverlay( |
+ StreamVideoDrawQuad::MaterialCast(draw_quad)->resource_id); |
+ default: |
+ return false; |
+ } |
+} |
+ |
+bool OverlayStrategyUnderlay::Attempt( |
+ RenderPassList* render_passes_in_draw_order, |
+ OverlayCandidateList* candidate_list) { |
+ if (!capability_checker_) |
+ return false; |
+ |
+ RenderPass* root_render_pass = render_passes_in_draw_order->back(); |
+ DCHECK(root_render_pass); |
+ |
+ OverlayCandidate candidate; |
+ QuadList& quad_list = root_render_pass->quad_list; |
+ auto candidate_iterator = quad_list.end(); |
+ for (auto it = quad_list.begin(); it != quad_list.end(); ++it) { |
alexst (slow to review)
2015/03/05 14:12:00
(auto it : quad_list) instead for simplicity?
|
+ const DrawQuad* draw_quad = *it; |
+ if (IsOverlayQuad(draw_quad) && |
+ GetCandidateQuadInfo(*draw_quad, &candidate)) { |
+ candidate_iterator = it; |
+ break; |
+ } |
+ } |
+ if (candidate_iterator == quad_list.end()) |
+ return false; |
+ |
+ // Add our primary surface. |
+ OverlayCandidateList candidates; |
+ OverlayCandidate main_image; |
+ main_image.display_rect = root_render_pass->output_rect; |
+ candidates.push_back(main_image); |
+ |
+ // Add the overlay. |
+ candidate.plane_z_order = 1; |
alexst (slow to review)
2015/03/05 14:12:00
This should be -1 for the underlay.
|
+ candidates.push_back(candidate); |
+ |
+ // Check for support. |
+ capability_checker_->CheckOverlaySupport(&candidates); |
+ |
+ // If the candidate can be handled by an overlay, create a pass for it. We |
+ // need to switch out the video quad with a black transparent one. |
+ if (candidates[1].overlay_handled) { |
+ const SharedQuadState* shared_quad_state = |
+ candidate_iterator->shared_quad_state; |
+ gfx::Rect rect = candidate_iterator->rect, |
+ opaque = candidate_iterator->opaque_rect, |
alexst (slow to review)
2015/03/05 14:12:00
If we are punching a hole, shouldn't opaque parts
|
+ visible = candidate_iterator->visible_rect; |
+ SolidColorDrawQuad* replacement = |
+ new (*candidate_iterator) SolidColorDrawQuad(); |
+ replacement->SetAll(shared_quad_state, rect, opaque, visible, false, |
+ SK_ColorTRANSPARENT, true); |
halliwell
2015/03/05 18:51:35
I tried patching this change into my build this mo
achaulk
2015/03/05 18:53:04
Hmm, I just took the existing VIDEO_HOLE setup for
|
+ candidate_list->swap(candidates); |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+} // namespace cc |