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/solid_color_draw_quad.h" | 10 #include "cc/quads/solid_color_draw_quad.h" |
10 #include "cc/quads/stream_video_draw_quad.h" | 11 #include "cc/quads/stream_video_draw_quad.h" |
11 #include "cc/quads/texture_draw_quad.h" | 12 #include "cc/quads/texture_draw_quad.h" |
12 #include "cc/resources/resource_provider.h" | 13 #include "cc/resources/resource_provider.h" |
13 #include "ui/gfx/geometry/point3_f.h" | 14 #include "ui/gfx/geometry/point3_f.h" |
14 #include "ui/gfx/geometry/rect_conversions.h" | 15 #include "ui/gfx/geometry/rect_conversions.h" |
15 #include "ui/gfx/transform.h" | 16 #include "ui/gfx/transform.h" |
16 | 17 |
17 namespace cc { | 18 namespace cc { |
18 | 19 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 SolidColorDrawQuad::MaterialCast(draw_quad); | 62 SolidColorDrawQuad::MaterialCast(draw_quad); |
62 SkColor color = solid_quad->color; | 63 SkColor color = solid_quad->color; |
63 float opacity = solid_quad->shared_quad_state->opacity; | 64 float opacity = solid_quad->shared_quad_state->opacity; |
64 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; | 65 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; |
65 return solid_quad->ShouldDrawWithBlending() && | 66 return solid_quad->ShouldDrawWithBlending() && |
66 alpha < std::numeric_limits<float>::epsilon(); | 67 alpha < std::numeric_limits<float>::epsilon(); |
67 } | 68 } |
68 return false; | 69 return false; |
69 } | 70 } |
70 | 71 |
71 bool OverlayStrategyCommon::GetTextureQuadInfo(const TextureDrawQuad& quad, | 72 bool OverlayStrategyCommon::GetTextureQuadInfo(const TextureDrawQuad& quad, |
danakj
2015/09/01 20:35:25
How come only video quad needs the clipped stuff?
| |
72 OverlayCandidate* quad_info) { | 73 OverlayCandidate* quad_info) { |
73 gfx::OverlayTransform overlay_transform = | 74 gfx::OverlayTransform overlay_transform = |
74 OverlayCandidate::GetOverlayTransform( | 75 OverlayCandidate::GetOverlayTransform( |
75 quad.shared_quad_state->quad_to_target_transform, quad.y_flipped); | 76 quad.shared_quad_state->quad_to_target_transform, quad.y_flipped); |
76 if (quad.background_color != SK_ColorTRANSPARENT || | 77 if (quad.background_color != SK_ColorTRANSPARENT || |
77 quad.premultiplied_alpha || | 78 quad.premultiplied_alpha || |
78 overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) | 79 overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) |
79 return false; | 80 return false; |
80 quad_info->resource_id = quad.resource_id(); | 81 quad_info->resource_id = quad.resource_id(); |
81 quad_info->resource_size_in_pixels = quad.resource_size_in_pixels(); | 82 quad_info->resource_size_in_pixels = quad.resource_size_in_pixels(); |
(...skipping 10 matching lines...) Expand all Loading... | |
92 if (overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) | 93 if (overlay_transform == gfx::OVERLAY_TRANSFORM_INVALID) |
93 return false; | 94 return false; |
94 if (!quad.matrix.IsScaleOrTranslation()) { | 95 if (!quad.matrix.IsScaleOrTranslation()) { |
95 // We cannot handle anything other than scaling & translation for texture | 96 // We cannot handle anything other than scaling & translation for texture |
96 // coordinates yet. | 97 // coordinates yet. |
97 return false; | 98 return false; |
98 } | 99 } |
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; |
103 quad_info->quad_rect_in_target_space = MathUtil::MapEnclosingClippedRect( | |
104 quad.shared_quad_state->quad_to_target_transform, quad.rect); | |
105 quad_info->clip_rect = quad.shared_quad_state->clip_rect; | |
106 quad_info->is_clipped = quad.shared_quad_state->is_clipped; | |
102 | 107 |
103 gfx::Point3F uv0 = gfx::Point3F(0, 0, 0); | 108 gfx::Point3F uv0 = gfx::Point3F(0, 0, 0); |
104 gfx::Point3F uv1 = gfx::Point3F(1, 1, 0); | 109 gfx::Point3F uv1 = gfx::Point3F(1, 1, 0); |
105 quad.matrix.TransformPoint(&uv0); | 110 quad.matrix.TransformPoint(&uv0); |
106 quad.matrix.TransformPoint(&uv1); | 111 quad.matrix.TransformPoint(&uv1); |
107 gfx::Vector3dF delta = uv1 - uv0; | 112 gfx::Vector3dF delta = uv1 - uv0; |
108 if (delta.x() < 0) { | 113 if (delta.x() < 0) { |
109 quad_info->transform = OverlayCandidate::ModifyTransform( | 114 quad_info->transform = OverlayCandidate::ModifyTransform( |
110 quad_info->transform, gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL); | 115 quad_info->transform, gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL); |
111 float x0 = uv0.x(); | 116 float x0 = uv0.x(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 return false; | 150 return false; |
146 } | 151 } |
147 | 152 |
148 quad_info->format = RGBA_8888; | 153 quad_info->format = RGBA_8888; |
149 quad_info->display_rect = OverlayCandidate::GetOverlayRect( | 154 quad_info->display_rect = OverlayCandidate::GetOverlayRect( |
150 draw_quad.shared_quad_state->quad_to_target_transform, draw_quad.rect); | 155 draw_quad.shared_quad_state->quad_to_target_transform, draw_quad.rect); |
151 return true; | 156 return true; |
152 } | 157 } |
153 | 158 |
154 } // namespace cc | 159 } // namespace cc |
OLD | NEW |