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 is_promotable_hint(false), |
| 179 #endif |
176 plane_z_order(0), | 180 plane_z_order(0), |
177 is_unoccluded(false), | 181 is_unoccluded(false), |
178 overlay_handled(false) {} | 182 overlay_handled(false) { |
| 183 } |
179 | 184 |
180 OverlayCandidate::OverlayCandidate(const OverlayCandidate& other) = default; | 185 OverlayCandidate::OverlayCandidate(const OverlayCandidate& other) = default; |
181 | 186 |
182 OverlayCandidate::~OverlayCandidate() {} | 187 OverlayCandidate::~OverlayCandidate() {} |
183 | 188 |
184 // static | 189 // static |
185 bool OverlayCandidate::FromDrawQuad(ResourceProvider* resource_provider, | 190 bool OverlayCandidate::FromDrawQuad(ResourceProvider* resource_provider, |
186 const DrawQuad* quad, | 191 const DrawQuad* quad, |
187 OverlayCandidate* candidate) { | 192 OverlayCandidate* candidate) { |
188 if (quad->ShouldDrawWithBlending() || | 193 if (quad->ShouldDrawWithBlending() || |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 if (overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) | 280 if (overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) |
276 return false; | 281 return false; |
277 if (!quad->matrix.IsScaleOrTranslation()) { | 282 if (!quad->matrix.IsScaleOrTranslation()) { |
278 // We cannot handle anything other than scaling & translation for texture | 283 // We cannot handle anything other than scaling & translation for texture |
279 // coordinates yet. | 284 // coordinates yet. |
280 return false; | 285 return false; |
281 } | 286 } |
282 candidate->resource_id = quad->resource_id(); | 287 candidate->resource_id = quad->resource_id(); |
283 candidate->resource_size_in_pixels = quad->resource_size_in_pixels(); | 288 candidate->resource_size_in_pixels = quad->resource_size_in_pixels(); |
284 candidate->transform = overlay_transform; | 289 candidate->transform = overlay_transform; |
| 290 #if defined(OS_ANDROID) |
| 291 candidate->is_backed_by_surface_texture = |
| 292 resource_provider->IsBackedBySurfaceTexture(quad->resource_id()); |
| 293 #endif |
285 | 294 |
286 gfx::Point3F uv0 = gfx::Point3F(0, 0, 0); | 295 gfx::Point3F uv0 = gfx::Point3F(0, 0, 0); |
287 gfx::Point3F uv1 = gfx::Point3F(1, 1, 0); | 296 gfx::Point3F uv1 = gfx::Point3F(1, 1, 0); |
288 quad->matrix.TransformPoint(&uv0); | 297 quad->matrix.TransformPoint(&uv0); |
289 quad->matrix.TransformPoint(&uv1); | 298 quad->matrix.TransformPoint(&uv1); |
290 gfx::Vector3dF delta = uv1 - uv0; | 299 gfx::Vector3dF delta = uv1 - uv0; |
291 if (delta.x() < 0) { | 300 if (delta.x() < 0) { |
292 candidate->transform = ComposeTransforms( | 301 candidate->transform = ComposeTransforms( |
293 gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL, candidate->transform); | 302 gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL, candidate->transform); |
294 float x0 = uv0.x(); | 303 float x0 = uv0.x(); |
295 uv0.set_x(uv1.x()); | 304 uv0.set_x(uv1.x()); |
296 uv1.set_x(x0); | 305 uv1.set_x(x0); |
297 delta.set_x(-delta.x()); | 306 delta.set_x(-delta.x()); |
298 } | 307 } |
299 | 308 |
300 if (delta.y() < 0) { | 309 if (delta.y() < 0) { |
301 // In this situation, uv0y < uv1y. Since we overlay inverted, a request | 310 // In this situation, uv0y < uv1y. Since we overlay inverted, a request |
302 // to invert the source texture means we can just output the texture | 311 // to invert the source texture means we can just output the texture |
303 // normally and it will be correct. | 312 // normally and it will be correct. |
304 candidate->uv_rect = gfx::RectF(uv0.x(), uv1.y(), delta.x(), -delta.y()); | 313 candidate->uv_rect = gfx::RectF(uv0.x(), uv1.y(), delta.x(), -delta.y()); |
305 } else { | 314 } else { |
306 candidate->transform = ComposeTransforms( | 315 candidate->transform = ComposeTransforms( |
307 gfx::OVERLAY_TRANSFORM_FLIP_VERTICAL, candidate->transform); | 316 gfx::OVERLAY_TRANSFORM_FLIP_VERTICAL, candidate->transform); |
308 candidate->uv_rect = gfx::RectF(uv0.x(), uv0.y(), delta.x(), delta.y()); | 317 candidate->uv_rect = gfx::RectF(uv0.x(), uv0.y(), delta.x(), delta.y()); |
309 } | 318 } |
310 return true; | 319 return true; |
311 } | 320 } |
312 | 321 |
| 322 OverlayCandidateList::OverlayCandidateList() {} |
| 323 |
| 324 OverlayCandidateList::OverlayCandidateList(const OverlayCandidateList& other) = |
| 325 default; |
| 326 |
| 327 OverlayCandidateList::OverlayCandidateList(OverlayCandidateList&& other) = |
| 328 default; |
| 329 |
| 330 OverlayCandidateList::~OverlayCandidateList() {} |
| 331 |
| 332 OverlayCandidateList& OverlayCandidateList::operator=( |
| 333 const OverlayCandidateList& other) = default; |
| 334 |
| 335 OverlayCandidateList& OverlayCandidateList::operator=( |
| 336 OverlayCandidateList&& other) = default; |
| 337 |
313 } // namespace cc | 338 } // namespace cc |
OLD | NEW |