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

Unified Diff: cc/output/overlay_strategy_underlay_cast.cc

Issue 2693023002: Use SwapBuffersWithBounds on Chromecast (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: cc/output/overlay_strategy_underlay_cast.cc
diff --git a/cc/output/overlay_strategy_underlay_cast.cc b/cc/output/overlay_strategy_underlay_cast.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3023b1695e3226eae145f799fd2a40f5ec782e71
--- /dev/null
+++ b/cc/output/overlay_strategy_underlay_cast.cc
@@ -0,0 +1,72 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/output/overlay_strategy_underlay_cast.h"
+
+#include "base/containers/adapters.h"
+#include "cc/quads/draw_quad.h"
+#include "cc/quads/solid_color_draw_quad.h"
+#include "ui/gfx/geometry/rect_conversions.h"
+
+namespace cc {
+
+OverlayStrategyUnderlayCast::OverlayStrategyUnderlayCast(
+ OverlayCandidateValidator* capability_checker)
+ : OverlayStrategyUnderlay(capability_checker) {}
+
+OverlayStrategyUnderlayCast::~OverlayStrategyUnderlayCast() {}
+
+bool OverlayStrategyUnderlayCast::Attempt(
+ ResourceProvider* resource_provider,
+ RenderPass* render_pass,
+ OverlayCandidateList* candidate_list) {
+ const QuadList& const_quad_list = render_pass->quad_list;
+ bool found_underlay = false;
+ gfx::Rect content_bounds;
+ for (const auto* quad : base::Reversed(const_quad_list)) {
+ if (OverlayCandidate::IsInvisibleQuad(quad))
+ continue;
+
+ const auto& transform = quad->shared_quad_state->quad_to_target_transform;
+ gfx::RectF quad_rect = gfx::RectF(quad->rect);
+ transform.TransformRect(&quad_rect);
+
+ bool is_underlay = false;
+ if (!found_underlay) {
+ OverlayCandidate candidate;
+ is_underlay =
+ OverlayCandidate::FromDrawQuad(resource_provider, quad, &candidate);
+ found_underlay |= is_underlay;
+ }
+
+ if (!found_underlay && quad->material == DrawQuad::SOLID_COLOR) {
+ const SolidColorDrawQuad* solid = SolidColorDrawQuad::MaterialCast(quad);
+ if (solid->color == SK_ColorBLACK)
+ continue;
+ }
+
+ if (is_underlay) {
+ content_bounds.Subtract(ToEnclosedRect(quad_rect));
+ } else {
+ content_bounds.Union(ToEnclosingRect(quad_rect));
+ }
+ }
+
+ if (found_underlay) {
+ content_bounds_.resize(1);
+ content_bounds_[0] = content_bounds;
+ } else {
+ content_bounds_.clear();
+ }
+ return OverlayStrategyUnderlay::Attempt(resource_provider, render_pass,
+ candidate_list);
+}
+
+void OverlayStrategyUnderlayCast::GetContentBounds(
+ std::vector<gfx::Rect>* bounds) {
+ DCHECK(bounds);
+ bounds->insert(bounds->end(), content_bounds_.begin(), content_bounds_.end());
+}
+
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698