| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_single_on_top.h" | 5 #include "cc/output/overlay_strategy_single_on_top.h" |
| 6 | 6 |
| 7 #include "cc/output/output_surface.h" | 7 #include "cc/output/output_surface.h" |
| 8 #include "cc/quads/draw_quad.h" | 8 #include "cc/quads/draw_quad.h" |
| 9 #include "cc/quads/texture_draw_quad.h" | 9 #include "cc/quads/texture_draw_quad.h" |
| 10 #include "ui/gfx/rect_conversions.h" | 10 #include "ui/gfx/rect_conversions.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 QuadList& quad_list = root_render_pass->quad_list; | 30 QuadList& quad_list = root_render_pass->quad_list; |
| 31 const DrawQuad* candidate_quad = quad_list.front(); | 31 const DrawQuad* candidate_quad = quad_list.front(); |
| 32 if (candidate_quad->material != DrawQuad::TEXTURE_CONTENT) | 32 if (candidate_quad->material != DrawQuad::TEXTURE_CONTENT) |
| 33 return false; | 33 return false; |
| 34 | 34 |
| 35 const TextureDrawQuad& quad = *TextureDrawQuad::MaterialCast(candidate_quad); | 35 const TextureDrawQuad& quad = *TextureDrawQuad::MaterialCast(candidate_quad); |
| 36 if (!resource_provider_->AllowOverlay(quad.resource_id)) | 36 if (!resource_provider_->AllowOverlay(quad.resource_id)) |
| 37 return false; | 37 return false; |
| 38 | 38 |
| 39 // Simple quads only. | 39 // Simple quads only. |
| 40 if (!quad.quadTransform().IsIdentityOrTranslation() || quad.needs_blending || | 40 OverlayCandidate::OverlayTransform overlay_transform = |
| 41 OverlayCandidate::GetOverlayTransform(quad.quadTransform(), quad.flipped); |
| 42 if (overlay_transform == OverlayCandidate::INVALID || |
| 43 !quad.quadTransform().IsIdentityOrTranslation() || quad.needs_blending || |
| 41 quad.shared_quad_state->opacity != 1.f || | 44 quad.shared_quad_state->opacity != 1.f || |
| 42 quad.shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode || | 45 quad.shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode || |
| 43 quad.premultiplied_alpha || quad.background_color != SK_ColorTRANSPARENT) | 46 quad.premultiplied_alpha || quad.background_color != SK_ColorTRANSPARENT) |
| 44 return false; | 47 return false; |
| 45 | 48 |
| 46 // Add our primary surface. | 49 // Add our primary surface. |
| 47 OverlayCandidateValidator::OverlayCandidateList candidates; | 50 OverlayCandidateValidator::OverlayCandidateList candidates; |
| 48 OverlayCandidate main_image; | 51 OverlayCandidate main_image; |
| 49 main_image.display_rect = root_render_pass->output_rect; | 52 main_image.display_rect = root_render_pass->output_rect; |
| 50 main_image.format = RGBA_8888; | 53 main_image.format = RGBA_8888; |
| 51 candidates.push_back(main_image); | 54 candidates.push_back(main_image); |
| 52 | 55 |
| 53 // Add the overlay. | 56 // Add the overlay. |
| 54 OverlayCandidate candidate; | 57 OverlayCandidate candidate; |
| 55 gfx::RectF float_rect(quad.rect); | 58 candidate.transform = overlay_transform; |
| 56 quad.quadTransform().TransformRect(&float_rect); | 59 candidate.display_rect = |
| 57 candidate.transform = | 60 OverlayCandidate::GetOverlayRect(quad.quadTransform(), quad.rect); |
| 58 quad.flipped ? OverlayCandidate::FLIP_VERTICAL : OverlayCandidate::NONE; | |
| 59 candidate.display_rect = gfx::ToNearestRect(float_rect); | |
| 60 candidate.uv_rect = BoundingRect(quad.uv_top_left, quad.uv_bottom_right); | 61 candidate.uv_rect = BoundingRect(quad.uv_top_left, quad.uv_bottom_right); |
| 61 candidate.format = RGBA_8888; | 62 candidate.format = RGBA_8888; |
| 62 candidates.push_back(candidate); | 63 candidates.push_back(candidate); |
| 63 | 64 |
| 64 // Check for support. | 65 // Check for support. |
| 65 capability_checker_->CheckOverlaySupport(&candidates); | 66 capability_checker_->CheckOverlaySupport(&candidates); |
| 66 | 67 |
| 67 // If the candidate can be handled by an overlay, create a pass for it. | 68 // If the candidate can be handled by an overlay, create a pass for it. |
| 68 if (candidates[1].overlay_handled) { | 69 if (candidates[1].overlay_handled) { |
| 69 scoped_ptr<RenderPass> overlay_pass = RenderPass::Create(); | 70 scoped_ptr<RenderPass> overlay_pass = RenderPass::Create(); |
| 70 overlay_pass->overlay_state = RenderPass::SIMPLE_OVERLAY; | 71 overlay_pass->overlay_state = RenderPass::SIMPLE_OVERLAY; |
| 71 | 72 |
| 72 scoped_ptr<DrawQuad> overlay_quad = quad_list.take(quad_list.begin()); | 73 scoped_ptr<DrawQuad> overlay_quad = quad_list.take(quad_list.begin()); |
| 73 quad_list.erase(quad_list.begin()); | 74 quad_list.erase(quad_list.begin()); |
| 74 overlay_pass->quad_list.push_back(overlay_quad.Pass()); | 75 overlay_pass->quad_list.push_back(overlay_quad.Pass()); |
| 75 render_passes_in_draw_order->insert(render_passes_in_draw_order->begin(), | 76 render_passes_in_draw_order->insert(render_passes_in_draw_order->begin(), |
| 76 overlay_pass.Pass()); | 77 overlay_pass.Pass()); |
| 77 } | 78 } |
| 78 return candidates[1].overlay_handled; | 79 return candidates[1].overlay_handled; |
| 79 } | 80 } |
| 80 | 81 |
| 81 } // namespace cc | 82 } // namespace cc |
| OLD | NEW |