• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_candidate.h"
6 
7 #include <algorithm>
8 #include "base/logging.h"
9 #include "ui/gfx/geometry/rect_conversions.h"
10 
11 namespace cc {
12 
OverlayCandidate()13 OverlayCandidate::OverlayCandidate()
14     : transform(gfx::OVERLAY_TRANSFORM_NONE),
15       format(RGBA_8888),
16       uv_rect(0.f, 0.f, 1.f, 1.f),
17       resource_id(0),
18       plane_z_order(0),
19       overlay_handled(false) {}
20 
~OverlayCandidate()21 OverlayCandidate::~OverlayCandidate() {}
22 
23 // static
GetOverlayTransform(const gfx::Transform & quad_transform,bool flipped)24 gfx::OverlayTransform OverlayCandidate::GetOverlayTransform(
25     const gfx::Transform& quad_transform,
26     bool flipped) {
27   if (!quad_transform.IsIdentityOrTranslation())
28     return gfx::OVERLAY_TRANSFORM_INVALID;
29 
30   return flipped ? gfx::OVERLAY_TRANSFORM_FLIP_VERTICAL
31                  : gfx::OVERLAY_TRANSFORM_NONE;
32 }
33 
34 // static
GetOverlayRect(const gfx::Transform & quad_transform,const gfx::Rect & rect)35 gfx::Rect OverlayCandidate::GetOverlayRect(const gfx::Transform& quad_transform,
36                                            const gfx::Rect& rect) {
37   DCHECK(quad_transform.IsIdentityOrTranslation());
38 
39   gfx::RectF float_rect(rect);
40   quad_transform.TransformRect(&float_rect);
41   return gfx::ToNearestRect(float_rect);
42 }
43 
44 }  // namespace cc
45