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