Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / cc / output / overlay_candidate.cc
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
11 OverlayCandidate::OverlayCandidate()
12     : 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
19 OverlayCandidate::~OverlayCandidate() {}
20
21 // static
22 OverlayCandidate::OverlayTransform OverlayCandidate::GetOverlayTransform(
23     const gfx::Transform& quad_transform,
24     bool flipped) {
25   if (!quad_transform.IsIdentityOrTranslation())
26     return INVALID;
27
28   return flipped ? FLIP_VERTICAL : NONE;
29 }
30
31 // static
32 gfx::Rect OverlayCandidate::GetOverlayRect(const gfx::Transform& quad_transform,
33                                            const gfx::Rect& rect) {
34   DCHECK(quad_transform.IsIdentityOrTranslation());
35
36   gfx::RectF float_rect(rect);
37   quad_transform.TransformRect(&float_rect);
38   return gfx::ToNearestRect(float_rect);
39 }
40
41 }  // namespace cc