Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: cc/output/overlay_strategy_common.cc

Issue 1304303002: Mac Overlays: Add sandwich strategy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@overlay_debug
Patch Set: incorporate review feedback Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/output/overlay_strategy_common.h ('k') | cc/output/overlay_strategy_sandwich.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "cc/quads/stream_video_draw_quad.h" 11 #include "cc/quads/stream_video_draw_quad.h"
12 #include "cc/quads/texture_draw_quad.h" 12 #include "cc/quads/texture_draw_quad.h"
13 #include "cc/resources/resource_provider.h" 13 #include "cc/resources/resource_provider.h"
14 #include "ui/gfx/geometry/point3_f.h" 14 #include "ui/gfx/geometry/point3_f.h"
15 #include "ui/gfx/geometry/rect_conversions.h" 15 #include "ui/gfx/geometry/rect_conversions.h"
16 #include "ui/gfx/transform.h" 16 #include "ui/gfx/transform.h"
17 17
18 namespace cc { 18 namespace cc {
19 19
20 OverlayStrategyCommon::OverlayStrategyCommon( 20 OverlayStrategyCommon::OverlayStrategyCommon(
21 OverlayCandidateValidator* capability_checker) 21 OverlayCandidateValidator* capability_checker,
22 : capability_checker_(capability_checker) { 22 OverlayStrategyCommonDelegate* delegate)
23 } 23 : capability_checker_(capability_checker), delegate_(delegate) {}
24 24
25 OverlayStrategyCommon::~OverlayStrategyCommon() { 25 OverlayStrategyCommon::~OverlayStrategyCommon() {
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 if (!capability_checker_) 31 if (!capability_checker_)
31 return false; 32 return false;
32 RenderPass* root_render_pass = render_passes_in_draw_order->back(); 33 RenderPass* root_render_pass = render_passes_in_draw_order->back();
33 DCHECK(root_render_pass); 34 DCHECK(root_render_pass);
34 35
35 QuadList& quad_list = root_render_pass->quad_list; 36 QuadList& quad_list = root_render_pass->quad_list;
36 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) { 37 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) {
37 OverlayCandidate candidate; 38 OverlayCandidate candidate;
38 const DrawQuad* draw_quad = *it; 39 const DrawQuad* draw_quad = *it;
39 if (IsOverlayQuad(draw_quad) && 40 if (IsOverlayQuad(draw_quad) &&
40 GetCandidateQuadInfo(*draw_quad, &candidate) && 41 GetCandidateQuadInfo(*draw_quad, &candidate) &&
41 TryOverlay(capability_checker_, render_passes_in_draw_order, 42 delegate_->TryOverlay(capability_checker_, render_passes_in_draw_order,
42 candidate_list, candidate, it)) 43 candidate_list, candidate, it,
44 device_scale_factor))
43 return true; 45 return true;
44 } 46 }
45 return false; 47 return false;
46 } 48 }
47 49
48 bool OverlayStrategyCommon::IsOverlayQuad(const DrawQuad* draw_quad) { 50 bool OverlayStrategyCommon::IsOverlayQuad(const DrawQuad* draw_quad) {
49 switch (draw_quad->material) { 51 switch (draw_quad->material) {
50 case DrawQuad::TEXTURE_CONTENT: 52 case DrawQuad::TEXTURE_CONTENT:
51 return TextureDrawQuad::MaterialCast(draw_quad)->allow_overlay(); 53 return TextureDrawQuad::MaterialCast(draw_quad)->allow_overlay();
52 case DrawQuad::STREAM_VIDEO_CONTENT: 54 case DrawQuad::STREAM_VIDEO_CONTENT:
53 return StreamVideoDrawQuad::MaterialCast(draw_quad)->allow_overlay(); 55 return StreamVideoDrawQuad::MaterialCast(draw_quad)->allow_overlay();
54 case DrawQuad::IO_SURFACE_CONTENT: 56 case DrawQuad::IO_SURFACE_CONTENT:
55 return IOSurfaceDrawQuad::MaterialCast(draw_quad)->allow_overlay; 57 return IOSurfaceDrawQuad::MaterialCast(draw_quad)->allow_overlay;
56 default: 58 default:
57 return false; 59 return false;
58 } 60 }
59 } 61 }
60 62
63 // static
61 bool OverlayStrategyCommon::IsInvisibleQuad(const DrawQuad* draw_quad) { 64 bool OverlayStrategyCommon::IsInvisibleQuad(const DrawQuad* draw_quad) {
62 if (draw_quad->material == DrawQuad::SOLID_COLOR) { 65 if (draw_quad->material == DrawQuad::SOLID_COLOR) {
63 const SolidColorDrawQuad* solid_quad = 66 const SolidColorDrawQuad* solid_quad =
64 SolidColorDrawQuad::MaterialCast(draw_quad); 67 SolidColorDrawQuad::MaterialCast(draw_quad);
65 SkColor color = solid_quad->color; 68 SkColor color = solid_quad->color;
66 float opacity = solid_quad->shared_quad_state->opacity; 69 float opacity = solid_quad->shared_quad_state->opacity;
67 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity; 70 float alpha = (SkColorGetA(color) * (1.0f / 255.0f)) * opacity;
68 return solid_quad->ShouldDrawWithBlending() && 71 return solid_quad->ShouldDrawWithBlending() &&
69 alpha < std::numeric_limits<float>::epsilon(); 72 alpha < std::numeric_limits<float>::epsilon();
70 } 73 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return false; 174 return false;
172 } 175 }
173 176
174 quad_info->format = RGBA_8888; 177 quad_info->format = RGBA_8888;
175 quad_info->display_rect = OverlayCandidate::GetOverlayRect( 178 quad_info->display_rect = OverlayCandidate::GetOverlayRect(
176 draw_quad.shared_quad_state->quad_to_target_transform, draw_quad.rect); 179 draw_quad.shared_quad_state->quad_to_target_transform, draw_quad.rect);
177 return true; 180 return true;
178 } 181 }
179 182
180 } // namespace cc 183 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/overlay_strategy_common.h ('k') | cc/output/overlay_strategy_sandwich.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698