| 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" |
| 11 #include "cc/quads/io_surface_draw_quad.h" | |
| 12 #include "cc/quads/solid_color_draw_quad.h" | 11 #include "cc/quads/solid_color_draw_quad.h" |
| 13 #include "cc/quads/stream_video_draw_quad.h" | 12 #include "cc/quads/stream_video_draw_quad.h" |
| 14 #include "cc/quads/texture_draw_quad.h" | 13 #include "cc/quads/texture_draw_quad.h" |
| 15 #include "cc/quads/tile_draw_quad.h" | 14 #include "cc/quads/tile_draw_quad.h" |
| 16 #include "cc/resources/resource_provider.h" | 15 #include "cc/resources/resource_provider.h" |
| 17 #include "ui/gfx/geometry/rect_conversions.h" | 16 #include "ui/gfx/geometry/rect_conversions.h" |
| 18 #include "ui/gfx/geometry/vector3d_f.h" | 17 #include "ui/gfx/geometry/vector3d_f.h" |
| 19 | 18 |
| 20 namespace cc { | 19 namespace cc { |
| 21 | 20 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 candidate->is_clipped = quad->shared_quad_state->is_clipped; | 200 candidate->is_clipped = quad->shared_quad_state->is_clipped; |
| 202 | 201 |
| 203 switch (quad->material) { | 202 switch (quad->material) { |
| 204 case DrawQuad::TEXTURE_CONTENT: | 203 case DrawQuad::TEXTURE_CONTENT: |
| 205 return FromTextureQuad(resource_provider, | 204 return FromTextureQuad(resource_provider, |
| 206 TextureDrawQuad::MaterialCast(quad), candidate); | 205 TextureDrawQuad::MaterialCast(quad), candidate); |
| 207 case DrawQuad::STREAM_VIDEO_CONTENT: | 206 case DrawQuad::STREAM_VIDEO_CONTENT: |
| 208 return FromStreamVideoQuad(resource_provider, | 207 return FromStreamVideoQuad(resource_provider, |
| 209 StreamVideoDrawQuad::MaterialCast(quad), | 208 StreamVideoDrawQuad::MaterialCast(quad), |
| 210 candidate); | 209 candidate); |
| 211 case DrawQuad::IO_SURFACE_CONTENT: | |
| 212 return FromIOSurfaceQuad( | |
| 213 resource_provider, IOSurfaceDrawQuad::MaterialCast(quad), candidate); | |
| 214 default: | 210 default: |
| 215 break; | 211 break; |
| 216 } | 212 } |
| 217 | 213 |
| 218 return false; | 214 return false; |
| 219 } | 215 } |
| 220 | 216 |
| 221 // static | 217 // static |
| 222 bool OverlayCandidate::IsInvisibleQuad(const DrawQuad* quad) { | 218 bool OverlayCandidate::IsInvisibleQuad(const DrawQuad* quad) { |
| 223 if (quad->material == DrawQuad::SOLID_COLOR) { | 219 if (quad->material == DrawQuad::SOLID_COLOR) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // normally and it will be correct. | 301 // normally and it will be correct. |
| 306 candidate->uv_rect = gfx::RectF(uv0.x(), uv1.y(), delta.x(), -delta.y()); | 302 candidate->uv_rect = gfx::RectF(uv0.x(), uv1.y(), delta.x(), -delta.y()); |
| 307 } else { | 303 } else { |
| 308 candidate->transform = ComposeTransforms( | 304 candidate->transform = ComposeTransforms( |
| 309 gfx::OVERLAY_TRANSFORM_FLIP_VERTICAL, candidate->transform); | 305 gfx::OVERLAY_TRANSFORM_FLIP_VERTICAL, candidate->transform); |
| 310 candidate->uv_rect = gfx::RectF(uv0.x(), uv0.y(), delta.x(), delta.y()); | 306 candidate->uv_rect = gfx::RectF(uv0.x(), uv0.y(), delta.x(), delta.y()); |
| 311 } | 307 } |
| 312 return true; | 308 return true; |
| 313 } | 309 } |
| 314 | 310 |
| 315 // static | |
| 316 bool OverlayCandidate::FromIOSurfaceQuad(ResourceProvider* resource_provider, | |
| 317 const IOSurfaceDrawQuad* quad, | |
| 318 OverlayCandidate* candidate) { | |
| 319 if (!resource_provider->IsOverlayCandidate(quad->io_surface_resource_id())) | |
| 320 return false; | |
| 321 gfx::OverlayTransform overlay_transform = GetOverlayTransform( | |
| 322 quad->shared_quad_state->quad_to_target_transform, false); | |
| 323 if (overlay_transform != gfx::OVERLAY_TRANSFORM_NONE) | |
| 324 return false; | |
| 325 candidate->resource_id = quad->io_surface_resource_id(); | |
| 326 candidate->resource_size_in_pixels = quad->io_surface_size; | |
| 327 candidate->transform = overlay_transform; | |
| 328 candidate->uv_rect = gfx::RectF(1.f, 1.f); | |
| 329 return true; | |
| 330 } | |
| 331 | |
| 332 } // namespace cc | 311 } // namespace cc |
| OLD | NEW |