Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #include "cc/output/overlay_strategy_underlay.h" | |
| 6 | |
| 7 #include "cc/quads/draw_quad.h" | |
| 8 #include "cc/quads/solid_color_draw_quad.h" | |
| 9 #include "cc/quads/stream_video_draw_quad.h" | |
| 10 #include "ui/gfx/geometry/rect_conversions.h" | |
| 11 #include "ui/gfx/transform.h" | |
| 12 | |
| 13 namespace cc { | |
| 14 | |
| 15 OverlayStrategyUnderlay::OverlayStrategyUnderlay( | |
| 16 OverlayCandidateValidator* capability_checker, | |
| 17 ResourceProvider* resource_provider) | |
| 18 : OverlayStrategyCommon(resource_provider), | |
| 19 capability_checker_(capability_checker) { | |
| 20 } | |
| 21 | |
| 22 bool OverlayStrategyUnderlay::IsOverlayQuad(const DrawQuad* draw_quad) { | |
| 23 switch (draw_quad->material) { | |
| 24 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.
| |
| 25 return resource_provider_->AllowOverlay( | |
| 26 StreamVideoDrawQuad::MaterialCast(draw_quad)->resource_id); | |
| 27 default: | |
| 28 return false; | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 bool OverlayStrategyUnderlay::Attempt( | |
| 33 RenderPassList* render_passes_in_draw_order, | |
| 34 OverlayCandidateList* candidate_list) { | |
| 35 if (!capability_checker_) | |
| 36 return false; | |
| 37 | |
| 38 RenderPass* root_render_pass = render_passes_in_draw_order->back(); | |
| 39 DCHECK(root_render_pass); | |
| 40 | |
| 41 OverlayCandidate candidate; | |
| 42 QuadList& quad_list = root_render_pass->quad_list; | |
| 43 auto candidate_iterator = quad_list.end(); | |
| 44 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?
| |
| 45 const DrawQuad* draw_quad = *it; | |
| 46 if (IsOverlayQuad(draw_quad) && | |
| 47 GetCandidateQuadInfo(*draw_quad, &candidate)) { | |
| 48 candidate_iterator = it; | |
| 49 break; | |
| 50 } | |
| 51 } | |
| 52 if (candidate_iterator == quad_list.end()) | |
| 53 return false; | |
| 54 | |
| 55 // Add our primary surface. | |
| 56 OverlayCandidateList candidates; | |
| 57 OverlayCandidate main_image; | |
| 58 main_image.display_rect = root_render_pass->output_rect; | |
| 59 candidates.push_back(main_image); | |
| 60 | |
| 61 // Add the overlay. | |
| 62 candidate.plane_z_order = 1; | |
|
alexst (slow to review)
2015/03/05 14:12:00
This should be -1 for the underlay.
| |
| 63 candidates.push_back(candidate); | |
| 64 | |
| 65 // Check for support. | |
| 66 capability_checker_->CheckOverlaySupport(&candidates); | |
| 67 | |
| 68 // If the candidate can be handled by an overlay, create a pass for it. We | |
| 69 // need to switch out the video quad with a black transparent one. | |
| 70 if (candidates[1].overlay_handled) { | |
| 71 const SharedQuadState* shared_quad_state = | |
| 72 candidate_iterator->shared_quad_state; | |
| 73 gfx::Rect rect = candidate_iterator->rect, | |
| 74 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
| |
| 75 visible = candidate_iterator->visible_rect; | |
| 76 SolidColorDrawQuad* replacement = | |
| 77 new (*candidate_iterator) SolidColorDrawQuad(); | |
| 78 replacement->SetAll(shared_quad_state, rect, opaque, visible, false, | |
| 79 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
| |
| 80 candidate_list->swap(candidates); | |
| 81 return true; | |
| 82 } | |
| 83 return false; | |
| 84 } | |
| 85 | |
| 86 } // namespace cc | |
| OLD | NEW |