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/quads/io_surface_draw_quad.h" | 9 #include "cc/quads/io_surface_draw_quad.h" |
10 #include "cc/quads/solid_color_draw_quad.h" | 10 #include "cc/quads/solid_color_draw_quad.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 } | 26 } |
27 | 27 |
28 bool OverlayStrategyCommon::Attempt(RenderPassList* render_passes_in_draw_order, | 28 bool OverlayStrategyCommon::Attempt(RenderPassList* render_passes_in_draw_order, |
29 OverlayCandidateList* candidate_list, | 29 OverlayCandidateList* candidate_list, |
30 float device_scale_factor) { | 30 float device_scale_factor) { |
31 if (!capability_checker_) | 31 if (!capability_checker_) |
32 return false; | 32 return false; |
33 RenderPass* root_render_pass = render_passes_in_draw_order->back(); | 33 RenderPass* root_render_pass = render_passes_in_draw_order->back(); |
34 DCHECK(root_render_pass); | 34 DCHECK(root_render_pass); |
35 | 35 |
36 // Add our primary surface. | |
37 OverlayCandidate main_image; | |
38 main_image.display_rect = root_render_pass->output_rect; | |
39 DCHECK(candidate_list->empty()); | |
40 candidate_list->push_back(main_image); | |
41 | |
42 bool success = false; | |
ccameron
2015/09/08 17:16:06
Maybe change "success" name to "created_overlay" (
Andre
2015/09/08 17:30:03
Done.
| |
36 QuadList& quad_list = root_render_pass->quad_list; | 43 QuadList& quad_list = root_render_pass->quad_list; |
37 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) { | 44 for (auto it = quad_list.begin(); it != quad_list.end();) { |
38 OverlayCandidate candidate; | 45 OverlayCandidate candidate; |
39 const DrawQuad* draw_quad = *it; | 46 if (!GetCandidateQuadInfo(**it, &candidate)) { |
40 if (IsOverlayQuad(draw_quad) && | 47 ++it; |
41 GetCandidateQuadInfo(*draw_quad, &candidate) && | 48 continue; |
42 delegate_->TryOverlay(capability_checker_, render_passes_in_draw_order, | 49 } |
43 candidate_list, candidate, it, | 50 |
44 device_scale_factor)) | 51 OverlayResult result = delegate_->TryOverlay( |
45 return true; | 52 capability_checker_, render_passes_in_draw_order, candidate_list, |
53 candidate, &it, device_scale_factor); | |
54 switch (result) { | |
55 case DID_NOT_CREATE_OVERLAY: | |
56 ++it; | |
57 break; | |
58 case CREATED_OVERLAY_STOP_LOOKING: | |
59 return true; | |
60 case CREATED_OVERLAY_KEEP_LOOKING: | |
61 success = true; | |
62 break; | |
63 } | |
46 } | 64 } |
47 return false; | |
48 } | |
49 | 65 |
50 bool OverlayStrategyCommon::IsOverlayQuad(const DrawQuad* draw_quad) { | 66 if (!success) { |
51 switch (draw_quad->material) { | 67 DCHECK_EQ(1u, candidate_list->size()); |
52 case DrawQuad::TEXTURE_CONTENT: | 68 candidate_list->clear(); |
53 return TextureDrawQuad::MaterialCast(draw_quad)->allow_overlay(); | |
54 case DrawQuad::STREAM_VIDEO_CONTENT: | |
55 return StreamVideoDrawQuad::MaterialCast(draw_quad)->allow_overlay(); | |
56 case DrawQuad::IO_SURFACE_CONTENT: | |
57 return IOSurfaceDrawQuad::MaterialCast(draw_quad)->allow_overlay; | |
58 default: | |
59 return false; | |
60 } | 69 } |
70 | |
71 return success; | |
61 } | 72 } |
62 | 73 |
63 // static | 74 // static |
64 bool OverlayStrategyCommon::IsInvisibleQuad(const DrawQuad* draw_quad) { | 75 bool OverlayStrategyCommon::IsInvisibleQuad(const DrawQuad* draw_quad) { |
65 if (draw_quad->material == DrawQuad::SOLID_COLOR) { | 76 if (draw_quad->material == DrawQuad::SOLID_COLOR) { |
66 const SolidColorDrawQuad* solid_quad = | 77 const SolidColorDrawQuad* solid_quad = |
67 SolidColorDrawQuad::MaterialCast(draw_quad); | 78 SolidColorDrawQuad::MaterialCast(draw_quad); |
68 SkColor color = solid_quad->color; | 79 SkColor color = solid_quad->color; |
69 float opacity = solid_quad->shared_quad_state->opacity; | 80 float opacity = solid_quad->shared_quad_state->opacity; |
70 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; | 81 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 | 160 |
150 bool OverlayStrategyCommon::GetCandidateQuadInfo(const DrawQuad& draw_quad, | 161 bool OverlayStrategyCommon::GetCandidateQuadInfo(const DrawQuad& draw_quad, |
151 OverlayCandidate* quad_info) { | 162 OverlayCandidate* quad_info) { |
152 // All quad checks. | 163 // All quad checks. |
153 if (draw_quad.needs_blending || draw_quad.shared_quad_state->opacity != 1.f || | 164 if (draw_quad.needs_blending || draw_quad.shared_quad_state->opacity != 1.f || |
154 draw_quad.shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode) | 165 draw_quad.shared_quad_state->blend_mode != SkXfermode::kSrcOver_Mode) |
155 return false; | 166 return false; |
156 | 167 |
157 switch (draw_quad.material) { | 168 switch (draw_quad.material) { |
158 case DrawQuad::TEXTURE_CONTENT: { | 169 case DrawQuad::TEXTURE_CONTENT: { |
159 auto* quad = TextureDrawQuad::MaterialCast(&draw_quad); | 170 auto* quad = TextureDrawQuad::MaterialCast(&draw_quad); |
ccameron
2015/09/08 17:16:05
Maybe move the allow_overlay() into GetTextureQuad
Andre
2015/09/08 17:30:03
Done.
| |
160 if (!GetTextureQuadInfo(*quad, quad_info)) | 171 if (!quad->allow_overlay() || !GetTextureQuadInfo(*quad, quad_info)) |
161 return false; | 172 return false; |
162 } break; | 173 } break; |
163 case DrawQuad::STREAM_VIDEO_CONTENT: { | 174 case DrawQuad::STREAM_VIDEO_CONTENT: { |
164 auto* quad = StreamVideoDrawQuad::MaterialCast(&draw_quad); | 175 auto* quad = StreamVideoDrawQuad::MaterialCast(&draw_quad); |
165 if (!GetVideoQuadInfo(*quad, quad_info)) | 176 if (!quad->allow_overlay() || !GetVideoQuadInfo(*quad, quad_info)) |
166 return false; | 177 return false; |
167 } break; | 178 } break; |
168 case DrawQuad::IO_SURFACE_CONTENT: { | 179 case DrawQuad::IO_SURFACE_CONTENT: { |
169 auto* quad = IOSurfaceDrawQuad::MaterialCast(&draw_quad); | 180 auto* quad = IOSurfaceDrawQuad::MaterialCast(&draw_quad); |
170 if (!GetIOSurfaceQuadInfo(*quad, quad_info)) | 181 if (!quad->allow_overlay || !GetIOSurfaceQuadInfo(*quad, quad_info)) |
171 return false; | 182 return false; |
172 } break; | 183 } break; |
173 default: | 184 default: |
174 return false; | 185 return false; |
175 } | 186 } |
176 | 187 |
177 quad_info->format = RGBA_8888; | 188 quad_info->format = RGBA_8888; |
178 quad_info->display_rect = OverlayCandidate::GetOverlayRect( | 189 quad_info->display_rect = OverlayCandidate::GetOverlayRect( |
179 draw_quad.shared_quad_state->quad_to_target_transform, draw_quad.rect); | 190 draw_quad.shared_quad_state->quad_to_target_transform, draw_quad.rect); |
180 return true; | 191 return true; |
181 } | 192 } |
182 | 193 |
183 } // namespace cc | 194 } // namespace cc |
OLD | NEW |