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_candidate.h" | 5 #include "cc/output/overlay_candidate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 } // namespace | 167 } // namespace |
168 | 168 |
169 OverlayCandidate::OverlayCandidate() | 169 OverlayCandidate::OverlayCandidate() |
170 : transform(gfx::OVERLAY_TRANSFORM_NONE), | 170 : transform(gfx::OVERLAY_TRANSFORM_NONE), |
171 format(RGBA_8888), | 171 format(RGBA_8888), |
172 uv_rect(0.f, 0.f, 1.f, 1.f), | 172 uv_rect(0.f, 0.f, 1.f, 1.f), |
173 is_clipped(false), | 173 is_clipped(false), |
174 use_output_surface_for_resource(false), | 174 use_output_surface_for_resource(false), |
175 resource_id(0), | 175 resource_id(0), |
| 176 #if defined(OS_ANDROID) |
| 177 is_backed_by_surface_texture(false), |
| 178 #endif |
176 plane_z_order(0), | 179 plane_z_order(0), |
177 is_unoccluded(false), | 180 is_unoccluded(false), |
178 overlay_handled(false) {} | 181 overlay_handled(false) { |
| 182 } |
179 | 183 |
180 OverlayCandidate::OverlayCandidate(const OverlayCandidate& other) = default; | 184 OverlayCandidate::OverlayCandidate(const OverlayCandidate& other) = default; |
181 | 185 |
182 OverlayCandidate::~OverlayCandidate() {} | 186 OverlayCandidate::~OverlayCandidate() {} |
183 | 187 |
184 // static | 188 // static |
185 bool OverlayCandidate::FromDrawQuad(ResourceProvider* resource_provider, | 189 bool OverlayCandidate::FromDrawQuad(ResourceProvider* resource_provider, |
186 const DrawQuad* quad, | 190 const DrawQuad* quad, |
187 OverlayCandidate* candidate) { | 191 OverlayCandidate* candidate) { |
188 if (quad->ShouldDrawWithBlending() || | 192 if (quad->ShouldDrawWithBlending() || |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 if (overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) | 279 if (overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) |
276 return false; | 280 return false; |
277 if (!quad->matrix.IsScaleOrTranslation()) { | 281 if (!quad->matrix.IsScaleOrTranslation()) { |
278 // We cannot handle anything other than scaling & translation for texture | 282 // We cannot handle anything other than scaling & translation for texture |
279 // coordinates yet. | 283 // coordinates yet. |
280 return false; | 284 return false; |
281 } | 285 } |
282 candidate->resource_id = quad->resource_id(); | 286 candidate->resource_id = quad->resource_id(); |
283 candidate->resource_size_in_pixels = quad->resource_size_in_pixels(); | 287 candidate->resource_size_in_pixels = quad->resource_size_in_pixels(); |
284 candidate->transform = overlay_transform; | 288 candidate->transform = overlay_transform; |
| 289 #if defined(OS_ANDROID) |
| 290 candidate->is_backed_by_surface_texture = |
| 291 resource_provider->IsBackedBySurfaceTexture(quad->resource_id()); |
| 292 #endif |
285 | 293 |
286 gfx::Point3F uv0 = gfx::Point3F(0, 0, 0); | 294 gfx::Point3F uv0 = gfx::Point3F(0, 0, 0); |
287 gfx::Point3F uv1 = gfx::Point3F(1, 1, 0); | 295 gfx::Point3F uv1 = gfx::Point3F(1, 1, 0); |
288 quad->matrix.TransformPoint(&uv0); | 296 quad->matrix.TransformPoint(&uv0); |
289 quad->matrix.TransformPoint(&uv1); | 297 quad->matrix.TransformPoint(&uv1); |
290 gfx::Vector3dF delta = uv1 - uv0; | 298 gfx::Vector3dF delta = uv1 - uv0; |
291 if (delta.x() < 0) { | 299 if (delta.x() < 0) { |
292 candidate->transform = ComposeTransforms( | 300 candidate->transform = ComposeTransforms( |
293 gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL, candidate->transform); | 301 gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL, candidate->transform); |
294 float x0 = uv0.x(); | 302 float x0 = uv0.x(); |
295 uv0.set_x(uv1.x()); | 303 uv0.set_x(uv1.x()); |
296 uv1.set_x(x0); | 304 uv1.set_x(x0); |
297 delta.set_x(-delta.x()); | 305 delta.set_x(-delta.x()); |
298 } | 306 } |
299 | 307 |
300 if (delta.y() < 0) { | 308 if (delta.y() < 0) { |
301 // In this situation, uv0y < uv1y. Since we overlay inverted, a request | 309 // In this situation, uv0y < uv1y. Since we overlay inverted, a request |
302 // to invert the source texture means we can just output the texture | 310 // to invert the source texture means we can just output the texture |
303 // normally and it will be correct. | 311 // normally and it will be correct. |
304 candidate->uv_rect = gfx::RectF(uv0.x(), uv1.y(), delta.x(), -delta.y()); | 312 candidate->uv_rect = gfx::RectF(uv0.x(), uv1.y(), delta.x(), -delta.y()); |
305 } else { | 313 } else { |
306 candidate->transform = ComposeTransforms( | 314 candidate->transform = ComposeTransforms( |
307 gfx::OVERLAY_TRANSFORM_FLIP_VERTICAL, candidate->transform); | 315 gfx::OVERLAY_TRANSFORM_FLIP_VERTICAL, candidate->transform); |
308 candidate->uv_rect = gfx::RectF(uv0.x(), uv0.y(), delta.x(), delta.y()); | 316 candidate->uv_rect = gfx::RectF(uv0.x(), uv0.y(), delta.x(), delta.y()); |
309 } | 317 } |
310 return true; | 318 return true; |
311 } | 319 } |
312 | 320 |
| 321 bool OverlayCandidateValidator::IsResourcePromotable(ResourceId resource_id) { |
| 322 return false; |
| 323 } |
| 324 |
313 } // namespace cc | 325 } // namespace cc |
OLD | NEW |