| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/overlay_strategy_sandwich.h" | 5 #include "cc/output/overlay_strategy_sandwich.h" |
| 6 | 6 |
| 7 #include "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
| 8 #include "cc/base/region.h" | 8 #include "cc/base/region.h" |
| 9 #include "cc/output/overlay_candidate_validator.h" | 9 #include "cc/output/overlay_candidate_validator.h" |
| 10 #include "cc/quads/draw_quad.h" | 10 #include "cc/quads/draw_quad.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 | 40 |
| 41 OverlayStrategySandwich::~OverlayStrategySandwich() {} | 41 OverlayStrategySandwich::~OverlayStrategySandwich() {} |
| 42 | 42 |
| 43 bool OverlayStrategySandwich::Attempt(ResourceProvider* resource_provider, | 43 bool OverlayStrategySandwich::Attempt(ResourceProvider* resource_provider, |
| 44 RenderPassList* render_passes, | 44 RenderPassList* render_passes, |
| 45 OverlayCandidateList* candidate_list) { | 45 OverlayCandidateList* candidate_list) { |
| 46 QuadList& quad_list = render_passes->back()->quad_list; | 46 QuadList& quad_list = render_passes->back()->quad_list; |
| 47 for (auto it = quad_list.begin(); it != quad_list.end();) { | 47 for (auto it = quad_list.begin(); it != quad_list.end();) { |
| 48 OverlayCandidate candidate; | 48 OverlayCandidate candidate; |
| 49 if (OverlayCandidate::FromDrawQuad(resource_provider, *it, &candidate)) | 49 if (it->material == DrawQuad::IO_SURFACE_CONTENT && |
| 50 capability_checker_->IsSupportedQuad(*it) && |
| 51 OverlayCandidate::FromDrawQuad(resource_provider, *it, &candidate)) { |
| 50 it = TryOverlay(render_passes->back(), candidate_list, candidate, it); | 52 it = TryOverlay(render_passes->back(), candidate_list, candidate, it); |
| 51 else | 53 } else { |
| 52 ++it; | 54 ++it; |
| 55 } |
| 53 } | 56 } |
| 54 | 57 |
| 55 return candidate_list->size() > 1; | 58 return candidate_list->size() > 1; |
| 56 } | 59 } |
| 57 | 60 |
| 58 QuadList::Iterator OverlayStrategySandwich::TryOverlay( | 61 QuadList::Iterator OverlayStrategySandwich::TryOverlay( |
| 59 RenderPass* render_pass, | 62 RenderPass* render_pass, |
| 60 OverlayCandidateList* candidate_list, | 63 OverlayCandidateList* candidate_list, |
| 61 const OverlayCandidate& candidate, | 64 const OverlayCandidate& candidate, |
| 62 QuadList::Iterator candidate_iter_in_quad_list) { | 65 QuadList::Iterator candidate_iter_in_quad_list) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 overlap_iter->shared_quad_state->quad_to_target_transform, | 102 overlap_iter->shared_quad_state->quad_to_target_transform, |
| 100 overlap_iter->rect); | 103 overlap_iter->rect); |
| 101 | 104 |
| 102 // Include the intersection of that quad with the candidate's quad in the | 105 // Include the intersection of that quad with the candidate's quad in the |
| 103 // covered region. | 106 // covered region. |
| 104 pixel_covered_rect.Intersect(candidate_pixel_rect); | 107 pixel_covered_rect.Intersect(candidate_pixel_rect); |
| 105 pixel_covered_region.Union(pixel_covered_rect); | 108 pixel_covered_region.Union(pixel_covered_rect); |
| 106 } | 109 } |
| 107 | 110 |
| 108 // Add the candidate's overlay. | 111 // Add the candidate's overlay. |
| 109 DCHECK(candidate.resource_id); | 112 DCHECK(candidate.resource.resource_id); |
| 110 OverlayCandidateList new_candidate_list = *candidate_list; | 113 OverlayCandidateList new_candidate_list = *candidate_list; |
| 111 new_candidate_list.push_back(candidate); | 114 new_candidate_list.push_back(candidate); |
| 112 OverlayCandidate& new_candidate = new_candidate_list.back(); | 115 OverlayCandidate& new_candidate = new_candidate_list.back(); |
| 113 new_candidate.plane_z_order = 1; | 116 new_candidate.plane_z_order = 1; |
| 114 new_candidate.display_rect = gfx::RectF(candidate_pixel_rect); | 117 new_candidate.display_rect = gfx::RectF(candidate_pixel_rect); |
| 115 new_candidate.quad_rect_in_target_space = candidate_pixel_rect; | 118 new_candidate.quad_rect_in_target_space = candidate_pixel_rect; |
| 116 new_candidate.uv_rect = candidate_uv_rect; | 119 new_candidate.uv_rect = candidate_uv_rect; |
| 117 | 120 |
| 118 // Add an overlay of the primary surface for any part of the candidate's | 121 // Add an overlay of the primary surface for any part of the candidate's |
| 119 // quad that was covered. | 122 // quad that was covered. |
| 120 std::vector<gfx::Rect> pixel_covered_rects; | 123 std::vector<gfx::Rect> pixel_covered_rects; |
| 121 for (Region::Iterator it(pixel_covered_region); it.has_rect(); it.next()) | 124 for (Region::Iterator it(pixel_covered_region); it.has_rect(); it.next()) |
| 122 pixel_covered_rects.push_back(it.rect()); | 125 pixel_covered_rects.push_back(it.rect()); |
| 123 for (const gfx::Rect& pixel_covered_rect : pixel_covered_rects) { | 126 for (const gfx::Rect& pixel_covered_rect : pixel_covered_rects) { |
| 124 OverlayCandidate main_image_on_top; | 127 OverlayCandidate main_image_on_top; |
| 125 main_image_on_top.display_rect = gfx::RectF(pixel_covered_rect); | 128 main_image_on_top.display_rect = gfx::RectF(pixel_covered_rect); |
| 126 main_image_on_top.uv_rect = gfx::RectF(pixel_covered_rect); | 129 main_image_on_top.uv_rect = gfx::RectF(pixel_covered_rect); |
| 127 main_image_on_top.uv_rect.Scale(1.f / pixel_bounds.width(), | 130 main_image_on_top.uv_rect.Scale(1.f / pixel_bounds.width(), |
| 128 1.f / pixel_bounds.height()); | 131 1.f / pixel_bounds.height()); |
| 129 main_image_on_top.plane_z_order = 2; | 132 main_image_on_top.plane_z_order = 2; |
| 130 main_image_on_top.transform = gfx::OVERLAY_TRANSFORM_NONE; | 133 main_image_on_top.transform = gfx::OVERLAY_TRANSFORM_NONE; |
| 131 main_image_on_top.use_output_surface_for_resource = true; | 134 main_image_on_top.resource_type = OverlayCandidate::USE_OUTPUT_SURFACE; |
| 132 new_candidate_list.push_back(main_image_on_top); | 135 new_candidate_list.push_back(main_image_on_top); |
| 133 } | 136 } |
| 134 | 137 |
| 135 // Check for support. | 138 // Check for support. |
| 136 capability_checker_->CheckOverlaySupport(&new_candidate_list); | 139 capability_checker_->CheckOverlaySupport(&new_candidate_list); |
| 137 for (const OverlayCandidate& candidate : new_candidate_list) { | 140 for (const OverlayCandidate& candidate : new_candidate_list) { |
| 138 if (!candidate.overlay_handled) | 141 if (!candidate.overlay_handled) |
| 139 return ++candidate_iter_in_quad_list; | 142 return ++candidate_iter_in_quad_list; |
| 140 } | 143 } |
| 141 | 144 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 172 SK_ColorTRANSPARENT, true); | 175 SK_ColorTRANSPARENT, true); |
| 173 ++candidate_iter_in_quad_list; | 176 ++candidate_iter_in_quad_list; |
| 174 } | 177 } |
| 175 } | 178 } |
| 176 | 179 |
| 177 candidate_list->swap(new_candidate_list); | 180 candidate_list->swap(new_candidate_list); |
| 178 return candidate_iter_in_quad_list; | 181 return candidate_iter_in_quad_list; |
| 179 } | 182 } |
| 180 | 183 |
| 181 } // namespace cc | 184 } // namespace cc |
| OLD | NEW |