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

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

Issue 2693023002: Use SwapBuffersWithBounds on Chromecast (Closed)
Patch Set: danakj nits Created 3 years, 9 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_underlay_cast.h ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/output/overlay_strategy_underlay_cast.h"
6
7 #include "base/containers/adapters.h"
8 #include "cc/quads/draw_quad.h"
9 #include "cc/quads/solid_color_draw_quad.h"
10 #include "ui/gfx/geometry/rect_conversions.h"
11
12 namespace cc {
13
14 OverlayStrategyUnderlayCast::OverlayStrategyUnderlayCast(
15 OverlayCandidateValidator* capability_checker)
16 : OverlayStrategyUnderlay(capability_checker) {}
17
18 OverlayStrategyUnderlayCast::~OverlayStrategyUnderlayCast() {}
19
20 bool OverlayStrategyUnderlayCast::Attempt(
21 ResourceProvider* resource_provider,
22 RenderPass* render_pass,
23 OverlayCandidateList* candidate_list,
24 std::vector<gfx::Rect>* content_bounds) {
25 const QuadList& const_quad_list = render_pass->quad_list;
26 bool found_underlay = false;
27 gfx::Rect content_rect;
28 for (const auto* quad : base::Reversed(const_quad_list)) {
29 if (OverlayCandidate::IsInvisibleQuad(quad))
30 continue;
31
32 const auto& transform = quad->shared_quad_state->quad_to_target_transform;
33 gfx::RectF quad_rect = gfx::RectF(quad->rect);
34 transform.TransformRect(&quad_rect);
35
36 bool is_underlay = false;
37 if (!found_underlay) {
38 OverlayCandidate candidate;
39 is_underlay =
40 OverlayCandidate::FromDrawQuad(resource_provider, quad, &candidate);
41 found_underlay = is_underlay;
42 }
43
44 if (!found_underlay && quad->material == DrawQuad::SOLID_COLOR) {
45 const SolidColorDrawQuad* solid = SolidColorDrawQuad::MaterialCast(quad);
46 if (solid->color == SK_ColorBLACK)
47 continue;
48 }
49
50 if (is_underlay) {
51 content_rect.Subtract(gfx::ToEnclosedRect(quad_rect));
52 } else {
53 content_rect.Union(gfx::ToEnclosingRect(quad_rect));
54 }
55 }
56
57 const bool result = OverlayStrategyUnderlay::Attempt(
58 resource_provider, render_pass, candidate_list, content_bounds);
59 DCHECK(content_bounds && content_bounds->empty());
60 DCHECK(result == found_underlay);
61 if (found_underlay) {
62 content_bounds->push_back(content_rect);
63 }
64 return result;
65 }
66
67 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/overlay_strategy_underlay_cast.h ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698