| 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_common.h" | 5 #include "cc/output/overlay_strategy_common.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" |
| 9 #include "cc/quads/io_surface_draw_quad.h" | 10 #include "cc/quads/io_surface_draw_quad.h" |
| 10 #include "cc/quads/solid_color_draw_quad.h" | 11 #include "cc/quads/solid_color_draw_quad.h" |
| 11 #include "cc/quads/stream_video_draw_quad.h" | 12 #include "cc/quads/stream_video_draw_quad.h" |
| 12 #include "cc/quads/texture_draw_quad.h" | 13 #include "cc/quads/texture_draw_quad.h" |
| 13 #include "cc/resources/resource_provider.h" | 14 #include "cc/resources/resource_provider.h" |
| 14 #include "ui/gfx/geometry/point3_f.h" | 15 #include "ui/gfx/geometry/point3_f.h" |
| 15 #include "ui/gfx/geometry/rect_conversions.h" | 16 #include "ui/gfx/geometry/rect_conversions.h" |
| 16 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
| 17 | 18 |
| 18 namespace cc { | 19 namespace cc { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 OverlayCandidate::GetOverlayTransform( | 94 OverlayCandidate::GetOverlayTransform( |
| 94 quad.shared_quad_state->quad_to_target_transform, quad.y_flipped); | 95 quad.shared_quad_state->quad_to_target_transform, quad.y_flipped); |
| 95 if (quad.background_color != SK_ColorTRANSPARENT || | 96 if (quad.background_color != SK_ColorTRANSPARENT || |
| 96 quad.premultiplied_alpha || | 97 quad.premultiplied_alpha || |
| 97 overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) | 98 overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) |
| 98 return false; | 99 return false; |
| 99 quad_info->resource_id = quad.resource_id(); | 100 quad_info->resource_id = quad.resource_id(); |
| 100 quad_info->resource_size_in_pixels = quad.resource_size_in_pixels(); | 101 quad_info->resource_size_in_pixels = quad.resource_size_in_pixels(); |
| 101 quad_info->transform = overlay_transform; | 102 quad_info->transform = overlay_transform; |
| 102 quad_info->uv_rect = BoundingRect(quad.uv_top_left, quad.uv_bottom_right); | 103 quad_info->uv_rect = BoundingRect(quad.uv_top_left, quad.uv_bottom_right); |
| 104 quad_info->quad_rect_in_target_space = MathUtil::MapEnclosingClippedRect( |
| 105 quad.shared_quad_state->quad_to_target_transform, quad.rect); |
| 106 quad_info->clip_rect = quad.shared_quad_state->clip_rect; |
| 107 quad_info->is_clipped = quad.shared_quad_state->is_clipped; |
| 103 return true; | 108 return true; |
| 104 } | 109 } |
| 105 | 110 |
| 106 bool OverlayStrategyCommon::GetVideoQuadInfo(const StreamVideoDrawQuad& quad, | 111 bool OverlayStrategyCommon::GetVideoQuadInfo(const StreamVideoDrawQuad& quad, |
| 107 OverlayCandidate* quad_info) { | 112 OverlayCandidate* quad_info) { |
| 108 if (!quad.allow_overlay()) | 113 if (!quad.allow_overlay()) |
| 109 return false; | 114 return false; |
| 110 gfx::OverlayTransform overlay_transform = | 115 gfx::OverlayTransform overlay_transform = |
| 111 OverlayCandidate::GetOverlayTransform( | 116 OverlayCandidate::GetOverlayTransform( |
| 112 quad.shared_quad_state->quad_to_target_transform, false); | 117 quad.shared_quad_state->quad_to_target_transform, false); |
| 113 if (overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) | 118 if (overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) |
| 114 return false; | 119 return false; |
| 115 if (!quad.matrix.IsScaleOrTranslation()) { | 120 if (!quad.matrix.IsScaleOrTranslation()) { |
| 116 // We cannot handle anything other than scaling & translation for texture | 121 // We cannot handle anything other than scaling & translation for texture |
| 117 // coordinates yet. | 122 // coordinates yet. |
| 118 return false; | 123 return false; |
| 119 } | 124 } |
| 120 quad_info->resource_id = quad.resource_id(); | 125 quad_info->resource_id = quad.resource_id(); |
| 121 quad_info->resource_size_in_pixels = quad.resource_size_in_pixels(); | 126 quad_info->resource_size_in_pixels = quad.resource_size_in_pixels(); |
| 122 quad_info->transform = overlay_transform; | 127 quad_info->transform = overlay_transform; |
| 128 quad_info->quad_rect_in_target_space = MathUtil::MapEnclosingClippedRect( |
| 129 quad.shared_quad_state->quad_to_target_transform, quad.rect); |
| 130 quad_info->clip_rect = quad.shared_quad_state->clip_rect; |
| 131 quad_info->is_clipped = quad.shared_quad_state->is_clipped; |
| 123 | 132 |
| 124 gfx::Point3F uv0 = gfx::Point3F(0, 0, 0); | 133 gfx::Point3F uv0 = gfx::Point3F(0, 0, 0); |
| 125 gfx::Point3F uv1 = gfx::Point3F(1, 1, 0); | 134 gfx::Point3F uv1 = gfx::Point3F(1, 1, 0); |
| 126 quad.matrix.TransformPoint(&uv0); | 135 quad.matrix.TransformPoint(&uv0); |
| 127 quad.matrix.TransformPoint(&uv1); | 136 quad.matrix.TransformPoint(&uv1); |
| 128 gfx::Vector3dF delta = uv1 - uv0; | 137 gfx::Vector3dF delta = uv1 - uv0; |
| 129 if (delta.x() < 0) { | 138 if (delta.x() < 0) { |
| 130 quad_info->transform = OverlayCandidate::ModifyTransform( | 139 quad_info->transform = OverlayCandidate::ModifyTransform( |
| 131 quad_info->transform, gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL); | 140 quad_info->transform, gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL); |
| 132 float x0 = uv0.x(); | 141 float x0 = uv0.x(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 154 return false; | 163 return false; |
| 155 gfx::OverlayTransform overlay_transform = | 164 gfx::OverlayTransform overlay_transform = |
| 156 OverlayCandidate::GetOverlayTransform( | 165 OverlayCandidate::GetOverlayTransform( |
| 157 quad.shared_quad_state->quad_to_target_transform, false); | 166 quad.shared_quad_state->quad_to_target_transform, false); |
| 158 if (overlay_transform != gfx::OVERLAY_TRANSFORM_NONE) | 167 if (overlay_transform != gfx::OVERLAY_TRANSFORM_NONE) |
| 159 return false; | 168 return false; |
| 160 quad_info->resource_id = quad.io_surface_resource_id(); | 169 quad_info->resource_id = quad.io_surface_resource_id(); |
| 161 quad_info->resource_size_in_pixels = quad.io_surface_size; | 170 quad_info->resource_size_in_pixels = quad.io_surface_size; |
| 162 quad_info->transform = overlay_transform; | 171 quad_info->transform = overlay_transform; |
| 163 quad_info->uv_rect = gfx::RectF(1.f, 1.f); | 172 quad_info->uv_rect = gfx::RectF(1.f, 1.f); |
| 173 quad_info->quad_rect_in_target_space = MathUtil::MapEnclosingClippedRect( |
| 174 quad.shared_quad_state->quad_to_target_transform, quad.rect); |
| 175 quad_info->clip_rect = quad.shared_quad_state->clip_rect; |
| 176 quad_info->is_clipped = quad.shared_quad_state->is_clipped; |
| 164 return true; | 177 return true; |
| 165 } | 178 } |
| 166 | 179 |
| 167 bool OverlayStrategyCommon::GetCandidateQuadInfo(const DrawQuad& draw_quad, | 180 bool OverlayStrategyCommon::GetCandidateQuadInfo(const DrawQuad& draw_quad, |
| 168 OverlayCandidate* quad_info) { | 181 OverlayCandidate* quad_info) { |
| 169 // All quad checks. | 182 // All quad checks. |
| 170 if (draw_quad.needs_blending || draw_quad.shared_quad_state->opacity != 1.f || | 183 if (draw_quad.needs_blending || draw_quad.shared_quad_state->opacity != 1.f || |
| 171 draw_quad.shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode) | 184 draw_quad.shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode) |
| 172 return false; | 185 return false; |
| 173 | 186 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 191 return false; | 204 return false; |
| 192 } | 205 } |
| 193 | 206 |
| 194 quad_info->format = RGBA_8888; | 207 quad_info->format = RGBA_8888; |
| 195 quad_info->display_rect = OverlayCandidate::GetOverlayRect( | 208 quad_info->display_rect = OverlayCandidate::GetOverlayRect( |
| 196 draw_quad.shared_quad_state->quad_to_target_transform, draw_quad.rect); | 209 draw_quad.shared_quad_state->quad_to_target_transform, draw_quad.rect); |
| 197 return true; | 210 return true; |
| 198 } | 211 } |
| 199 | 212 |
| 200 } // namespace cc | 213 } // namespace cc |
| OLD | NEW |